diff --git a/plugins/index.json b/plugins/index.json index a6a63d9..c82289d 100644 --- a/plugins/index.json +++ b/plugins/index.json @@ -13,9 +13,9 @@ }, { "id": "image-annotate", - "file": "plugin-image-annotate.10f2df918936.js", - "version": "1.20.4", - "integrity": "sha256-EPLfkYk2D1wgqeRslEy3lJs0ER3CmEyekS2FkP7BcaE=" + "file": "plugin-image-annotate.2a8b070e9150.js", + "version": "1.20.5", + "integrity": "sha256-KosHDpFQs910KPsW1G91hhLX58Xh9oWcvyb8tbmYqnM=" }, { "id": "image-vectorize", diff --git a/plugins/runtime/plugin-image-annotate.10f2df918936.js b/plugins/runtime/plugin-image-annotate.2a8b070e9150.js similarity index 99% rename from plugins/runtime/plugin-image-annotate.10f2df918936.js rename to plugins/runtime/plugin-image-annotate.2a8b070e9150.js index c7ed0a9..8bc1a13 100644 --- a/plugins/runtime/plugin-image-annotate.10f2df918936.js +++ b/plugins/runtime/plugin-image-annotate.2a8b070e9150.js @@ -9,7 +9,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { id: 'image-annotate', name: '标注 / 修图', - version: '1.20.4', + version: '1.20.5', apiVersion: 1, capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'], settings: { @@ -3918,8 +3918,12 @@ var __IWB_ANNOTATE_MANIFEST__ = { filterCanvas(canvas, "invert(" + k + ")"); return; } - const okInv = mapPixels(canvas, (r, g, b) => [clamp255(255 - (255 - r) * k), clamp255(255 - (255 - g) * k), clamp255(255 - (255 - b) * k)]); - if (!okInv) blendFallback(canvas, "invert"); + const okInv = mapPixels(canvas, (r, g, b) => [ + clamp255(r + (255 - 2 * r) * k), + clamp255(g + (255 - 2 * g) * k), + clamp255(b + (255 - 2 * b) * k) + ]); + if (!okInv) blendFallback(canvas, "invert", k); } }, gray: { @@ -3942,7 +3946,7 @@ var __IWB_ANNOTATE_MANIFEST__ = { const y = luma(r, g, b); return [clamp255(r + (y - r) * k), clamp255(g + (y - g) * k), clamp255(b + (y - b) * k)]; }); - if (!okGray) blendFallback(canvas, "gray"); + if (!okGray) blendFallback(canvas, "gray", k); } }, boost: { @@ -4079,8 +4083,13 @@ var __IWB_ANNOTATE_MANIFEST__ = { ctx.putImageData(img, 0, 0); return true; } - function blendFallback(canvas, mode) { + function blendFallback(canvas, mode, strength) { + const k = typeof strength === "number" ? Math.max(0, Math.min(1, strength)) : 1; const ctx = canvas.getContext("2d"); + const copy = document.createElement("canvas"); + copy.width = canvas.width; + copy.height = canvas.height; + copy.getContext("2d").drawImage(canvas, 0, 0); ctx.save(); ctx.setTransform(1, 0, 0, 1, 0, 0); ctx.globalAlpha = 1; @@ -4092,6 +4101,11 @@ var __IWB_ANNOTATE_MANIFEST__ = { ctx.fillStyle = "#808080"; } ctx.fillRect(0, 0, canvas.width, canvas.height); + if (k < 1) { + ctx.globalCompositeOperation = "source-over"; + ctx.globalAlpha = 1 - k; + ctx.drawImage(copy, 0, 0); + } ctx.restore(); } function luma(r, g, b) {