feat(image-annotate): v1.10.0 颜色语义统一、选中框改实线、选区命令归位、矢量图形补描边与填充
四个问题来自同一张界面截图,都是真缺陷。 1) 三处颜色各司其职。'#ff4444'/'#ffffff'/'#000000'/0.68 这些默认值原先散在 state.js、text.js、events.js 三处,改一处另两处不跟 —— 界面上就成了「同一个 概念三种颜色」。现在 text.js 导出 TEXT_DEFAULTS 做单点定义,state.js 与选项栏 都从这里取。三个色块统一外观但标记「生效状态」:描边宽度 0 / 底色关闭 / 图形处于描边模式时,色块显示灰色斜纹(不显示颜色本身),语义是「这里还没有 颜色」;只做半透明灰化不够,深色照样是一块黑方块。文字底色默认从纯黑 #000000 改为中性近黑 #101014(68% 透明),色块按真实不透明度渲染。选描边色时若宽度 为 0 自动给 6px,与「选底色即开底色」同一条原则。 2) 选中框从虚线改实线。虚线在修图软件里的语义是像素选区(蚂蚁线),文字外面 套一圈虚线会被当成「多出来一个删不掉的选区」。objects.js 的文字/形状、 layers.js 的位图图层三处同步改为实线,虚线只留给真正的像素选区。 3) 选区命令(全选/反选/取消)归位到选区工具。它们操作的是像素选区,跟文字对象 无关:以前挂在「选中文字/图形」的选项栏里,选中文字就冒出来;而矩形/套索 选区工具反而没有。现在选区工具有,选择工具「未选中任何元素」时也有。 4) 矢量图形补上描边色与填充色。每个形状新增独立 fillColor;描边色不再另起一份, 直接复用主色(左侧色板/吸管/选项栏一个真相源,四处永远同步)。fillColor===null 表示跟随描边色,于是新画的实心图形是同色实心,换主色整块跟着变。 矩形/圆形/钢笔/箭头的选项栏都出「描边 ■ / 填充 ■」色块(箭头无填充区域,只给 描边色);选中对象读它自己的值,没选中时改的是新建默认值。选填充色即自动切 实心,色块从斜纹变成实际颜色。「样式 描边/实心」也改成读选中对象自己的 fill (以前只看全局默认值,选中已实心的矩形却高亮「描边」,和画面反着来)。 顺带简化:文本样式与形状颜色共用同一套色块控件与 CSS,is-off 用斜纹 + 虚线边框;底色色块用 --sw-a 变量体现半透明。 harness 162 → 172 条全通(新增:默认色不写死、色块生效态、选区命令归位、 选中框实线覆盖率 ≥0.85、图形描边/填充色与实际像素);validate 9/9。 harness 自身两处改法:清选中改用「切到别的工具再切回」(画布上早有别的用例 留下的图形,点空白会点到它们);像素断言改成全画布统计同色像素 (矢量画布含 overlayPad 外扩,按图片坐标换算单点会采到别处)。
This commit is contained in:
1 parent
73a29715d3
commit
b63771f6e4
13 files changed
+654
-233
No files matched your search
+244
-168
@@ -9,7 +9,7 @@
|
||||
var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
id: 'image-annotate',
|
||||
name: '标注 / 修图',
|
||||
version: '1.9.1',
|
||||
version: '1.10.0',
|
||||
apiVersion: 1,
|
||||
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
||||
settings: {
|
||||
@@ -24,6 +24,131 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
|
||||
"use strict";
|
||||
(() => {
|
||||
// image-annotate/plugin/editor/text.js
|
||||
var TEXT_LINE_HEIGHT = 1.25;
|
||||
var TEXT_DEFAULTS = {
|
||||
color: "#ff4444",
|
||||
strokeWidth: 0,
|
||||
strokeColor: "#ffffff",
|
||||
bgFill: false,
|
||||
bgColor: "#101014",
|
||||
bgAlpha: 0.68
|
||||
};
|
||||
var BG_PAD_RATIO = 0.3;
|
||||
var _measureCtx = null;
|
||||
function measureCtx() {
|
||||
if (!_measureCtx) {
|
||||
const c = document.createElement("canvas");
|
||||
c.width = 8;
|
||||
c.height = 8;
|
||||
_measureCtx = c.getContext("2d");
|
||||
}
|
||||
return _measureCtx;
|
||||
}
|
||||
function weightOf(t) {
|
||||
const w = t && t.fontWeight;
|
||||
return w == null || w === "" ? "bold" : String(w);
|
||||
}
|
||||
function fontOf(t) {
|
||||
const size = Math.max(4, Number(t && t.fontSize) || 32);
|
||||
return weightOf(t) + " " + size + "px sans-serif";
|
||||
}
|
||||
function textMetrics(t) {
|
||||
const ctx = measureCtx();
|
||||
const font = fontOf(t);
|
||||
ctx.font = font;
|
||||
const raw = (t && t.text) == null ? "" : String(t.text);
|
||||
const lines = raw.split("\n");
|
||||
const widths = lines.map((line) => ctx.measureText(line).width);
|
||||
const size = Math.max(4, Number(t && t.fontSize) || 32);
|
||||
const lh = size * (Number(t && t.lineHeight) || TEXT_LINE_HEIGHT);
|
||||
const w = lines.length ? Math.max.apply(null, widths) : 0;
|
||||
const pad = t && t.bgFill ? Math.round(size * BG_PAD_RATIO) : 0;
|
||||
const sw = Math.max(0, Number(t && t.strokeWidth) || 0);
|
||||
return { lines, widths, w, h: lh * lines.length, lh, pad, sw, font, size };
|
||||
}
|
||||
function textBox(t) {
|
||||
const m = textMetrics(t);
|
||||
const half = m.sw / 2;
|
||||
return {
|
||||
x: t.x - half,
|
||||
y: t.y - half,
|
||||
w: Math.max(m.w, 2) + m.pad * 2 + m.sw,
|
||||
h: Math.max(m.h, 1) + m.pad * 2 + m.sw
|
||||
};
|
||||
}
|
||||
function alignOf(t) {
|
||||
const a = t && t.align;
|
||||
return a === "center" || a === "right" ? a : "left";
|
||||
}
|
||||
function drawTextObject(ctx, t) {
|
||||
const m = textMetrics(t);
|
||||
ctx.save();
|
||||
ctx.textBaseline = "top";
|
||||
ctx.globalAlpha = t.opacity != null ? t.opacity : 1;
|
||||
const b = textBox(t);
|
||||
const rot = t.rotation || 0;
|
||||
if (rot) {
|
||||
const cx = b.x + b.w / 2;
|
||||
const cy = b.y + b.h / 2;
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(rot * Math.PI / 180);
|
||||
ctx.translate(-cx, -cy);
|
||||
}
|
||||
ctx.font = m.font;
|
||||
const align = alignOf(t);
|
||||
const boxW = m.w + m.pad * 2;
|
||||
if (t.bgFill) {
|
||||
const r = Math.min(m.pad + 2, Math.min(boxW, m.h + m.pad * 2) / 2);
|
||||
ctx.globalAlpha = (t.opacity != null ? t.opacity : 1) * (t.bgAlpha == null ? TEXT_DEFAULTS.bgAlpha : t.bgAlpha);
|
||||
ctx.fillStyle = t.bgColor || TEXT_DEFAULTS.bgColor;
|
||||
const bx = t.x, by = t.y;
|
||||
const bw = boxW, bh = m.h + m.pad * 2;
|
||||
ctx.beginPath();
|
||||
if (typeof ctx.roundRect === "function") {
|
||||
ctx.roundRect(bx, by, bw, bh, r);
|
||||
} else {
|
||||
ctx.moveTo(bx + r, by);
|
||||
ctx.arcTo(bx + bw, by, bx + bw, by + bh, r);
|
||||
ctx.arcTo(bx + bw, by + bh, bx, by + bh, r);
|
||||
ctx.arcTo(bx, by + bh, bx, by, r);
|
||||
ctx.arcTo(bx, by, bx + bw, by, r);
|
||||
ctx.closePath();
|
||||
}
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = t.opacity != null ? t.opacity : 1;
|
||||
}
|
||||
ctx.textAlign = align;
|
||||
const left = t.x + m.pad;
|
||||
const ox = align === "center" ? left + m.w / 2 : align === "right" ? left + m.w : left;
|
||||
ctx.lineJoin = "round";
|
||||
ctx.miterLimit = 2;
|
||||
for (let i = 0; i < m.lines.length; i++) {
|
||||
const y = t.y + m.pad + i * m.lh;
|
||||
if (m.sw > 0) {
|
||||
ctx.lineWidth = m.sw;
|
||||
ctx.strokeStyle = t.strokeColor || TEXT_DEFAULTS.strokeColor;
|
||||
ctx.strokeText(m.lines[i], ox, y);
|
||||
}
|
||||
ctx.fillStyle = t.color || TEXT_DEFAULTS.color;
|
||||
ctx.fillText(m.lines[i], ox, y);
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
function newTextStyle(src) {
|
||||
const s = src || {};
|
||||
return {
|
||||
fontWeight: weightOf(s),
|
||||
align: alignOf(s),
|
||||
lineHeight: Number(s.lineHeight) || TEXT_LINE_HEIGHT,
|
||||
strokeWidth: Math.max(0, Number(s.strokeWidth) || 0),
|
||||
strokeColor: s.strokeColor || TEXT_DEFAULTS.strokeColor,
|
||||
bgFill: !!s.bgFill,
|
||||
bgColor: s.bgColor || TEXT_DEFAULTS.bgColor,
|
||||
bgAlpha: s.bgAlpha == null ? TEXT_DEFAULTS.bgAlpha : Number(s.bgAlpha)
|
||||
};
|
||||
}
|
||||
|
||||
// image-annotate/plugin/editor/state.js
|
||||
var ZOOM_MIN = 0.1;
|
||||
var ZOOM_MAX = 10;
|
||||
@@ -65,6 +190,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
// 矩形/圆形/箭头/钢笔的描边粗细
|
||||
shapeRadius: 0,
|
||||
// 矩形圆角半径 px(v1.9,仅 rect 有意义)
|
||||
// v1.10:矢量图形的填充色。null = 跟随描边色(新画的就是「同色实心」,
|
||||
// 换主色时整体跟着变),一旦单独选过填充色就固定下来(每形状自己存 fillColor)。
|
||||
shapeFillColor: null,
|
||||
textSize: 32,
|
||||
// 新建文字的字号 px
|
||||
// ---- v1.9 文字样式:这套是「新建文字」的默认值,每段文字自己存一份 ----
|
||||
@@ -74,12 +202,15 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
// left | center | right(多行时各行按块宽对齐)
|
||||
textLineHeight: 1.25,
|
||||
// 行高倍数(1.25 = 老版单行高度,勿随意改)
|
||||
textStrokeWidth: 0,
|
||||
textStrokeWidth: TEXT_DEFAULTS.strokeWidth,
|
||||
// 描边宽度 px,0 = 无描边
|
||||
textStrokeColor: "#ffffff",
|
||||
textBgFill: false,
|
||||
textStrokeColor: TEXT_DEFAULTS.strokeColor,
|
||||
textBgFill: TEXT_DEFAULTS.bgFill,
|
||||
// 底色块
|
||||
textBgColor: "#000000",
|
||||
textBgColor: TEXT_DEFAULTS.bgColor,
|
||||
// 中性近黑,不再是纯黑 #000000
|
||||
textBgAlpha: TEXT_DEFAULTS.bgAlpha,
|
||||
// 底色透明度(色块按这个不透明度显示,所见即所得)
|
||||
// 最近使用颜色(最多 8 个,存 ctx.settings,跨会话保留)
|
||||
recentColors: [],
|
||||
// 图层系统
|
||||
@@ -662,6 +793,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
ctx.arcTo(x, y, x + w, y, rr);
|
||||
ctx.closePath();
|
||||
}
|
||||
function strokeOf(s) {
|
||||
return s && s.color || S.color;
|
||||
}
|
||||
function fillOf(s) {
|
||||
return s && s.fillColor || strokeOf(s);
|
||||
}
|
||||
function drawShape(ctx, s) {
|
||||
ctx.save();
|
||||
ctx.globalAlpha = s.opacity != null ? s.opacity : 1;
|
||||
@@ -673,7 +810,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
ctx.rotate(rot * Math.PI / 180);
|
||||
ctx.translate(-cx, -cy);
|
||||
}
|
||||
ctx.strokeStyle = s.color;
|
||||
ctx.strokeStyle = strokeOf(s);
|
||||
ctx.lineWidth = s.lw;
|
||||
ctx.lineCap = "round";
|
||||
ctx.lineJoin = "round";
|
||||
@@ -685,7 +822,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
for (let i = 1; i < pts.length; i++) ctx.lineTo(pts[i].x, pts[i].y);
|
||||
if (s.closed) ctx.closePath();
|
||||
if (s.closed && s.fill) {
|
||||
ctx.fillStyle = s.color;
|
||||
ctx.fillStyle = fillOf(s);
|
||||
ctx.fill();
|
||||
}
|
||||
ctx.stroke();
|
||||
@@ -697,13 +834,13 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
ctx.beginPath();
|
||||
roundRectPath(ctx, rx, ry, rw, rh, radius);
|
||||
if (s.fill) {
|
||||
ctx.fillStyle = s.color;
|
||||
ctx.fillStyle = fillOf(s);
|
||||
ctx.fill();
|
||||
}
|
||||
ctx.stroke();
|
||||
} else {
|
||||
if (s.fill) {
|
||||
ctx.fillStyle = s.color;
|
||||
ctx.fillStyle = fillOf(s);
|
||||
ctx.fillRect(rx, ry, rw, rh);
|
||||
}
|
||||
ctx.strokeRect(rx, ry, rw, rh);
|
||||
@@ -714,12 +851,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
ctx.beginPath();
|
||||
ctx.ellipse(rx + rw / 2, ry + rh / 2, Math.max(1, rw / 2), Math.max(1, rh / 2), 0, 0, Math.PI * 2);
|
||||
if (s.fill) {
|
||||
ctx.fillStyle = s.color;
|
||||
ctx.fillStyle = fillOf(s);
|
||||
ctx.fill();
|
||||
}
|
||||
ctx.stroke();
|
||||
} else {
|
||||
ctx.fillStyle = s.color;
|
||||
ctx.fillStyle = strokeOf(s);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(s.x1, s.y1);
|
||||
ctx.lineTo(s.x2, s.y2);
|
||||
@@ -990,123 +1127,6 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
}, 2600);
|
||||
}
|
||||
|
||||
// image-annotate/plugin/editor/text.js
|
||||
var TEXT_LINE_HEIGHT = 1.25;
|
||||
var BG_PAD_RATIO = 0.3;
|
||||
var _measureCtx = null;
|
||||
function measureCtx() {
|
||||
if (!_measureCtx) {
|
||||
const c = document.createElement("canvas");
|
||||
c.width = 8;
|
||||
c.height = 8;
|
||||
_measureCtx = c.getContext("2d");
|
||||
}
|
||||
return _measureCtx;
|
||||
}
|
||||
function weightOf(t) {
|
||||
const w = t && t.fontWeight;
|
||||
return w == null || w === "" ? "bold" : String(w);
|
||||
}
|
||||
function fontOf(t) {
|
||||
const size = Math.max(4, Number(t && t.fontSize) || 32);
|
||||
return weightOf(t) + " " + size + "px sans-serif";
|
||||
}
|
||||
function textMetrics(t) {
|
||||
const ctx = measureCtx();
|
||||
const font = fontOf(t);
|
||||
ctx.font = font;
|
||||
const raw = (t && t.text) == null ? "" : String(t.text);
|
||||
const lines = raw.split("\n");
|
||||
const widths = lines.map((line) => ctx.measureText(line).width);
|
||||
const size = Math.max(4, Number(t && t.fontSize) || 32);
|
||||
const lh = size * (Number(t && t.lineHeight) || TEXT_LINE_HEIGHT);
|
||||
const w = lines.length ? Math.max.apply(null, widths) : 0;
|
||||
const pad = t && t.bgFill ? Math.round(size * BG_PAD_RATIO) : 0;
|
||||
const sw = Math.max(0, Number(t && t.strokeWidth) || 0);
|
||||
return { lines, widths, w, h: lh * lines.length, lh, pad, sw, font, size };
|
||||
}
|
||||
function textBox(t) {
|
||||
const m = textMetrics(t);
|
||||
const half = m.sw / 2;
|
||||
return {
|
||||
x: t.x - half,
|
||||
y: t.y - half,
|
||||
w: Math.max(m.w, 2) + m.pad * 2 + m.sw,
|
||||
h: Math.max(m.h, 1) + m.pad * 2 + m.sw
|
||||
};
|
||||
}
|
||||
function alignOf(t) {
|
||||
const a = t && t.align;
|
||||
return a === "center" || a === "right" ? a : "left";
|
||||
}
|
||||
function drawTextObject(ctx, t) {
|
||||
const m = textMetrics(t);
|
||||
ctx.save();
|
||||
ctx.textBaseline = "top";
|
||||
ctx.globalAlpha = t.opacity != null ? t.opacity : 1;
|
||||
const b = textBox(t);
|
||||
const rot = t.rotation || 0;
|
||||
if (rot) {
|
||||
const cx = b.x + b.w / 2;
|
||||
const cy = b.y + b.h / 2;
|
||||
ctx.translate(cx, cy);
|
||||
ctx.rotate(rot * Math.PI / 180);
|
||||
ctx.translate(-cx, -cy);
|
||||
}
|
||||
ctx.font = m.font;
|
||||
const align = alignOf(t);
|
||||
const boxW = m.w + m.pad * 2;
|
||||
if (t.bgFill) {
|
||||
const r = Math.min(m.pad + 2, Math.min(boxW, m.h + m.pad * 2) / 2);
|
||||
ctx.globalAlpha = (t.opacity != null ? t.opacity : 1) * (t.bgAlpha == null ? 0.68 : t.bgAlpha);
|
||||
ctx.fillStyle = t.bgColor || "#000000";
|
||||
const bx = t.x, by = t.y;
|
||||
const bw = boxW, bh = m.h + m.pad * 2;
|
||||
ctx.beginPath();
|
||||
if (typeof ctx.roundRect === "function") {
|
||||
ctx.roundRect(bx, by, bw, bh, r);
|
||||
} else {
|
||||
ctx.moveTo(bx + r, by);
|
||||
ctx.arcTo(bx + bw, by, bx + bw, by + bh, r);
|
||||
ctx.arcTo(bx + bw, by + bh, bx, by + bh, r);
|
||||
ctx.arcTo(bx, by + bh, bx, by, r);
|
||||
ctx.arcTo(bx, by, bx + bw, by, r);
|
||||
ctx.closePath();
|
||||
}
|
||||
ctx.fill();
|
||||
ctx.globalAlpha = t.opacity != null ? t.opacity : 1;
|
||||
}
|
||||
ctx.textAlign = align;
|
||||
const left = t.x + m.pad;
|
||||
const ox = align === "center" ? left + m.w / 2 : align === "right" ? left + m.w : left;
|
||||
ctx.lineJoin = "round";
|
||||
ctx.miterLimit = 2;
|
||||
for (let i = 0; i < m.lines.length; i++) {
|
||||
const y = t.y + m.pad + i * m.lh;
|
||||
if (m.sw > 0) {
|
||||
ctx.lineWidth = m.sw;
|
||||
ctx.strokeStyle = t.strokeColor || "#ffffff";
|
||||
ctx.strokeText(m.lines[i], ox, y);
|
||||
}
|
||||
ctx.fillStyle = t.color || "#ff4444";
|
||||
ctx.fillText(m.lines[i], ox, y);
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
function newTextStyle(src) {
|
||||
const s = src || {};
|
||||
return {
|
||||
fontWeight: weightOf(s),
|
||||
align: alignOf(s),
|
||||
lineHeight: Number(s.lineHeight) || TEXT_LINE_HEIGHT,
|
||||
strokeWidth: Math.max(0, Number(s.strokeWidth) || 0),
|
||||
strokeColor: s.strokeColor || "#ffffff",
|
||||
bgFill: !!s.bgFill,
|
||||
bgColor: s.bgColor || "#000000",
|
||||
bgAlpha: s.bgAlpha == null ? 0.68 : Number(s.bgAlpha)
|
||||
};
|
||||
}
|
||||
|
||||
// image-annotate/plugin/editor/snap.js
|
||||
var SNAP_SCREEN_PX = 6;
|
||||
var GUIDE_COLOR = "#ff2d95";
|
||||
@@ -1548,14 +1568,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
octx.save();
|
||||
octx.strokeStyle = "#e8a735";
|
||||
octx.lineWidth = 1.5 / viewScale();
|
||||
octx.setLineDash([6 / viewScale(), 3 / viewScale()]);
|
||||
const corners = boxCorners(b.x, b.y, b.w, b.h, rot);
|
||||
octx.beginPath();
|
||||
octx.moveTo(corners[0][0], corners[0][1]);
|
||||
for (let i = 1; i < corners.length; i++) octx.lineTo(corners[i][0], corners[i][1]);
|
||||
octx.closePath();
|
||||
octx.stroke();
|
||||
octx.setLineDash([]);
|
||||
const hs = 5.5 / viewScale();
|
||||
octx.fillStyle = "#ffffff";
|
||||
octx.strokeStyle = "#e8a735";
|
||||
@@ -1600,14 +1618,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
octx.save();
|
||||
octx.strokeStyle = "#e8a735";
|
||||
octx.lineWidth = 1.5 / viewScale();
|
||||
octx.setLineDash([6 / viewScale(), 3 / viewScale()]);
|
||||
const corners = boxCorners(b.x - 2 / viewScale(), b.y - 2 / viewScale(), b.w + 4 / viewScale(), b.h + 4 / viewScale(), rot);
|
||||
octx.beginPath();
|
||||
octx.moveTo(corners[0][0], corners[0][1]);
|
||||
for (let i = 1; i < corners.length; i++) octx.lineTo(corners[i][0], corners[i][1]);
|
||||
octx.closePath();
|
||||
octx.stroke();
|
||||
octx.setLineDash([]);
|
||||
const hs = 5.5 / viewScale();
|
||||
octx.fillStyle = "#ffffff";
|
||||
octx.strokeStyle = "#e8a735";
|
||||
@@ -2030,14 +2046,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
ctx.save();
|
||||
ctx.strokeStyle = "#e8a735";
|
||||
ctx.lineWidth = 1.5 / viewScale();
|
||||
ctx.setLineDash([6 / viewScale(), 3 / viewScale()]);
|
||||
const corners = boxCorners(box.x, box.y, box.w, box.h, rot);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(corners[0][0], corners[0][1]);
|
||||
for (let i = 1; i < corners.length; i++) ctx.lineTo(corners[i][0], corners[i][1]);
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
ctx.setLineDash([]);
|
||||
ctx.fillStyle = "#fff";
|
||||
ctx.strokeStyle = "#e8a735";
|
||||
const pts = frameHandlePoints(box, rot);
|
||||
@@ -4498,6 +4512,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
x2: pos.x,
|
||||
y2: pos.y,
|
||||
color: S.color,
|
||||
fillColor: S.shapeFillColor,
|
||||
lw: Math.max(1, S.shapeLineWidth),
|
||||
lineWidth: Math.max(1, S.shapeLineWidth),
|
||||
fill: S.tool === "rect" || S.tool === "circle" ? !!S.rectFill : false,
|
||||
@@ -4688,6 +4703,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
x2: pos.x,
|
||||
y2: pos.y,
|
||||
color: S.color,
|
||||
fillColor: S.shapeFillColor,
|
||||
// null = 跟随描边色(改主色时整块跟着变)
|
||||
lw: Math.max(1, S.shapeLineWidth),
|
||||
fill: S.tool === "rect" || S.tool === "circle" ? !!S.rectFill : false,
|
||||
radius: S.tool === "rect" ? Math.max(0, S.shapeRadius) : 0,
|
||||
@@ -4902,11 +4919,22 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
<button type="button" class="iwb-editor-crop-cancel" data-action="cancelCrop" title="Esc">✗ 取消</button>
|
||||
<span class="iwb-opt-hint">拖出裁剪框;Enter 确认 · Esc 取消;裁剪后可 Ctrl+Z</span>`;
|
||||
}
|
||||
function fillStyleHTML(owner) {
|
||||
const fill = owner === "pen" ? S.penFill : S.rectFill;
|
||||
function shapeColorHTML(sh, owner) {
|
||||
const stroke = sh ? sh.color || S.color : S.color;
|
||||
const fillOn = sh ? !!sh.fill : owner === "pen" ? S.penFill : S.rectFill;
|
||||
const fill = sh ? sh.fillColor || sh.color || S.color : S.shapeFillColor || S.color;
|
||||
let html = `<span class="iwb-opt-label">描边</span><input type="color" class="iwb-opt-color" data-shape-color="stroke" value="${stroke}" title="描边颜色(与左侧主色同步,吸管取色也写这里)">`;
|
||||
if (owner) {
|
||||
html += `<span class="iwb-opt-label">填充</span><input type="color" class="iwb-opt-color${fillOn ? "" : " is-off"}" data-shape-color="fill" data-fill-owner="${owner}" value="${fill}" title="填充颜色${fillOn ? "" : ";当前是描边模式,选色会自动切成实心"}">`;
|
||||
}
|
||||
return html;
|
||||
}
|
||||
function fillStyleHTML(owner, sh) {
|
||||
const own = !!sh && (owner === "pen" ? sh.type === "pen" : sh.type === "rect" || sh.type === "circle");
|
||||
const fill = own ? !!sh.fill : owner === "pen" ? S.penFill : S.rectFill;
|
||||
return `<span class="iwb-opt-label">样式</span>
|
||||
<button class="iwb-opt-btn${fill ? "" : " active"}" data-opt-toggle="stroke" data-fill-owner="${owner}" data-value="stroke" title="描边 (Shift+X 切换)">描边</button>
|
||||
<button class="iwb-opt-btn${fill ? " active" : ""}" data-opt-toggle="fill" data-fill-owner="${owner}" data-value="fill" title="实心 (Shift+X 切换)">实心</button>`;
|
||||
<button class="iwb-opt-btn${fill ? "" : " active"}" data-opt-toggle="stroke" data-fill-owner="${owner}" data-value="stroke" title="只描边 (Shift+X 切换)">描边</button>
|
||||
<button class="iwb-opt-btn${fill ? " active" : ""}" data-opt-toggle="fill" data-fill-owner="${owner}" data-value="fill" title="实心填充 (Shift+X 切换)">实心</button>`;
|
||||
}
|
||||
var SHAPE_NAMES = { rect: "矩形", circle: "圆形", arrow: "箭头", pen: "钢笔路径" };
|
||||
var TEXT_STYLE_STATE_KEY = {
|
||||
@@ -4926,11 +4954,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
return {
|
||||
fontWeight: String(pick("fontWeight", "textWeight", "bold")),
|
||||
align: pick("align", "textAlign", "left"),
|
||||
lineHeight: Number(pick("lineHeight", "textLineHeight", 1.25)) || 1.25,
|
||||
strokeWidth: Math.max(0, Number(pick("strokeWidth", "textStrokeWidth", 0)) || 0),
|
||||
strokeColor: pick("strokeColor", "textStrokeColor", "#ffffff"),
|
||||
bgFill: !!pick("bgFill", "textBgFill", false),
|
||||
bgColor: pick("bgColor", "textBgColor", "#000000")
|
||||
lineHeight: Number(pick("lineHeight", "textLineHeight", TEXT_LINE_HEIGHT)) || TEXT_LINE_HEIGHT,
|
||||
strokeWidth: Math.max(0, Number(pick("strokeWidth", "textStrokeWidth", TEXT_DEFAULTS.strokeWidth)) || 0),
|
||||
strokeColor: pick("strokeColor", "textStrokeColor", TEXT_DEFAULTS.strokeColor),
|
||||
bgFill: !!pick("bgFill", "textBgFill", TEXT_DEFAULTS.bgFill),
|
||||
bgColor: pick("bgColor", "textBgColor", TEXT_DEFAULTS.bgColor),
|
||||
bgAlpha: Number(pick("bgAlpha", "textBgAlpha", TEXT_DEFAULTS.bgAlpha)) || TEXT_DEFAULTS.bgAlpha
|
||||
};
|
||||
}
|
||||
function textStyleHTML(t) {
|
||||
@@ -4945,9 +4974,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
<span class="iwb-opt-sep"></span>
|
||||
<span class="iwb-opt-label">描边</span>
|
||||
<input type="number" class="iwb-opt-num" data-opt="textStrokeWidth" min="0" max="40" step="1" value="${Math.round(v.strokeWidth)}"><span class="iwb-opt-unit">px</span>
|
||||
<input type="color" class="iwb-opt-color" data-opt-color="strokeColor" value="${v.strokeColor}" title="描边颜色">
|
||||
<button class="iwb-opt-btn${v.bgFill ? " active" : ""}" data-opt-text="bgFill" data-value="${v.bgFill ? "0" : "1"}" title="给文字加一块半透明底色,压在花背景上也能看清">底色</button>
|
||||
<input type="color" class="iwb-opt-color" data-opt-color="bgColor" value="${v.bgColor}" title="底色颜色;选色会自动开启底色,不用先点左侧按钮">`;
|
||||
<input type="color" class="iwb-opt-color${v.strokeWidth > 0 ? "" : " is-off"}" data-opt-color="strokeColor" value="${v.strokeColor}" title="描边颜色${v.strokeWidth > 0 ? "" : ";描边宽度是 0,选色会自动给 6px"}">
|
||||
<button class="iwb-opt-btn${v.bgFill ? " active" : ""}" data-opt-text="bgFill" data-value="${v.bgFill ? "0" : "1"}" title="给文字加一块底色,压在花背景上也能看清">底色</button>
|
||||
<input type="color" class="iwb-opt-color${v.bgFill ? "" : " is-off"}" data-opt-color="bgColor" value="${v.bgColor}" style="--sw-a:${v.bgAlpha}" title="底色 ${Math.round(v.bgAlpha * 100)}% 不透明(色块按真实半透明显示);选色会自动开启底色">`;
|
||||
}
|
||||
var SELCMD_SVGS = {
|
||||
all: '<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="3 2"><rect x="3.5" y="3.5" width="17" height="17" rx="1"/></svg>',
|
||||
@@ -4965,12 +4994,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
if (t === "rect" || t === "circle" || t === "pen" || t === "arrow") {
|
||||
const owner = t === "pen" ? "pen" : "rect";
|
||||
const lw = Math.max(1, Math.round(sh.lw || S.shapeLineWidth));
|
||||
return `<span class="iwb-opt-current">已选中:${SHAPE_NAMES[t] || t}</span>` + rangeOpt("shapeLineWidth", "线宽", 1, 60, lw, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + (t === "rect" ? rangeOpt("shapeRadius", "圆角", 0, 200, Math.round(sh.radius || 0), "px") : "") + (t === "arrow" ? "" : fillStyleHTML(owner)) + (t === "pen" && !sh.closed ? '<span class="iwb-opt-hint">这条钢笔路径未闭合,实心不生效;点回起点闭合后即可填充</span>' : "") + selCmdHTML();
|
||||
return `<span class="iwb-opt-current">已选中:${SHAPE_NAMES[t] || t}</span>` + rangeOpt("shapeLineWidth", "线宽", 1, 60, lw, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + (t === "rect" ? rangeOpt("shapeRadius", "圆角", 0, 200, Math.round(sh.radius || 0), "px") : "") + shapeColorHTML(sh, t === "arrow" ? null : owner) + (t === "arrow" ? "" : fillStyleHTML(owner, sh)) + (t === "pen" && !sh.closed ? '<span class="iwb-opt-hint">这条钢笔路径未闭合,实心不生效;点回起点闭合后即可填充</span>' : "");
|
||||
}
|
||||
}
|
||||
const text = getSelectedText();
|
||||
if (text) {
|
||||
return `<span class="iwb-opt-current">已选中:文字</span>` + rangeOpt("textSize", "字号", 8, 400, Math.round(text.fontSize || S.textSize), "px") + textStyleHTML(text) + selCmdHTML() + '<span class="iwb-opt-hint">双击改内容 · 拖动手柄缩放</span>';
|
||||
return `<span class="iwb-opt-current">已选中:文字</span>` + rangeOpt("textSize", "字号", 8, 400, Math.round(text.fontSize || S.textSize), "px") + textStyleHTML(text) + '<span class="iwb-opt-hint">双击改内容 · 拖动手柄缩放</span>';
|
||||
}
|
||||
return `<span class="iwb-opt-current">当前工具:选择 / 移动</span>` + selCmdHTML() + '<span class="iwb-opt-hint">点中矩形/圆形/钢笔/文字后,这里出现它的描边、实心与粗细</span>';
|
||||
}
|
||||
@@ -4986,13 +5015,13 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
<span class="iwb-opt-val" data-opt-val="brushOpacity">${Math.round(S.brushOpacity * 100)}%</span>` + presetDots("brushHardness", [0, 25, 50, 75, 100]);
|
||||
}
|
||||
if (tool === "rect" || tool === "circle") {
|
||||
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + (tool === "rect" ? rangeOpt("shapeRadius", "圆角", 0, 200, S.shapeRadius, "px") : "") + fillStyleHTML("rect");
|
||||
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + (tool === "rect" ? rangeOpt("shapeRadius", "圆角", 0, 200, S.shapeRadius, "px") : "") + shapeColorHTML(null, "rect") + fillStyleHTML("rect");
|
||||
}
|
||||
if (tool === "arrow") {
|
||||
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + '<span class="iwb-opt-hint">拖出箭头,松手完成</span>';
|
||||
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + shapeColorHTML(null, null) + '<span class="iwb-opt-hint">拖出箭头,松手完成</span>';
|
||||
}
|
||||
if (tool === "pen") {
|
||||
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + fillStyleHTML("pen") + '<span class="iwb-opt-hint">逐点点击,点回起点闭合;闭合后可切换描边/实心</span>';
|
||||
return rangeOpt("shapeLineWidth", "线宽", 1, 60, S.shapeLineWidth, "") + presetDots("shapeLineWidth", [1, 2, 3, 6, 10, 16, 24]) + shapeColorHTML(null, "pen") + fillStyleHTML("pen") + '<span class="iwb-opt-hint">逐点点击,点回起点闭合;闭合后可切换描边/实心</span>';
|
||||
}
|
||||
if (tool === "text") {
|
||||
return rangeOpt("textSize", "字号", 8, 400, S.textSize, "px") + textStyleHTML(null) + '<span class="iwb-opt-hint">点画布输入文字,Enter 确认,Shift+Enter 换行</span>';
|
||||
@@ -5001,12 +5030,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
return `<span class="iwb-opt-label">形状</span>
|
||||
<button class="iwb-opt-btn${S.selectionKind === "rect" ? " active" : ""}" data-opt="shape" data-value="rect">矩形</button>
|
||||
<button class="iwb-opt-btn${S.selectionKind === "ellipse" ? " active" : ""}" data-opt="shape" data-value="ellipse">椭圆</button>
|
||||
<label class="iwb-opt-label">羽化 <input type="number" class="iwb-opt-num" data-opt="feather" min="0" max="20" step="1" value="${S.selectionFeather}"> px</label>
|
||||
<span class="iwb-opt-hint">${OPT_HINTS.marquee}</span>`;
|
||||
<label class="iwb-opt-label">羽化 <input type="number" class="iwb-opt-num" data-opt="feather" min="0" max="20" step="1" value="${S.selectionFeather}"> px</label>` + selCmdHTML() + `<span class="iwb-opt-hint">${OPT_HINTS.marquee}</span>`;
|
||||
}
|
||||
if (tool === "lasso") {
|
||||
return `<span class="iwb-opt-label">羽化 <input type="number" class="iwb-opt-num" data-opt="feather" min="0" max="20" step="1" value="${S.selectionFeather}"> px</span>
|
||||
<span class="iwb-opt-hint">${OPT_HINTS.lasso}</span>`;
|
||||
return `<span class="iwb-opt-label">羽化 <input type="number" class="iwb-opt-num" data-opt="feather" min="0" max="20" step="1" value="${S.selectionFeather}"> px</span>` + selCmdHTML() + `<span class="iwb-opt-hint">${OPT_HINTS.lasso}</span>`;
|
||||
}
|
||||
return `<span class="iwb-opt-current">当前工具:${TOOL_NAMES[tool] || tool}</span>
|
||||
<span class="iwb-opt-hint">${OPT_HINTS[tool] || "选区工具按 M / L;Ctrl+J 复制选区,Delete 清除当前层"}</span>`;
|
||||
@@ -5073,9 +5100,25 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
btn.classList.toggle("active", String(sv[k]) === btn.dataset.value);
|
||||
});
|
||||
body.querySelectorAll("[data-opt-color]").forEach((inp) => {
|
||||
if (document.activeElement === inp) return;
|
||||
const v = sv[inp.dataset.optColor];
|
||||
if (v && String(inp.value).toLowerCase() !== String(v).toLowerCase()) inp.value = v;
|
||||
const k = inp.dataset.optColor;
|
||||
if (document.activeElement !== inp) {
|
||||
const v = sv[k];
|
||||
if (v && String(inp.value).toLowerCase() !== String(v).toLowerCase()) inp.value = v;
|
||||
}
|
||||
if (k === "strokeColor") inp.classList.toggle("is-off", !(sv.strokeWidth > 0));
|
||||
if (k === "bgColor") inp.classList.toggle("is-off", !sv.bgFill);
|
||||
});
|
||||
body.querySelectorAll("[data-shape-color]").forEach((inp) => {
|
||||
const kind = inp.dataset.shapeColor;
|
||||
const owner = inp.dataset.fillOwner === "pen" ? "pen" : "rect";
|
||||
const stroke = selShape ? selShape.color || S.color : S.color;
|
||||
const fill = selShape ? selShape.fillColor || selShape.color || S.color : S.shapeFillColor || S.color;
|
||||
const v = kind === "fill" ? fill : stroke;
|
||||
if (document.activeElement !== inp && v && String(inp.value).toLowerCase() !== String(v).toLowerCase()) inp.value = v;
|
||||
if (kind === "fill") {
|
||||
const on = selShape ? !!selShape.fill : owner === "pen" ? S.penFill : S.rectFill;
|
||||
inp.classList.toggle("is-off", !on);
|
||||
}
|
||||
});
|
||||
}
|
||||
function updateStatusbar() {
|
||||
@@ -5132,12 +5175,15 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
if (key === "bgFill") value = raw === true || raw === 1 || raw === "1" || raw === "true";
|
||||
else if (key === "lineHeight") value = clamp(Number(raw) || 125, 80, 300) / 100;
|
||||
else if (key === "strokeWidth") value = clamp(Number(raw) || 0, 0, 40);
|
||||
else if (key === "strokeColor" || key === "bgColor") value = String(raw || "#000000").toLowerCase();
|
||||
else if (key === "strokeColor" || key === "bgColor") value = String(raw || TEXT_DEFAULTS.bgColor).toLowerCase();
|
||||
else value = String(raw);
|
||||
S[stateKey] = value;
|
||||
if (key === "strokeColor" && !(Number(S.textStrokeWidth) > 0)) S.textStrokeWidth = 6;
|
||||
if (key === "bgColor" && !S.textBgFill) S.textBgFill = true;
|
||||
const t = getSelectedText();
|
||||
if (!t || t.locked) {
|
||||
textStyleSnapDone = false;
|
||||
syncOptionBar();
|
||||
return;
|
||||
}
|
||||
if (committed || !textStyleSnapDone) {
|
||||
@@ -5145,12 +5191,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
textStyleSnapDone = true;
|
||||
}
|
||||
t[key] = value;
|
||||
if (key === "bgColor" && !t.bgFill) {
|
||||
t.bgFill = true;
|
||||
S.textBgFill = true;
|
||||
}
|
||||
if (key === "strokeColor" && !(Number(t.strokeWidth) > 0)) t.strokeWidth = S.textStrokeWidth;
|
||||
if (key === "bgColor" && !t.bgFill) t.bgFill = true;
|
||||
renderObjects();
|
||||
if (key === "bgColor") syncOptionBar();
|
||||
if (key === "bgColor" || key === "strokeColor") syncOptionBar();
|
||||
if (committed) textStyleSnapDone = false;
|
||||
}
|
||||
var radiusSnapDone = false;
|
||||
@@ -5168,6 +5212,29 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
renderObjects();
|
||||
if (committed) radiusSnapDone = false;
|
||||
}
|
||||
function applyShapeColor(kind, raw) {
|
||||
const hex = String(raw || "").toLowerCase();
|
||||
if (!/^#[0-9a-f]{6}$/.test(hex)) return;
|
||||
if (kind === "stroke") {
|
||||
applyColorChange(hex);
|
||||
syncOptionBar();
|
||||
return;
|
||||
}
|
||||
S.shapeFillColor = hex;
|
||||
rememberColor(hex);
|
||||
const sh = getSelectedShape();
|
||||
const owner = sh ? sh.type === "pen" ? "pen" : "rect" : S.tool === "pen" ? "pen" : "rect";
|
||||
if (owner === "pen") S.penFill = true;
|
||||
else S.rectFill = true;
|
||||
updateFillUI();
|
||||
if (sh && !sh.locked) {
|
||||
saveSnapshot("填充颜色");
|
||||
sh.fillColor = hex;
|
||||
sh.fill = owner === "pen" ? !!sh.closed : true;
|
||||
renderObjects();
|
||||
}
|
||||
syncOptionBar();
|
||||
}
|
||||
function setShapeFill(fill, owner) {
|
||||
const isPen = owner === "pen";
|
||||
if (isPen) S.penFill = !!fill;
|
||||
@@ -5293,6 +5360,12 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
syncOptionBar();
|
||||
return;
|
||||
}
|
||||
const shapeColorEl = e.target.closest ? e.target.closest("[data-shape-color]") : null;
|
||||
if (shapeColorEl) {
|
||||
e.stopPropagation();
|
||||
applyShapeColor(shapeColorEl.dataset.shapeColor, shapeColorEl.value);
|
||||
return;
|
||||
}
|
||||
setOptionFromControl(e.target, true);
|
||||
});
|
||||
body.addEventListener("click", (e) => {
|
||||
@@ -5746,7 +5819,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
return;
|
||||
}
|
||||
saveSnapshot();
|
||||
const shape = { id: "s" + Date.now() + Math.floor(Math.random() * 1e3), type: "pen", pts: S.penPath.pts.slice(), closed: !!S.penPath.closed, color: S.color, lw: Math.max(1, S.shapeLineWidth), fill: !!S.penFill && !!S.penPath.closed, opacity: 1, visible: true, locked: false, z: ++S.zCounter };
|
||||
const shape = { id: "s" + Date.now() + Math.floor(Math.random() * 1e3), type: "pen", pts: S.penPath.pts.slice(), closed: !!S.penPath.closed, color: S.color, fillColor: S.shapeFillColor, lw: Math.max(1, S.shapeLineWidth), fill: !!S.penFill && !!S.penPath.closed, opacity: 1, visible: true, locked: false, z: ++S.zCounter };
|
||||
S.shapeLayers.push(shape);
|
||||
S.penPath = null;
|
||||
renderObjects();
|
||||
@@ -7715,7 +7788,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
opacity: l.opacity == null ? 1 : l.opacity,
|
||||
cssOpacity: l.canvas ? parseFloat(l.canvas.style.opacity || "1") : null
|
||||
})),
|
||||
shapes: S.shapeLayers.map((s) => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z, color: s.color, radius: s.radius || 0, x1: Math.round(s.x1 || 0), y1: Math.round(s.y1 || 0), x2: Math.round(s.x2 || 0), y2: Math.round(s.y2 || 0) })),
|
||||
shapes: S.shapeLayers.map((s) => ({ id: s.id, type: s.type, lw: s.lw, fill: !!s.fill, closed: !!s.closed, z: s.z, color: s.color, fillColor: s.fillColor || null, radius: s.radius || 0, x1: Math.round(s.x1 || 0), y1: Math.round(s.y1 || 0), x2: Math.round(s.x2 || 0), y2: Math.round(s.y2 || 0) })),
|
||||
texts: S.textLayers.map((t) => ({
|
||||
id: t.id,
|
||||
text: t.text,
|
||||
@@ -7746,8 +7819,11 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
strokeWidth: S.textStrokeWidth,
|
||||
strokeColor: S.textStrokeColor,
|
||||
bgFill: S.textBgFill,
|
||||
bgColor: S.textBgColor
|
||||
bgColor: S.textBgColor,
|
||||
bgAlpha: S.textBgAlpha
|
||||
},
|
||||
// 矢量图形颜色:fillColor=null 表示跟随描边色(回归要能断言这条语义)
|
||||
shapeColors: { stroke: S.color, fill: S.shapeFillColor || null },
|
||||
selectedShapeId: S.selectedShapeId,
|
||||
// 光标所在的图片坐标(状态栏同源):换算问题的第一现场证据
|
||||
lastPos: S.lastPos ? { x: Math.round(S.lastPos.x), y: Math.round(S.lastPos.y) } : null,
|
||||
@@ -7847,7 +7923,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
};
|
||||
|
||||
// image-annotate/plugin/editor.css
|
||||
var editor_default = '/* IWB 鲜艺抠图节点 - 注入样式 */\n\n/* 抠图按钮 */\n.iwb-cutout-btn {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n\n.iwb-cutout-btn:hover {\n opacity: 1;\n transform: scale(1.15);\n}\n\n.iwb-cutout-btn svg {\n width: 14px;\n height: 14px;\n display: block;\n}\n\n/* 正在处理中的按钮状态 */\n.iwb-cutout-btn.processing {\n animation: iwb-cutout-pulse 1s infinite;\n pointer-events: none;\n}\n\n@keyframes iwb-cutout-pulse {\n 0%, 100% { opacity: 0.4; }\n 50% { opacity: 1; }\n}\n\n/* 全屏遮罩 */\n.iwb-cutout-overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.25);\n display: none;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 12px;\n z-index: 999999;\n pointer-events: all;\n backdrop-filter: blur(2px);\n}\n\n/* 自定义按钮提示(挂在 body,最高层级,不会被图片遮挡) */\n#iwb-cutout-tip {\n position: fixed;\n z-index: 2147483647;\n background: rgba(30, 30, 46, 0.95);\n color: #fff;\n padding: 5px 10px;\n border-radius: 6px;\n font-size: 12px;\n line-height: 1.5;\n white-space: nowrap;\n pointer-events: none;\n display: none;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);\n border: 1px solid rgba(255, 255, 255, 0.14);\n font-family: system-ui, -apple-system, "Segoe UI", sans-serif;\n max-width: 320px;\n white-space: normal;\n word-break: break-all;\n}\n\n/* 加载动画 */\n.iwb-cutout-spinner {\n width: 48px;\n height: 48px;\n border: 4px solid rgba(255, 255, 255, 0.3);\n border-top-color: #e8a735;\n border-radius: 50%;\n animation: iwb-cutout-spin 0.8s linear infinite;\n}\n\n@keyframes iwb-cutout-spin {\n to { transform: rotate(360deg); }\n}\n\n/* 遮罩文字 */\n.iwb-cutout-text {\n color: #fff;\n font-size: 14px;\n font-weight: 500;\n text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);\n background: rgba(0, 0, 0, 0.6);\n padding: 8px 16px;\n border-radius: 6px;\n}\n\n/* Toast 提示 */\n.iwb-cutout-toast {\n position: fixed;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n padding: 10px 20px;\n border-radius: 8px;\n font-size: 13px;\n font-weight: 500;\n z-index: 999999;\n transition: opacity 0.3s;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n display: none;\n max-width: 400px;\n}\n\n.iwb-cutout-toast-success {\n background: #1a7f37;\n color: #fff;\n}\n\n.iwb-cutout-toast-error {\n background: #cf222e;\n color: #fff;\n}\n\n.iwb-cutout-toast-info {\n background: #1f6feb;\n color: #fff;\n}\n\n/* 白底按钮 */\n.iwb-whitebg-btn {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n.iwb-whitebg-btn:hover { opacity: 1; transform: scale(1.15); }\n.iwb-whitebg-btn svg { width: 14px; height: 14px; display: block; }\n.iwb-whitebg-btn.processing { animation: iwb-cutout-pulse 1s infinite; pointer-events: none; }\n\n/* 编辑按钮 */\n.iwb-editor-btn-icon {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n.iwb-editor-btn-icon:hover { opacity: 1; transform: scale(1.15); }\n.iwb-editor-btn-icon svg { width: 14px; height: 14px; display: block; }\n\n/* ==================== 图片编辑器 ==================== */\n\n.iwb-editor-overlay {\n position: fixed;\n top: 0; left: 0;\n width: 100%; height: 100%;\n background: rgba(0, 0, 0, 0.6);\n display: none;\n align-items: center;\n justify-content: center;\n z-index: 999998;\n backdrop-filter: blur(3px);\n}\n\n.iwb-editor-modal {\n background: #1e1e2e;\n border-radius: 0;\n box-shadow: none;\n display: flex;\n flex-direction: column;\n width: 100vw;\n height: 100vh;\n max-width: none;\n max-height: none;\n overflow: visible;\n}\n\n/* 新增:主区域(画布 + 图层面板)flex 布局 */\n.iwb-editor-main {\n display: flex;\n flex: 1 1 auto;\n min-height: 0;\n overflow: visible;\n}\n\n.iwb-editor-header {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 10px 16px;\n background: #181825;\n border-bottom: 1px solid #313244;\n flex-wrap: nowrap;\n}\n.iwb-editor-header > .iwb-editor-tools {\n position: absolute;\n left: 12px;\n top: 68px;\n width: 44px;\n flex-direction: column;\n padding: 6px;\n background: #181825;\n border: 1px solid #313244;\n border-radius: 8px;\n z-index: 20;\n}\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action { position: static; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="undo"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="redo"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="reset"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="restore"] {\n position: absolute;\n top: -54px;\n left: auto;\n}\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="undo"] { right: 154px; }\n.iwb-editor-header > .iwb-edLine truncated
|
||||
var editor_default = '/* IWB 鲜艺抠图节点 - 注入样式 */\n\n/* 抠图按钮 */\n.iwb-cutout-btn {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n\n.iwb-cutout-btn:hover {\n opacity: 1;\n transform: scale(1.15);\n}\n\n.iwb-cutout-btn svg {\n width: 14px;\n height: 14px;\n display: block;\n}\n\n/* 正在处理中的按钮状态 */\n.iwb-cutout-btn.processing {\n animation: iwb-cutout-pulse 1s infinite;\n pointer-events: none;\n}\n\n@keyframes iwb-cutout-pulse {\n 0%, 100% { opacity: 0.4; }\n 50% { opacity: 1; }\n}\n\n/* 全屏遮罩 */\n.iwb-cutout-overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.25);\n display: none;\n align-items: center;\n justify-content: center;\n flex-direction: column;\n gap: 12px;\n z-index: 999999;\n pointer-events: all;\n backdrop-filter: blur(2px);\n}\n\n/* 自定义按钮提示(挂在 body,最高层级,不会被图片遮挡) */\n#iwb-cutout-tip {\n position: fixed;\n z-index: 2147483647;\n background: rgba(30, 30, 46, 0.95);\n color: #fff;\n padding: 5px 10px;\n border-radius: 6px;\n font-size: 12px;\n line-height: 1.5;\n white-space: nowrap;\n pointer-events: none;\n display: none;\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);\n border: 1px solid rgba(255, 255, 255, 0.14);\n font-family: system-ui, -apple-system, "Segoe UI", sans-serif;\n max-width: 320px;\n white-space: normal;\n word-break: break-all;\n}\n\n/* 加载动画 */\n.iwb-cutout-spinner {\n width: 48px;\n height: 48px;\n border: 4px solid rgba(255, 255, 255, 0.3);\n border-top-color: #e8a735;\n border-radius: 50%;\n animation: iwb-cutout-spin 0.8s linear infinite;\n}\n\n@keyframes iwb-cutout-spin {\n to { transform: rotate(360deg); }\n}\n\n/* 遮罩文字 */\n.iwb-cutout-text {\n color: #fff;\n font-size: 14px;\n font-weight: 500;\n text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);\n background: rgba(0, 0, 0, 0.6);\n padding: 8px 16px;\n border-radius: 6px;\n}\n\n/* Toast 提示 */\n.iwb-cutout-toast {\n position: fixed;\n bottom: 24px;\n left: 50%;\n transform: translateX(-50%);\n padding: 10px 20px;\n border-radius: 8px;\n font-size: 13px;\n font-weight: 500;\n z-index: 999999;\n transition: opacity 0.3s;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\n display: none;\n max-width: 400px;\n}\n\n.iwb-cutout-toast-success {\n background: #1a7f37;\n color: #fff;\n}\n\n.iwb-cutout-toast-error {\n background: #cf222e;\n color: #fff;\n}\n\n.iwb-cutout-toast-info {\n background: #1f6feb;\n color: #fff;\n}\n\n/* 白底按钮 */\n.iwb-whitebg-btn {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n.iwb-whitebg-btn:hover { opacity: 1; transform: scale(1.15); }\n.iwb-whitebg-btn svg { width: 14px; height: 14px; display: block; }\n.iwb-whitebg-btn.processing { animation: iwb-cutout-pulse 1s infinite; pointer-events: none; }\n\n/* 编辑按钮 */\n.iwb-editor-btn-icon {\n cursor: pointer;\n opacity: 0.7;\n transition: opacity 0.15s, transform 0.15s;\n}\n.iwb-editor-btn-icon:hover { opacity: 1; transform: scale(1.15); }\n.iwb-editor-btn-icon svg { width: 14px; height: 14px; display: block; }\n\n/* ==================== 图片编辑器 ==================== */\n\n.iwb-editor-overlay {\n position: fixed;\n top: 0; left: 0;\n width: 100%; height: 100%;\n background: rgba(0, 0, 0, 0.6);\n display: none;\n align-items: center;\n justify-content: center;\n z-index: 999998;\n backdrop-filter: blur(3px);\n}\n\n.iwb-editor-modal {\n background: #1e1e2e;\n border-radius: 0;\n box-shadow: none;\n display: flex;\n flex-direction: column;\n width: 100vw;\n height: 100vh;\n max-width: none;\n max-height: none;\n overflow: visible;\n}\n\n/* 新增:主区域(画布 + 图层面板)flex 布局 */\n.iwb-editor-main {\n display: flex;\n flex: 1 1 auto;\n min-height: 0;\n overflow: visible;\n}\n\n.iwb-editor-header {\n display: flex;\n align-items: center;\n gap: 12px;\n padding: 10px 16px;\n background: #181825;\n border-bottom: 1px solid #313244;\n flex-wrap: nowrap;\n}\n.iwb-editor-header > .iwb-editor-tools {\n position: absolute;\n left: 12px;\n top: 68px;\n width: 44px;\n flex-direction: column;\n padding: 6px;\n background: #181825;\n border: 1px solid #313244;\n border-radius: 8px;\n z-index: 20;\n}\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action { position: static; }\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="undo"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="redo"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="reset"],\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="restore"] {\n position: absolute;\n top: -54px;\n left: auto;\n}\n.iwb-editor-header > .iwb-editor-tools .iwb-editor-action[data-action="undo"] { right: 154px; }\n.iwb-editor-header > .iwb-edLine truncated
|
||||
|
||||
// image-annotate/plugin/glue.js
|
||||
function createGlue(ctx, css) {
|
||||
|
||||
Reference in new issue
Block a user