feat(image-annotate): v1.8.0 快速效果加参数(马赛克块大小 / 柔化半径 / 其余强度)

v1.4 的六个效果都是一键定死强度:马赛克在 800px 图上固定 13px 块挡不住手机号,
柔化固定 1.6px 小图上几乎看不出。现在每个效果都带参数,点完还能继续拖。

参数模型:
- 百分比类(反白/灰度/增强/高对比):强度 0~100%,走 invert()/grayscale() 原生比例,
  其余按 k 插值(高对比 = grayscale(k) contrast(1+1.4k))
- 物理量类:柔化半径 0~16px、马赛克块大小 2~96px,默认值按短边缩放

关键设计:效果不能叠加在自己的结果上。
点效果时把目标层像素备份进 S.fx.source,拖滑杆一律「先还原 source 再按新参数渲染」。
否则「马赛克 12 → 48 → 12」会做三次重采样,块越来越碎且不可逆。

交互约定:
- 一次效果 = 一条撤销(点效果时快照,拖滑杆不再拍)
- 同效果再点 = 回默认值,不再糊一层
- 切到别的层滑杆置灰(源属于旧层),切回自动恢复
- 当前生效效果描橙边;拖滑杆不重建图层面板(否则每帧 innerHTML 会闪)

顺带修了两处既有缺陷:
- .iwb-editor-fx-target 标签从来没被更新过,一直显示「原图」——现在跟随目标层
- 柔化默认过弱(1.6px / 800px 图)——系数改 400、下限 1.2

验证:harness 139 项全通(新增 6 项,含「12→48→12 像素指纹一致」的叠加检测)、
validate 9/9、产物 341608 B。
This commit is contained in:
qiqi committed 2026-11-08 17:06:56 +08:00
1 parent eb90939f11
commit 3819048e54
11 files changed
+710 -50

No files matched your search

+262 -22
View File
@@ -9,7 +9,7 @@
var __IWB_ANNOTATE_MANIFEST__ = {
id: 'image-annotate',
name: '标注 / 修图',
version: '1.7.0',
version: '1.8.0',
apiVersion: 1,
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
settings: {
@@ -51,6 +51,10 @@ var __IWB_ANNOTATE_MANIFEST__ = {
// 按住 Alt 的临时吸管(画笔/橡皮下),松开 Alt 回到原工具
pickerComposite: null,
// 吸管取样用的合成画布缓存(切工具/画布变化时失效)
// v1.8 快速效果的「可重调」状态:source 是点效果那一刻的像素备份,
// 拖强度滑杆时一律从 source 重算,绝不在上一次结果上叠加(否则来回拖会越拖越糊)。
// layerId 用于判断源是否还对得上当前目标层:切层后滑杆自动置灰,切回即恢复。
fx: { key: null, value: 0, layerId: null, source: null },
rectFill: false,
// 矩形/圆形是否实心填充
penFill: true,
@@ -1846,6 +1850,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
if (!changed) return;
renderLayerPanel();
renderObjects();
if (S.renderFxPanel) S.renderFxPanel();
}
function addBitmapLayer(img) {
placeImageDirectly(img);
@@ -3190,7 +3195,15 @@ var __IWB_ANNOTATE_MANIFEST__ = {
<span class="iwb-editor-fx-ico ico-mosaic"></span><span>马赛克</span>
</button>
</div>
<p class="iwb-editor-fx-tip">作用于当前层 · Ctrl+Z 可撤销</p>
<!-- v1.8:效果参数。点效果后启用,范围/单位随效果切换(马赛克=块大小,柔化=半径,其余=强度) -->
<div class="iwb-editor-fx-adj iwb-editor-fx-adj-off">
<div class="iwb-editor-fx-adj-head">
<span class="iwb-editor-fx-adj-name">强度</span>
<span class="iwb-editor-fx-adj-val">—</span>
</div>
<input type="range" class="iwb-editor-fx-range" min="0" max="100" step="1" value="0" disabled aria-label="效果强度">
</div>
<p class="iwb-editor-fx-tip">先点效果,再拖强度微调 · Ctrl+Z 撤销</p>
</section>
<div class="iwb-editor-zoom">
@@ -3303,24 +3316,100 @@ var __IWB_ANNOTATE_MANIFEST__ = {
}
// image-annotate/plugin/editor/effects.js
var QUICK_EFFECTS = {
invert: { label: "反白", hint: "反相:明暗翻转,白底变黑底", css: () => "invert(1)" },
gray: { label: "灰度", hint: "去色,保留明暗层次", css: () => "grayscale(1)" },
boost: { label: "增强", hint: "提亮并略加对比", css: () => "brightness(1.12) contrast(1.1) saturate(1.06)" },
contrast: { label: "高对比", hint: "压成黑白硬调", css: () => "grayscale(1) contrast(2.4)" },
soft: { label: "柔化", hint: "轻微模糊,弱化背景", css: (c) => "blur(" + softRadius(c) + "px)" },
mosaic: { label: "马赛克", hint: "像素化,用于打码", pixel: true }
};
var SOFT_MIN = 0.8;
var SOFT_MIN = 1.2;
var SOFT_MAX = 8;
function softRadius(canvas) {
const side = Math.min(canvas.width || 0, canvas.height || 0);
return Math.max(SOFT_MIN, Math.min(SOFT_MAX, Math.round(side / 500 * 10) / 10));
return Math.max(SOFT_MIN, Math.min(SOFT_MAX, Math.round(side / 400 * 10) / 10));
}
function mosaicBlock(canvas) {
const side = Math.min(canvas.width || 0, canvas.height || 0);
return Math.max(6, Math.round(side / 60));
}
var QUICK_EFFECTS = {
invert: {
label: "反白",
hint: "反相:明暗翻转,白底变黑底",
param: "强度",
unit: "%",
min: 0,
max: 100,
step: 1,
def: () => 100,
render: (canvas, v) => {
if (v > 0) filterCanvas(canvas, "invert(" + v / 100 + ")");
}
},
gray: {
label: "灰度",
hint: "去色,保留明暗层次",
param: "强度",
unit: "%",
min: 0,
max: 100,
step: 1,
def: () => 100,
render: (canvas, v) => {
if (v > 0) filterCanvas(canvas, "grayscale(" + v / 100 + ")");
}
},
boost: {
label: "增强",
hint: "提亮并略加对比,适合发灰的截图",
param: "强度",
unit: "%",
min: 0,
max: 100,
step: 1,
def: () => 100,
render: (canvas, v) => {
if (v <= 0) return;
const k = v / 100;
filterCanvas(canvas, "brightness(" + (1 + 0.12 * k).toFixed(3) + ") contrast(" + (1 + 0.1 * k).toFixed(3) + ") saturate(" + (1 + 0.06 * k).toFixed(3) + ")");
}
},
contrast: {
label: "高对比",
hint: "压成黑白硬调,突出主体",
param: "强度",
unit: "%",
min: 0,
max: 100,
step: 1,
def: () => 100,
render: (canvas, v) => {
if (v <= 0) return;
const k = v / 100;
filterCanvas(canvas, "grayscale(" + k.toFixed(3) + ") contrast(" + (1 + 1.4 * k).toFixed(3) + ")");
}
},
soft: {
label: "柔化",
hint: "模糊,弱化背景",
param: "半径",
unit: "px",
min: 0,
max: 16,
step: 0.5,
def: (canvas) => softRadius(canvas),
render: (canvas, v) => {
if (v > 0) filterCanvas(canvas, "blur(" + v + "px)");
}
},
mosaic: {
label: "马赛克",
hint: "像素化,用于打码手机号/地址等隐私信息",
param: "块大小",
unit: "px",
min: 2,
max: 96,
step: 1,
def: (canvas) => mosaicBlock(canvas),
render: (canvas, v) => {
if (v > 1) pixelateCanvas(canvas, v);
}
}
};
function effectTarget() {
const active = getActiveLayer();
if (active) return active;
@@ -3347,8 +3436,9 @@ var __IWB_ANNOTATE_MANIFEST__ = {
function pixelateCanvas(canvas, block) {
const w = canvas.width, h = canvas.height;
if (!w || !h) return;
const sw = Math.max(1, Math.round(w / block));
const sh = Math.max(1, Math.round(h / block));
const b = Math.max(2, block);
const sw = Math.max(1, Math.round(w / b));
const sh = Math.max(1, Math.round(h / b));
const tmp = document.createElement("canvas");
tmp.width = sw;
tmp.height = sh;
@@ -3365,6 +3455,14 @@ var __IWB_ANNOTATE_MANIFEST__ = {
ctx.drawImage(tmp, 0, 0, w, h);
ctx.restore();
}
function snapshotCanvas(canvas) {
const c = document.createElement("canvas");
c.width = canvas.width;
c.height = canvas.height;
const ctx = c.getContext("2d");
ctx.drawImage(canvas, 0, 0);
return c;
}
function rasterizeLayer(layer) {
const canvas = createLayerCanvas();
const ctx = canvas.getContext("2d", { willReadFrequently: true });
@@ -3399,6 +3497,70 @@ var __IWB_ANNOTATE_MANIFEST__ = {
renderLayerPanel();
return clone;
}
function renderFromSource(target, key, value) {
const st = S.fx;
const fx = QUICK_EFFECTS[key];
if (!st.source || !fx) return;
const ctx = target.canvas.getContext("2d");
ctx.save();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.globalAlpha = 1;
ctx.globalCompositeOperation = "copy";
ctx.filter = "none";
ctx.imageSmoothingEnabled = true;
ctx.drawImage(st.source, 0, 0);
ctx.restore();
fx.render(target.canvas, value);
target._bounds = void 0;
S.pickerComposite = null;
}
function fmtValue(fx, v) {
if (fx.unit === "px") return Math.round(v * 10) / 10 + " px";
return Math.round(v) + "%";
}
function renderFxPanel() {
if (!runtime.el) return;
const adv = runtime.el.querySelector(".iwb-editor-fx-adj");
if (!adv) return;
const range = adv.querySelector(".iwb-editor-fx-range");
const nameEl = adv.querySelector(".iwb-editor-fx-adj-name");
const valEl = adv.querySelector(".iwb-editor-fx-adj-val");
const targetEl = runtime.el.querySelector(".iwb-editor-fx-target");
const layer = effectTarget();
const activeKey = S.fx.source ? S.fx.key : null;
runtime.el.querySelectorAll("[data-fx]").forEach((btn) => {
btn.classList.toggle("is-active", Boolean(activeKey) && btn.dataset.fx === activeKey);
});
if (targetEl) {
const name = layer ? layer.name : "无图层";
targetEl.textContent = name;
targetEl.title = layer ? "效果作用于「" + name + "」" : "没有可处理的位图图层";
}
const st = S.fx;
const fx = st.source ? QUICK_EFFECTS[st.key] : null;
if (!fx || !range) {
adv.classList.add("iwb-editor-fx-adj-off");
if (nameEl) nameEl.textContent = "强度";
if (valEl) valEl.textContent = "—";
if (range) {
range.disabled = true;
range.value = "0";
}
return;
}
const usable = Boolean(layer && st.layerId === layer.id);
adv.classList.toggle("iwb-editor-fx-adj-off", !usable);
if (nameEl) nameEl.textContent = fx.label + " · " + fx.param;
range.min = String(fx.min);
range.max = String(fx.max);
range.step = String(fx.step);
range.disabled = !usable;
if (usable) range.value = String(st.value);
if (valEl) {
valEl.textContent = fmtValue(fx, st.value);
valEl.title = usable ? "" : "效果作用在「" + (S.layers.find((l) => l.id === st.layerId) || {}).name + "」,切回该层可继续调整";
}
}
function applyQuickEffect(key) {
const fx = QUICK_EFFECTS[key];
if (!fx) return false;
@@ -3411,20 +3573,43 @@ var __IWB_ANNOTATE_MANIFEST__ = {
toast("「" + layer.name + "」已隐藏,先显示再应用效果");
return false;
}
saveSnapshot("效果:" + fx.label);
let target = layer;
if (!needsPixelSnapshot(layer)) target = rasterizeLayer(layer);
if (!target) {
toast("栅格化失败,效果未应用");
return false;
}
if (fx.pixel) pixelateCanvas(target.canvas, mosaicBlock(target.canvas));
else filterCanvas(target.canvas, fx.css(target.canvas));
target._bounds = void 0;
S.pickerComposite = null;
const st = S.fx;
if (st.source && st.layerId === target.id && st.key === key) {
st.value = fx.def(target.canvas);
renderFromSource(target, key, st.value);
if (S.renderAll) S.renderAll();
toast("「" + fx.label + "」已重置为 " + fmtValue(fx, st.value), "success");
return true;
}
saveSnapshot("效果:" + fx.label);
S.fx = { key, layerId: target.id, source: snapshotCanvas(target.canvas), value: fx.def(target.canvas) };
renderFromSource(target, key, S.fx.value);
if (S.renderAll) S.renderAll();
renderLayerPanel();
toast("已应用「" + fx.label + "」到 " + target.name + " · Ctrl+Z 撤销", "success");
toast("已应用「" + fx.label + "」" + fmtValue(fx, S.fx.value) + " 到 " + target.name + " · 可拖强度微调", "success");
return true;
}
function setEffectValue(value) {
const st = S.fx;
if (!st.source) return false;
const fx = QUICK_EFFECTS[st.key];
if (!fx) return false;
const target = S.layers.find((l) => l.id === st.layerId);
if (!target) return false;
const layer = effectTarget();
if (!layer || layer.id !== st.layerId) return false;
const v = Math.min(fx.max, Math.max(fx.min, Number(value) || 0));
st.value = v;
renderFromSource(target, st.key, v);
if (runtime.el) {
const valEl = runtime.el.querySelector(".iwb-editor-fx-adj-val");
if (valEl) valEl.textContent = fmtValue(fx, v);
}
return true;
}
@@ -4527,6 +4712,19 @@ var __IWB_ANNOTATE_MANIFEST__ = {
closeMenus();
});
});
const fxRangeOf = (e) => e.target && e.target.closest ? e.target.closest(".iwb-editor-fx-range") : null;
root.addEventListener("input", (e) => {
const range = fxRangeOf(e);
if (!range) return;
e.stopPropagation();
setEffectValue(parseFloat(range.value));
});
root.addEventListener("change", (e) => {
const range = fxRangeOf(e);
if (!range) return;
e.stopPropagation();
if (S.renderAll) S.renderAll();
});
const body = root.querySelector(".iwb-editor-optionbar-body");
if (body) {
body.addEventListener("mousedown", (e) => e.stopPropagation());
@@ -6628,6 +6826,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
S.callbacks = options;
S.renderAll = renderAll;
S.positionFloating = positionFloating;
S.renderFxPanel = renderFxPanel;
try {
const img = await loadImage(options.imageBase64);
S.imgW = img.naturalWidth || img.width;
@@ -6694,6 +6893,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
S.lastClick = null;
S.lastNameClick = null;
S.altPicker = false;
S.fx = { key: null, value: 0, layerId: null, source: null };
S.zCounter = Math.max(S.layers.length - 1, 0);
S.placingImage = null;
S.placingHandle = null;
@@ -6726,6 +6926,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
if (!S.open || !runtime.el) return;
renderObjects();
renderLayerPanel();
renderFxPanel();
renderOptionBar();
updateStatusbar();
renderExportUI();
@@ -6774,6 +6975,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
S.redoStack = [];
S.originalImage = null;
S.pickerComposite = null;
S.fx = { key: null, value: 0, layerId: null, source: null };
S.isDrawing = false;
S.panning = false;
S.penDragPt = -1;
@@ -6875,9 +7077,47 @@ var __IWB_ANNOTATE_MANIFEST__ = {
redo: S.redoStack.length,
exportOptions: S.exportOptions ? { ...S.exportOptions } : null,
lastExport: S.lastExport ? { ...S.lastExport } : null,
// 快速效果的可重调状态:hasSource=false 表示还没点过效果(滑杆应置灰)
fx: { key: S.fx.key, value: S.fx.value, layerId: S.fx.layerId, hasSource: Boolean(S.fx.source) },
interaction: S.interaction,
ants: !!S._antFrame,
view: S.viewX !== null ? [Math.round(S.viewX), Math.round(S.viewY)] : null,
// 图层整幅像素指纹(抽样校验和):断言「改强度后从基准重算」而不是叠加,
// 比逐点采样稳 —— 马赛克/模糊的差异散在整幅,单点可能刚好相同
layerHash: (id) => {
const l = S.layers.find((v) => v.id === id);
if (!l || !l.ctx || !l.canvas) return 0;
try {
const d = l.ctx.getImageData(0, 0, l.canvas.width, l.canvas.height).data;
let h = 2166136261;
for (let i = 0; i < d.length; i += 97) {
h ^= d[i];
h = Math.imul(h, 16777619);
}
return h >>> 0;
} catch (e) {
return 0;
}
},
// 非透明像素的平均色:断言效果是否落在预期值上(如反相 50% 必然趋近 128)
avgColor: (id) => {
const l = S.layers.find((v) => v.id === id);
if (!l || !l.ctx || !l.canvas) return null;
try {
const d = l.ctx.getImageData(0, 0, l.canvas.width, l.canvas.height).data;
let r = 0, g = 0, b = 0, n = 0;
for (let i = 0; i < d.length; i += 4) {
if (d[i + 3] < 200) continue;
r += d[i];
g += d[i + 1];
b += d[i + 2];
n++;
}
return n ? [Math.round(r / n), Math.round(g / n), Math.round(b / n), n] : null;
} catch (e) {
return null;
}
},
pixel: (id, x, y) => {
const l = S.layers.find((v) => v.id === id);
if (!l || !l.ctx) return null;
@@ -6911,7 +7151,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) {