feat(image-annotate): v1.6.0 色板入工具栏 + 快速效果 + 画完回 V + 图层合并(补齐 1.3.0–1.6.0)
上一次提交停在 1.2.12,本次把 1.3.0 → 1.6.0 四个版本的源码一并归档。 v1.3.0 色板进工具栏 + 矢量/文字工具只负责创建 - 工具栏最左色点 → 弹层(前调色器、后颜色设置 + 推荐颜色) - 弹层必须挂 .iwb-editor-modal 下:工具栏是 overflow-x:auto、画布 wrap 是 overflow:clip,塞进去会被裁 - applyColorChange 改 pointerdown 拍一次快照,修「拖调色器爆撤销栈」 - 每次按下前从 S.color 重同步 hsv,修「点推荐色后再拖 SV 跳回红」 - 外部点击改 document 捕获阶段监听(画布 mousedown preventDefault,冒泡收不到) - onShapeMouseDown / onTextMouseDown 不再命中已有对象;setTool 的 keepSel 只剩 select|picker v1.4.0 侧栏快速效果 - 6 个:反白(反相,非排版意义的黑底白字)/ 灰度 / 提亮 / 压暗 / 高对比 / 马赛克 - 目标是当前位图图层,标题右侧实时显示层名;不碰图层几何也不改 image - 导入图片层先克隆栅格化成「xxx · 效果」层、原层 visible=false(直接改像素会被 redraw 冲掉) - 撤销走快照,base 与画笔层走像素路径 v1.5.0 画完自动回 V,编辑统一走 V - 图形/文字落笔完成即退出当前工具并切 V - 钢笔改为只用 V 双击进节点编辑 - 双击判定改成自算 380ms 窗口:单击选中会重绘矢量画布,浏览器不再派发 dblclick v1.6.0 笔刷环 + 图层合并 - 画笔用 [ / ] 调粗细时立刻刷新笔刷环(原来只在 mousemove 里 drawToolRing,键改后不动) - 图层合并:⌘/Ctrl 点击多选后合并、⌘E 向下合并、⌘⇧E 合并可见(PS 语义) - 统一用 composeUnitsInto 合成并按结果重排 z,避免合并后像素为空 - 隐藏层不参与且保留;矢量(文字/形状/钢笔)直接栅格化 - 有 base 参与时写回 base(像素快照可逐像素撤销),否则新建位图层承载 harness 129 项全通。1.6.0 已发布到线上: plugin-image-annotate.198a20e4d722.js / sha256-GYog5NcinRDM67in67JxJUtBhUPB2lfttM/kw9UHwFo=
This commit is contained in:
1 parent
577a891e73
commit
5f11e40f43
14 files changed
+2034
-233
No files matched your search
@@ -1608,3 +1608,132 @@
|
||||
/* 标题与会话组之间、撤销组与命令带之间的竖分隔 */
|
||||
.iwb-editor-header > .iwb-editor-session { margin-right: 4px; }
|
||||
.iwb-editor-header > .iwb-editor-divider { width: 1px; height: 20px; background: #313244; flex: 0 0 auto; margin: 0 4px; }
|
||||
|
||||
/* ================================================================
|
||||
v1.3:色板搬进工具栏(用户裁定 2026-11-05)
|
||||
工具栏最左一个「当前色圆点」,点开在工具栏上方弹出色板:
|
||||
[SV + 色相] | [吸管 + hex] | [6×2 推荐色]
|
||||
弹层挂在 modal 下(不是工具栏里):工具栏 overflow-x:auto、
|
||||
canvas-wrap overflow:clip,放里面必被裁;位置由 events.js 按按钮矩形算。
|
||||
================================================================ */
|
||||
.iwb-editor-modal { position: relative; }
|
||||
|
||||
.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn {
|
||||
width: 32px; height: 32px; min-width: 32px; flex: 0 0 auto; padding: 0;
|
||||
border: 0; border-radius: 9px; background: #313244; cursor: pointer;
|
||||
display: inline-flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn:hover,
|
||||
.iwb-editor-canvas-wrap > .iwb-editor-tools .iwb-editor-color-btn.active { background: #45475a; }
|
||||
.iwb-editor-color-btn i {
|
||||
width: 18px; height: 18px; border-radius: 50%; display: block; background: #ff4444;
|
||||
box-shadow: 0 0 0 2px #181825, 0 0 0 3px #585b70;
|
||||
}
|
||||
|
||||
.iwb-editor-color-pop {
|
||||
position: absolute; z-index: 60; display: flex; align-items: center; gap: 10px;
|
||||
padding: 10px 12px; border-radius: 12px;
|
||||
background: rgba(24, 24, 37, 0.97); border: 1px solid #313244;
|
||||
box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
|
||||
-webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
|
||||
}
|
||||
.iwb-editor-color-pop[hidden] { display: none; }
|
||||
.iwb-color-pop-picker { display: flex; gap: 8px; flex: 0 0 auto; }
|
||||
.iwb-editor-color-pop .iwb-color-sv { width: 180px; height: 104px; flex: 0 0 180px; }
|
||||
.iwb-editor-color-pop .iwb-color-hue { width: 16px; height: 104px; flex: 0 0 16px; }
|
||||
.iwb-color-pop-sep { width: 1px; align-self: stretch; background: #313244; flex: 0 0 auto; }
|
||||
.iwb-color-pop-fields { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
|
||||
.iwb-editor-color-pop .iwb-editor-color-hex-input {
|
||||
width: 86px; height: 28px; padding: 0 6px; text-align: center;
|
||||
font: 600 12px monospace; border-radius: 6px; box-sizing: border-box;
|
||||
}
|
||||
.iwb-editor-color-pop .iwb-editor-color-swatches {
|
||||
display: grid; grid-template-columns: repeat(6, 22px); grid-auto-rows: 22px;
|
||||
gap: 7px; flex: 0 0 auto; align-content: center;
|
||||
}
|
||||
.iwb-editor-color-pop .iwb-editor-color-panel-swatch {
|
||||
width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
|
||||
transition: transform 0.08s ease;
|
||||
}
|
||||
.iwb-editor-color-pop .iwb-editor-color-panel-swatch:hover { transform: scale(1.12); }
|
||||
.iwb-editor-color-pop .iwb-editor-color-panel-swatch.active {
|
||||
outline: 2px solid #fff; outline-offset: 2px;
|
||||
}
|
||||
.iwb-editor-color-pop .iwb-editor-color-eye { width: 28px; height: 28px; border-radius: 6px; }
|
||||
|
||||
/* ================================================================
|
||||
v1.4:侧栏「快速效果」
|
||||
3×2 网格,作用于当前位图图层。只做颜色/采样变换,不改几何。
|
||||
图标全部用 CSS 渐变画(不引第三方库,也不加 SVG 体积)。
|
||||
================================================================ */
|
||||
.iwb-editor-fx {
|
||||
display: flex; flex-direction: column; gap: 8px;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.iwb-editor-fx-head {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 6px;
|
||||
}
|
||||
.iwb-editor-fx-title {
|
||||
font-size: 11px; font-weight: 600; letter-spacing: 0.4px; color: #a6adc8;
|
||||
}
|
||||
.iwb-editor-fx-target {
|
||||
max-width: 116px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
padding: 2px 6px; border-radius: 5px; background: #313244; color: #cdd6f4;
|
||||
font-size: 10px; line-height: 1.4;
|
||||
}
|
||||
.iwb-editor-fx-grid {
|
||||
display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
|
||||
}
|
||||
.iwb-editor-fx-btn {
|
||||
display: flex; flex-direction: column; align-items: center; gap: 5px;
|
||||
padding: 7px 2px 6px; border: 1px solid transparent; border-radius: 9px;
|
||||
background: #232334; color: #cdd6f4;
|
||||
font: 500 10.5px/1 -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
|
||||
cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
|
||||
}
|
||||
.iwb-editor-fx-btn:hover { background: #313244; border-color: #45475a; }
|
||||
.iwb-editor-fx-btn:active { transform: scale(0.96); }
|
||||
.iwb-editor-fx-btn:focus-visible { outline: 2px solid #89b4fa; outline-offset: 1px; }
|
||||
.iwb-editor-fx-ico {
|
||||
width: 22px; height: 22px; border-radius: 5px; display: block;
|
||||
background-color: #d9d9e3;
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
/* 图标统一垫浅色底:纯黑部分若直接压在深色按钮上会「消失」,看着像缺了个角 */
|
||||
.ico-invert { background-image: linear-gradient(135deg, transparent 0 50%, #14141f 50% 100%); }
|
||||
.ico-gray { background-image: linear-gradient(90deg, #12121c 0, #8a8a99 50%, #f4f4f8 100%); }
|
||||
.ico-boost {
|
||||
background-image: radial-gradient(circle at 50% 52%, #ffffff 0 24%, #cfcfdd 42%, #6e6e85 100%);
|
||||
}
|
||||
.ico-contrast { background-image: linear-gradient(90deg, #000000 0 46%, #ffffff 54% 100%); }
|
||||
.ico-soft {
|
||||
background-image: radial-gradient(circle at 50% 50%, #23233a 0 16%, rgba(35, 35, 58, 0.5) 34%, rgba(35, 35, 58, 0.16) 50%, rgba(35, 35, 58, 0) 68%);
|
||||
}
|
||||
.ico-mosaic {
|
||||
background-image: repeating-conic-gradient(#6b6b80 0% 25%, #d9d9e3 0% 50%);
|
||||
background-size: 10px 10px;
|
||||
}
|
||||
.iwb-editor-fx-tip {
|
||||
margin: 0; font-size: 10px; line-height: 1.55; color: #6c7086;
|
||||
}
|
||||
|
||||
/* ================================================================
|
||||
v1.6:图层面板多选(⌘/Ctrl 点击)+ 合并按钮
|
||||
多选用青色侧条与单选(橙色 #e8a735)区分:一个图层可以「被选中但不在合并集合里」,
|
||||
两套状态不能长得一样。
|
||||
================================================================ */
|
||||
.iwb-layer-item.multi {
|
||||
background: rgba(137, 180, 250, 0.14);
|
||||
box-shadow: inset 2px 0 0 #89b4fa;
|
||||
}
|
||||
.iwb-layer-item.multi.active {
|
||||
background: rgba(137, 180, 250, 0.2);
|
||||
box-shadow: inset 2px 0 0 #89b4fa, inset 0 0 0 1px rgba(137, 180, 250, 0.45);
|
||||
}
|
||||
.iwb-editor-layer-add-group { flex: 0 0 auto; flex-wrap: nowrap; }
|
||||
.iwb-editor-layer-add-btn[data-action="mergeLayers"]:hover,
|
||||
.iwb-editor-layer-add-btn[data-action="mergeVisible"]:hover {
|
||||
background: #45475a;
|
||||
border-color: #89b4fa;
|
||||
color: #cdd6f4;
|
||||
}
|
||||
@@ -94,6 +94,8 @@ import { bindEvents } from './events.js'
|
||||
<span class="iwb-editor-layer-panel-title">图层</span>
|
||||
<!-- 图层的「新建 / 导入图片」回到标题栏右侧(用户裁定 2026-11-04:顶栏只留顺序与视图命令) -->
|
||||
<div class="iwb-editor-layer-add-group">
|
||||
<button class="iwb-editor-layer-add-btn" data-action="mergeLayers" title="合并图层 (Ctrl/⌘+E):⌘/Ctrl 点击可多选图层后合并;未多选时向下合并"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m12 2 9 4.5-9 4.5-9-4.5L12 2Z"/><path d="m3 12 9 4.5 9-4.5"/><path d="M12 17v4"/><path d="m9.5 18.5 2.5 2.5 2.5-2.5"/></svg></button>
|
||||
<button class="iwb-editor-layer-add-btn" data-action="mergeVisible" title="合并可见图层 (Ctrl/⌘+Shift+E):隐藏的图层保留不动"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m12 2 9 4.5-9 4.5-9-4.5L12 2Z"/><path d="m3 11 9 4.5 9-4.5"/><path d="m3 15.5 9 4.5 9-4.5"/></svg></button>
|
||||
<button class="iwb-editor-layer-add-btn" data-action="addBlankLayer" title="新建空白图层 (Ctrl+Shift+N)"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg></button>
|
||||
<button class="iwb-editor-layer-add-btn" data-action="addBitmapLayer" title="导入图片为新图层 (Ctrl+O),也可直接 ⌘/Ctrl+V 粘贴剪贴板图片"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/><line x1="19" y1="8" x2="19" y2="14"/><line x1="22" y1="11" x2="16" y2="11"/></svg></button>
|
||||
</div>
|
||||
@@ -126,6 +128,9 @@ import { bindEvents } from './events.js'
|
||||
<button data-sel-cmd="sel.none" title="取消选区 (Esc / Ctrl+D)">取消</button>
|
||||
</div>
|
||||
<div class="iwb-editor-tools">
|
||||
<!-- 当前色圆点(v1.3):点开就是完整色板,侧栏不再放调色板 -->
|
||||
<button type="button" class="iwb-editor-color-btn" data-action="toggleColorPop" aria-expanded="false" title="颜色:点开色板(调色器 / 吸管 / 推荐色)"><i></i></button>
|
||||
<span class="iwb-editor-divider"></span>
|
||||
<button class="iwb-editor-tool" data-tool="select" title="选择/移动 (V):点击元素选中,拖拽移动,手柄调整大小,双击文字改内容"><svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 3l7.07 16.97 2.51-7.39 7.39-2.51L3 3z"/></svg></button>
|
||||
<span class="iwb-editor-divider"></span>
|
||||
|
||||
@@ -160,10 +165,39 @@ import { bindEvents } from './events.js'
|
||||
<div class="iwb-editor-zoom-hint">滚轮缩放 · 抓手/空格/中键拖拽自由移动画布</div>
|
||||
|
||||
<aside class="iwb-editor-left">
|
||||
<div class="iwb-editor-color-panel"><div class="iwb-editor-color-panel-title">调色板</div><div class="iwb-editor-color-picker2"><div class="iwb-color-sv"><span></span></div><div class="iwb-color-hue"><span></span></div></div><div class="iwb-editor-color-fields"><button type="button" class="iwb-editor-color-eye" data-action="palettePick" title="吸色:点击后在画布取样"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button><input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7"></div><div class="iwb-editor-color-swatches"><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ff4444" style="background:#ff4444" title="#ff4444"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ff8800" style="background:#ff8800" title="#ff8800"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ffd400" style="background:#ffd400" title="#ffd400"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#44dd44" style="background:#44dd44" title="#44dd44"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#00bfa5" style="background:#00bfa5" title="#00bfa5"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#4488ff" style="background:#4488ff" title="#4488ff"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#aa44ff" style="background:#aa44ff" title="#aa44ff"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ff66aa" style="background:#ff66aa" title="#ff66aa"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ffffff" style="background:#ffffff" title="#ffffff"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#b8b8b8" style="background:#b8b8b8" title="#b8b8b8"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#555555" style="background:#555555" title="#555555"></button><button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#000000" style="background:#000000" title="#000000"></button></div></div>
|
||||
<!-- 描边粗细/快捷点已从侧栏移除(用户裁定 2026-11-04):都收进工具选项栏一处,
|
||||
侧栏只保留调色板与缩放,避免「同一参数两个入口、数值还对不上」 -->
|
||||
<!-- 调色板已迁到工具栏弹层(v1.3,用户裁定 2026-11-05):
|
||||
侧栏只留快速效果 + 缩放;色板 DOM 在 modal 末尾的 .iwb-editor-color-pop -->
|
||||
<!-- 快速效果(v1.4):作用于当前位图图层,点一下就应用,Ctrl+Z 撤销。
|
||||
目标层名由 effects.js 的 updateFxTargetLabel() 实时刷新。 -->
|
||||
<section class="iwb-editor-fx">
|
||||
<div class="iwb-editor-fx-head">
|
||||
<span class="iwb-editor-fx-title">快速效果</span>
|
||||
<span class="iwb-editor-fx-target" title="效果作用于当前位图图层">原图</span>
|
||||
</div>
|
||||
<div class="iwb-editor-fx-grid">
|
||||
<button type="button" class="iwb-editor-fx-btn" data-fx="invert" title="反白(反相 Invert):明暗翻转,白底变黑底、黑字变白字">
|
||||
<span class="iwb-editor-fx-ico ico-invert"></span><span>反白</span>
|
||||
</button>
|
||||
<button type="button" class="iwb-editor-fx-btn" data-fx="gray" title="灰度:去色,保留明暗层次">
|
||||
<span class="iwb-editor-fx-ico ico-gray"></span><span>灰度</span>
|
||||
</button>
|
||||
<button type="button" class="iwb-editor-fx-btn" data-fx="boost" title="增强:提亮并略加对比,适合发灰的截图">
|
||||
<span class="iwb-editor-fx-ico ico-boost"></span><span>增强</span>
|
||||
</button>
|
||||
<button type="button" class="iwb-editor-fx-btn" data-fx="contrast" title="高对比:压成黑白硬调,突出主体">
|
||||
<span class="iwb-editor-fx-ico ico-contrast"></span><span>高对比</span>
|
||||
</button>
|
||||
<button type="button" class="iwb-editor-fx-btn" data-fx="soft" title="柔化:轻微模糊,弱化背景">
|
||||
<span class="iwb-editor-fx-ico ico-soft"></span><span>柔化</span>
|
||||
</button>
|
||||
<button type="button" class="iwb-editor-fx-btn" data-fx="mosaic" title="马赛克:像素化,用于打码手机号/地址等隐私信息">
|
||||
<span class="iwb-editor-fx-ico ico-mosaic"></span><span>马赛克</span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="iwb-editor-fx-tip">作用于当前层 · Ctrl+Z 可撤销</p>
|
||||
</section>
|
||||
<div class="iwb-editor-zoom">
|
||||
|
||||
<button class="iwb-editor-zoom-btn" data-action="zoomOut" title="缩小 (Ctrl+- / 滚轮向下)">−</button>
|
||||
<span class="iwb-editor-zoom-val" title="滚轮缩放">100%</span>
|
||||
<button class="iwb-editor-zoom-btn" data-action="zoomIn" title="放大 (Ctrl++ / 滚轮向上)">+</button>
|
||||
@@ -183,6 +217,35 @@ import { bindEvents } from './events.js'
|
||||
<span class="iwb-editor-status-layer">当前层:原图</span>
|
||||
<span class="iwb-editor-status-tool">画笔</span>
|
||||
</div>
|
||||
<!-- 色板弹层(v1.3):工具栏色点点击展开。
|
||||
必须挂在 modal 下、不能塞进 .iwb-editor-tools —— 工具栏是 overflow-x:auto,
|
||||
canvas-wrap 是 overflow:clip,塞进去弹层会被直接裁掉;定位由 events.js 计算。 -->
|
||||
<div class="iwb-editor-color-pop" hidden>
|
||||
<div class="iwb-color-pop-picker">
|
||||
<div class="iwb-color-sv"><span></span></div>
|
||||
<div class="iwb-color-hue"><span></span></div>
|
||||
</div>
|
||||
<span class="iwb-color-pop-sep"></span>
|
||||
<div class="iwb-color-pop-fields">
|
||||
<button type="button" class="iwb-editor-color-eye" data-action="palettePick" title="吸色:切到吸管工具,在画布上点一下取色"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 22 1-1h3l9-9"/><path d="M3 21v-3l9-9"/><path d="m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3Z"/></svg></button>
|
||||
<input class="iwb-editor-color-hex-input" value="#ff4444" maxlength="7" spellcheck="false" autocomplete="off" title="十六进制颜色,回车生效">
|
||||
</div>
|
||||
<span class="iwb-color-pop-sep"></span>
|
||||
<div class="iwb-editor-color-swatches">
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ff4444" style="background:#ff4444" title="#ff4444"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ff8a00" style="background:#ff8a00" title="#ff8a00"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ffd400" style="background:#ffd400" title="#ffd400"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#4cd964" style="background:#4cd964" title="#4cd964"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#00bfa5" style="background:#00bfa5" title="#00bfa5"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#4488ff" style="background:#4488ff" title="#4488ff"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#aa44ff" style="background:#aa44ff" title="#aa44ff"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ff66aa" style="background:#ff66aa" title="#ff66aa"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#ffffff" style="background:#ffffff" title="#ffffff"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#d0d0d0" style="background:#d0d0d0" title="#d0d0d0"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#808080" style="background:#808080" title="#808080"></button>
|
||||
<button type="button" class="iwb-editor-color-panel-swatch" data-panel-color="#000000" style="background:#000000" title="#000000"></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="iwb-editor-toast" role="status" aria-live="polite"></div>
|
||||
</div>
|
||||
`
|
||||
|
||||
+161
@@ -0,0 +1,161 @@
|
||||
/* effects.js - 侧栏「快速效果」(v1.4)
|
||||
*
|
||||
* 作用对象只有一个:当前位图图层(侧栏标题后面实时显示层名)。
|
||||
* 全部走 canvas 2D 的 ctx.filter / 缩放重采样,不引入依赖、不动矢量层、
|
||||
* 不改图层几何,因此对「原图」这种带 locked 标记的层也安全(效果不是画笔)。
|
||||
*
|
||||
* 撤销:应用前 saveSnapshot()。base 与画笔层走像素快照(putImageData),
|
||||
* 天然可回退;导入图片层走 image/sourceCanvas 重绘,原地改像素会被下一次
|
||||
* 重绘冲掉,所以先按 PS「栅格化」的做法落一个普通位图副本(原层隐藏)。
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
import { S } from './state.js'
|
||||
import { saveSnapshot } from './history.js'
|
||||
import { createLayerCanvas, getActiveLayer, renderLayerPanel, reorderLayerCanvas, updateLayerCanvasStyles } from './layers.js'
|
||||
import { layerUnits } from './objects.js'
|
||||
import { needsPixelSnapshot } from '../vendor/layer-logic.js'
|
||||
import { toast } from './commands.js'
|
||||
|
||||
/** 效果表:label 用于按钮与提示,css 可依赖画布尺寸(柔化半径随图缩放) */
|
||||
export const 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 }
|
||||
}
|
||||
|
||||
const SOFT_MIN = 0.8
|
||||
const 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))
|
||||
}
|
||||
function mosaicBlock(canvas) {
|
||||
const side = Math.min(canvas.width || 0, canvas.height || 0)
|
||||
return Math.max(6, Math.round(side / 60))
|
||||
}
|
||||
|
||||
/** 效果目标:当前活跃位图图层;没有就退回「原图」 */
|
||||
export function effectTarget() {
|
||||
const active = getActiveLayer()
|
||||
if (active) return active
|
||||
return S.layers.find(l => l.id === 'base') || null
|
||||
}
|
||||
|
||||
/** 用 ctx.filter 把画布自身重绘一遍(临时画布中转,避免自绘自的采样问题) */
|
||||
function filterCanvas(canvas, css) {
|
||||
const w = canvas.width, h = canvas.height
|
||||
if (!w || !h || !css) return
|
||||
const tmp = document.createElement('canvas')
|
||||
tmp.width = w
|
||||
tmp.height = h
|
||||
const tctx = tmp.getContext('2d')
|
||||
tctx.filter = css
|
||||
tctx.drawImage(canvas, 0, 0)
|
||||
|
||||
const ctx = canvas.getContext('2d')
|
||||
ctx.save()
|
||||
// 图层 ctx 平时带着视图变换,重绘必须回到设备像素坐标系
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
ctx.globalAlpha = 1
|
||||
ctx.globalCompositeOperation = 'copy' // copy:连透明像素一起替换,不留旧内容
|
||||
ctx.filter = 'none'
|
||||
ctx.drawImage(tmp, 0, 0)
|
||||
ctx.restore()
|
||||
}
|
||||
|
||||
/** 马赛克:缩到 1/block 再关掉平滑放大,比逐像素 getImageData 快一个量级 */
|
||||
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 tmp = document.createElement('canvas')
|
||||
tmp.width = sw
|
||||
tmp.height = sh
|
||||
const tctx = tmp.getContext('2d')
|
||||
tctx.imageSmoothingEnabled = true
|
||||
tctx.drawImage(canvas, 0, 0, sw, sh)
|
||||
|
||||
const ctx = canvas.getContext('2d')
|
||||
ctx.save()
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
ctx.globalAlpha = 1
|
||||
ctx.globalCompositeOperation = 'copy'
|
||||
ctx.imageSmoothingEnabled = false
|
||||
ctx.filter = 'none'
|
||||
ctx.drawImage(tmp, 0, 0, w, h)
|
||||
ctx.restore()
|
||||
}
|
||||
|
||||
/**
|
||||
* 把「导入图片层」栅格化成普通位图,插在它上面一层。
|
||||
* 只拷当前 canvas 的可见结果(已含旋转/缩放),所以视觉不变。
|
||||
* 原层隐藏而不删除:撤销时快照里有它的 visible,能原样恢复。
|
||||
*/
|
||||
function rasterizeLayer(layer) {
|
||||
const canvas = createLayerCanvas()
|
||||
const ctx = canvas.getContext('2d', { willReadFrequently: true })
|
||||
ctx.clearRect(0, 0, S.imgW, S.imgH)
|
||||
ctx.drawImage(layer.canvas, 0, 0)
|
||||
|
||||
// z 取「原层 → 上一层」的中点,保证副本紧贴在原层上方,不会窜到别的标注之上
|
||||
const units = layerUnits()
|
||||
const i = units.findIndex(u => u.kind === 'bitmap' && u.obj === layer)
|
||||
const baseZ = layer.z || 0
|
||||
const nextZ = (i >= 0 && units[i + 1]) ? (units[i + 1].obj.z || 0) : baseZ + 1
|
||||
const z = nextZ > baseZ ? (baseZ + nextZ) / 2 : baseZ + 0.5
|
||||
|
||||
const clone = {
|
||||
id: 'fx' + Date.now() + Math.floor(Math.random() * 1000),
|
||||
name: layer.name + ' · 效果',
|
||||
canvas,
|
||||
ctx,
|
||||
opacity: layer.opacity == null ? 1 : layer.opacity,
|
||||
visible: true,
|
||||
locked: false,
|
||||
x: 0, y: 0, w: S.imgW, h: S.imgH,
|
||||
rotation: 0,
|
||||
z
|
||||
}
|
||||
S.layers.push(clone)
|
||||
layer.visible = false
|
||||
if (S.selectedLayerId === layer.id) S.selectedLayerId = clone.id
|
||||
S.activeLayerId = clone.id
|
||||
reorderLayerCanvas()
|
||||
updateLayerCanvasStyles()
|
||||
renderLayerPanel()
|
||||
return clone
|
||||
}
|
||||
|
||||
/** 唯一入口:应用一个快速效果 */
|
||||
export function applyQuickEffect(key) {
|
||||
const fx = QUICK_EFFECTS[key]
|
||||
if (!fx) return false
|
||||
const layer = effectTarget()
|
||||
if (!layer) { toast('没有可处理的图层'); return false }
|
||||
if (layer.visible === false) {
|
||||
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 = undefined
|
||||
S.pickerComposite = null
|
||||
if (S.renderAll) S.renderAll()
|
||||
renderLayerPanel()
|
||||
toast('已应用「' + fx.label + '」到 ' + target.name + ' · Ctrl+Z 撤销', 'success')
|
||||
return true
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import { S, ZOOM_STEP, runtime } from './state.js'
|
||||
import { ROT_CURSOR, clamp, getPos, isOverRotationHandle, setView, setZoomActual, setZoomFit, zoomStep } from './viewport.js'
|
||||
import { addBitmapLayer, addBlankLayer, applyBitmapDrag, beginBitmapDrag, clearSelection, deleteLayer, ensureWritableLayer, getActiveCtx, getActiveLayer, hitBitmapHandle, removeVecCanvas, renderLayerPanel } from './layers.js'
|
||||
import { addBitmapLayer, addBlankLayer, applyBitmapDrag, beginBitmapDrag, clearSelection, deleteLayer, ensureWritableLayer, getActiveCtx, getActiveLayer, hitBitmapHandle, mergeLayers, mergeVisibleLayers, removeVecCanvas, renderLayerPanel } from './layers.js'
|
||||
import { applyColorChange, beginAltPicker, beginStroke, clearToolRing, drawToolRing, endAltPicker, endStroke, eraseSegment, exitPicker, hidePickerTip, sampleColor, setTool, showPickerTip, strokeSegment } from './tools.js'
|
||||
import { beginMarquee, updateMarquee, endMarquee, beginLasso, updateLasso, endLasso, clearMarquee, syncAnts, renderSelection } from './selection.js'
|
||||
import { runCommand, toast } from './commands.js'
|
||||
@@ -19,6 +19,7 @@ import { cancelImagePlacement, confirmImagePlacement, drawPlacementPreview, hitP
|
||||
import { close, exportResult } from './index.js'
|
||||
import { loadImage } from './dom.js'
|
||||
import { pushHistory, redo, resetDraw, restoreOriginal, restoreAll, saveSnapshot, snapshotState, undo } from './history.js'
|
||||
import { applyQuickEffect } from './effects.js'
|
||||
import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
|
||||
|
||||
@@ -58,19 +59,86 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
S.startX = pos.x
|
||||
S.startY = pos.y
|
||||
hideSelectionContext()
|
||||
// 点画布视为离开图层面板:退出「合并多选」,免得下次 Ctrl+E 合到看不见的旧集合上
|
||||
if (S.layerMulti.length) { S.layerMulti.length = 0; renderLayerPanel() }
|
||||
|
||||
// 选区工具:拉框 / 套索期间独占交互,不与选择/绘制/裁剪分支纠缠
|
||||
if (S.tool === 'marquee') { beginMarquee(pos); return }
|
||||
if (S.tool === 'lasso') { beginLasso(pos); return }
|
||||
|
||||
// 钢笔节点编辑优先:点节点/点边直接接管;点空白退出编辑后继续走下方工具逻辑
|
||||
if ((S.tool === 'select' || S.tool === 'pen')) {
|
||||
// 双击:V 下进对象编辑(钢笔节点 / 文字内容),P 下结束当前路径。
|
||||
// 自己判而不听 dblclick 事件 —— 画布上选中态重绘会让浏览器换掉命中元素,
|
||||
// 实测 dblclick 根本不派发(无头环境 100% 复现),而 mousedown 一定有。
|
||||
const dbl = isDoubleClick(pos)
|
||||
if (S.tool === 'select') {
|
||||
if (dbl && onCanvasDoubleClick(e, pos)) return
|
||||
// 钢笔节点编辑优先(只属于 V,v1.5):点节点/点边直接接管;点空白退出编辑后继续走下方工具逻辑
|
||||
const penShape = getPenEditingShape()
|
||||
if (penShape && onPenEditMouseDown(e, pos, penShape)) return
|
||||
}
|
||||
if (S.tool === 'pen' && dbl) { commitPenPath(); return }
|
||||
|
||||
const handler = Object.prototype.hasOwnProperty.call(MOUSE_DOWN_HANDLERS, S.tool) ? MOUSE_DOWN_HANDLERS[S.tool] : null
|
||||
if (handler) handler(pos)
|
||||
if (handler) handler(pos, e)
|
||||
}
|
||||
|
||||
/**
|
||||
* 自算双击:同一位置 380ms 内两次 mousedown。
|
||||
* 命中一次后清空记录,三连击不会重复触发。
|
||||
*/
|
||||
const DBL_INTERVAL = 380
|
||||
function isDoubleClick(pos) {
|
||||
const now = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now()
|
||||
const last = S.lastClick
|
||||
const hit = !!last && (now - last.t) < DBL_INTERVAL &&
|
||||
Math.hypot(pos.x - last.x, pos.y - last.y) < Math.max(8 / S.zoom, 6)
|
||||
S.lastClick = hit ? null : { t: now, x: pos.x, y: pos.y }
|
||||
return hit
|
||||
}
|
||||
|
||||
/**
|
||||
* 双击语义(只属于 V,v1.5 用户裁定):
|
||||
* 编辑中的钢笔删节点 > 未编辑的钢笔进节点编辑 > 文字进内容编辑。
|
||||
* 返回 true 表示已接管,不再走单击逻辑。
|
||||
*/
|
||||
function onCanvasDoubleClick(e, pos) {
|
||||
const penShape = getPenEditingShape()
|
||||
if (penShape) {
|
||||
const pi = hitPenPoint(pos, penShape, Math.max(14 / S.zoom, 8))
|
||||
if (pi < 0) return false
|
||||
e.preventDefault()
|
||||
saveSnapshot()
|
||||
const pts = penShape.pts
|
||||
const minPts = penShape.closed ? 3 : 2
|
||||
if (pts.length <= minPts) {
|
||||
removeVecCanvas(penShape)
|
||||
S.shapeLayers = S.shapeLayers.filter(x => x.id !== penShape.id)
|
||||
S.penEditId = null
|
||||
S.selectedShapeId = null
|
||||
} else {
|
||||
pts.splice(pi, 1)
|
||||
if (penShape.closed && pts.length < 3) penShape.closed = false
|
||||
}
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
return true
|
||||
}
|
||||
const hitPen = hitShapeLayer(pos, true)
|
||||
if (hitPen && hitPen.type === 'pen') {
|
||||
e.preventDefault()
|
||||
beginPenEdit(hitPen)
|
||||
return true
|
||||
}
|
||||
const hitText = hitTextLayer(pos)
|
||||
if (hitText) {
|
||||
e.preventDefault()
|
||||
selectUnit('text', hitText.id)
|
||||
if (hitText.locked) return true
|
||||
renderObjects()
|
||||
showTextInput(hitText.x, hitText.y, hitText)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/** 图片放置模式的按下:命中手柄/图内开始拖拽,点外部确认放置 */
|
||||
@@ -175,27 +243,14 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
S.isDrawing = true
|
||||
}
|
||||
|
||||
/** 文字工具的按下:手柄 > 命中已有文字 > 在点击处新建文字 */
|
||||
/** 文字工具的按下:只负责「在点击处新建文字」。
|
||||
* v1.3(用户裁定 2026-11-05):与矢量工具同一套规则 —— 点已有文字不再选中/移动它,
|
||||
* 否则想在文字上叠一段新文字时会被当成拖旧文字。选中/移动/缩放交给 V;
|
||||
* 改内容 = V 下双击(T 下双击沿用旧行为,仍可直接改)。 */
|
||||
function onTextMouseDown(pos) {
|
||||
if (commitTextInput()) return
|
||||
const handle = hitTextHandle(pos)
|
||||
if (handle) { if (handle === 'rotate') beginTextRotate(pos); else beginTextScaleDrag(handle, pos); return }
|
||||
const hit = hitTextLayer(pos)
|
||||
if (hit) {
|
||||
selectUnit('text', hit.id)
|
||||
if (hit.locked) { renderObjects(); renderLayerPanel(); return }
|
||||
S.textDrag = {
|
||||
mode: 'move',
|
||||
start: pos,
|
||||
layer: { x: hit.x, y: hit.y },
|
||||
pending: snapshotState()
|
||||
}
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
} else {
|
||||
if (S.selectedTextId) { S.selectedTextId = null; renderObjects(); renderLayerPanel() }
|
||||
showTextInput(pos.x, pos.y)
|
||||
}
|
||||
if (S.selectedTextId) { S.selectedTextId = null; renderObjects(); renderLayerPanel() }
|
||||
showTextInput(pos.x, pos.y)
|
||||
}
|
||||
|
||||
/** 吸管工具的按下:取样并应用颜色后退出吸管模式 */
|
||||
@@ -266,19 +321,11 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
return
|
||||
}
|
||||
|
||||
/** 矩形/圆形/箭头的按下:命中同类型形状则拖动,否则开始拉新形状 */
|
||||
/** 矩形/圆形/箭头的按下:只负责「起笔新建」。
|
||||
* v1.3(用户裁定 2026-11-05):矢量工具不再具备选择功能 —— 以前这里先试手柄、
|
||||
* 再命中同类型形状并拖动它,于是在已有矩形上面按下会被当成拖旧矩形,
|
||||
* 根本没法在它上面继续画。选中/移动/改尺寸统一交给 V(选择工具)。 */
|
||||
function onShapeMouseDown(pos) {
|
||||
const handle = hitShapeHandle(pos)
|
||||
if (handle) { beginShapeHandleDrag(handle, pos); return }
|
||||
const hitShape = hitShapeLayer(pos, true)
|
||||
if (hitShape && hitShape.type === S.tool) {
|
||||
S.selectedShapeId = hitShape.id
|
||||
if (hitShape.locked) { renderObjects(); renderLayerPanel(); return }
|
||||
S.shapeDrag = { mode: 'move', start: pos, shape: { ...hitShape }, pending: snapshotState() }
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
return
|
||||
}
|
||||
if (S.selectedShapeId) { S.selectedShapeId = null; renderObjects(); renderLayerPanel() }
|
||||
S.isDrawing = true
|
||||
}
|
||||
@@ -644,7 +691,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
}
|
||||
}
|
||||
|
||||
/** 矩形/圆/箭头拉框结束:尺寸达标则落成新形状并选中 */
|
||||
/** 矩形/圆/箭头拉框结束:尺寸达标则落成新形状,并回到 V 选中它 */
|
||||
function onShapeDrawUp(pos) {
|
||||
const len = Math.hypot(pos.x - S.startX, pos.y - S.startY)
|
||||
const ok = S.tool === 'rect' || S.tool === 'circle'
|
||||
@@ -666,12 +713,30 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
z: ++S.zCounter
|
||||
}
|
||||
S.shapeLayers.push(shape)
|
||||
selectUnit('shape', shape.id)
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
finishCreateTool('shape', shape.id)
|
||||
return
|
||||
}
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建类工具画完即回 V 并选中新对象(用户 2026-11-05 裁定)。
|
||||
* 依据:画完的下一步基本是调位置/颜色/粗细,再手动按一次 V 是多余动作。
|
||||
* 顺序必须是「先 setTool('select') 再 selectUnit」—— setTool 里对非选中类工具
|
||||
* 会清三个选中 id,反过来选中会被立刻清掉。
|
||||
*/
|
||||
function finishCreateTool(kind, id) {
|
||||
if (['rect', 'circle', 'arrow', 'pen'].indexOf(S.tool) < 0) return
|
||||
setTool('select')
|
||||
if (!id) return
|
||||
selectUnit(kind, id)
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
}
|
||||
|
||||
// ============ 缩放 ============
|
||||
function onWheel(e) {
|
||||
if (!S.open) return
|
||||
@@ -723,12 +788,26 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
updateStatusbar()
|
||||
}
|
||||
|
||||
/**
|
||||
* 笔刷大小 / 工具变化后立刻按「最后悬停点」重画笔刷环。
|
||||
* 不这么做,按 ] / [ 或拖选项栏滑块时只有数值在变,环要等下一次 mousemove 才跟上
|
||||
* —— 用户看到的就是「调了大小但光标没变,动一下鼠标才正常」(v1.6 反馈)。
|
||||
*/
|
||||
export function refreshBrushRing() {
|
||||
if (!S.hoverPos) return
|
||||
if (S.tool !== 'brush' && S.tool !== 'eraser') return
|
||||
if (S.isDrawing) return
|
||||
drawToolRing(S.hoverPos)
|
||||
}
|
||||
|
||||
export function updateCursor() {
|
||||
if (S.panning) { S.drawCanvasCursor('grabbing'); return }
|
||||
if (S.spaceDown) { S.drawCanvasCursor('grab'); return }
|
||||
if (S.tool === 'hand') { S.drawCanvasCursor('grab'); return }
|
||||
if (S.tool === 'brush' || S.tool === 'eraser') {
|
||||
S.drawCanvasCursor('none')
|
||||
// 切到画笔/橡皮时鼠标可能已经在画布上停着:直接补画一次环,不用等移动
|
||||
refreshBrushRing()
|
||||
return
|
||||
}
|
||||
if (S.tool === 'crop' && S.cropRect) {
|
||||
@@ -755,6 +834,9 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
const panelHex = runtime.el.querySelector('.iwb-editor-color-hex')
|
||||
const hexInput = runtime.el.querySelector('.iwb-editor-color-hex-input')
|
||||
if (hexInput && document.activeElement !== hexInput) hexInput.value = S.color.toUpperCase()
|
||||
// 工具栏色点:色板收起时它就是唯一的颜色指示,必须始终跟随 S.color
|
||||
const colorDot = runtime.el.querySelector('.iwb-editor-color-btn i')
|
||||
if (colorDot) colorDot.style.background = S.color
|
||||
runtime.el.querySelectorAll('.iwb-editor-color-panel-swatch').forEach(sw => sw.classList.toggle('active', (sw.dataset.panelColor || '').toLowerCase() === S.color.toLowerCase()))
|
||||
if (panelHex) panelHex.textContent = S.color.toUpperCase()
|
||||
const rgb = hexToRgb(S.color)
|
||||
@@ -1086,6 +1168,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
S.brushSize = clamp(safe || 1, 1, 300)
|
||||
updateBrushUI()
|
||||
updateBrushParamUI()
|
||||
refreshBrushRing()
|
||||
} else if (key === 'brushHardness') {
|
||||
S.brushHardness = clamp(safe, 0, 100)
|
||||
updateBrushParamUI()
|
||||
@@ -1136,6 +1219,13 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
// 选区命令(全选/反选/取消)在「选择」工具的选项栏里,与竖工具条时代一样走根级事件委托:
|
||||
// 三个按钮不切换工具,只调命令层(与快捷键、右键菜单同一条路径)。
|
||||
root.addEventListener('click', (e) => {
|
||||
// 快速效果(侧栏):点一下即应用,目标层与撤销由 effects.js 负责
|
||||
const fxBtn = e.target.closest('[data-fx]')
|
||||
if (fxBtn) {
|
||||
e.stopPropagation()
|
||||
applyQuickEffect(fxBtn.dataset.fx)
|
||||
return
|
||||
}
|
||||
const btn = e.target.closest('[data-more]')
|
||||
if (!btn) return
|
||||
e.stopPropagation()
|
||||
@@ -1281,15 +1371,92 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
})
|
||||
}
|
||||
|
||||
/** 独立颜色面板:hex 输入、面板色块、吸管入口与 SV/HUE 取色区 */
|
||||
/** 关闭色板弹层;返回「关之前是开着的」,供 Esc 决定要不要吞掉这次按键 */
|
||||
export function closeColorPop() {
|
||||
const pop = runtime.el && runtime.el.querySelector('.iwb-editor-color-pop')
|
||||
if (!pop || pop.hidden) return false
|
||||
pop.hidden = true
|
||||
const btn = runtime.el.querySelector('[data-action="toggleColorPop"]')
|
||||
if (btn) { btn.classList.remove('active'); btn.setAttribute('aria-expanded', 'false') }
|
||||
return true
|
||||
}
|
||||
|
||||
/** 弹层定位:贴工具栏色点上方、左对齐;上方放不下翻到下方,左右夹在 modal 内。
|
||||
* 坐标用「按钮矩形 − modal 矩形」算,弹层是 modal 的绝对定位子节点,
|
||||
* 这样宿主页面有 transform 时也不会错位。 */
|
||||
function positionColorPop() {
|
||||
const pop = runtime.el && runtime.el.querySelector('.iwb-editor-color-pop')
|
||||
const btn = runtime.el && runtime.el.querySelector('[data-action="toggleColorPop"]')
|
||||
const modal = runtime.el && runtime.el.querySelector('.iwb-editor-modal')
|
||||
if (!pop || !btn || !modal || pop.hidden) return
|
||||
const mr = modal.getBoundingClientRect()
|
||||
const br = btn.getBoundingClientRect()
|
||||
const pr = pop.getBoundingClientRect()
|
||||
let left = br.left - mr.left - 10
|
||||
left = Math.min(Math.max(8, left), Math.max(8, mr.width - pr.width - 8))
|
||||
let top = br.top - mr.top - pr.height - 10
|
||||
if (top < 8) top = br.bottom - mr.top + 10
|
||||
pop.style.left = Math.round(left) + 'px'
|
||||
pop.style.top = Math.round(top) + 'px'
|
||||
}
|
||||
|
||||
function toggleColorPop() {
|
||||
const pop = runtime.el.querySelector('.iwb-editor-color-pop')
|
||||
const btn = runtime.el.querySelector('[data-action="toggleColorPop"]')
|
||||
if (!pop || !btn) return
|
||||
if (pop.hidden) {
|
||||
pop.hidden = false // 先显示再量:hidden 元素 getBoundingClientRect 全是 0
|
||||
btn.classList.add('active')
|
||||
btn.setAttribute('aria-expanded', 'true')
|
||||
positionColorPop()
|
||||
} else {
|
||||
closeColorPop()
|
||||
}
|
||||
}
|
||||
|
||||
/** 色板弹层(v1.3):工具栏色点开关;hex/吸管/推荐色/调色器都在这一个弹层里 */
|
||||
function bindColorPanel() {
|
||||
const pop = runtime.el.querySelector('.iwb-editor-color-pop')
|
||||
const colorBtn = runtime.el.querySelector('[data-action="toggleColorPop"]')
|
||||
if (colorBtn) {
|
||||
colorBtn.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||
colorBtn.addEventListener('click', (e) => { e.stopPropagation(); toggleColorPop() })
|
||||
}
|
||||
if (pop) {
|
||||
pop.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||
// 点外面关闭:必须用捕获阶段 —— 画布的 mousedown 会 preventDefault,
|
||||
// 冒泡阶段拿不到「点了外面」这件事。
|
||||
document.addEventListener('mousedown', (e) => {
|
||||
if (!pop.hidden && !pop.contains(e.target) && !(colorBtn && colorBtn.contains(e.target))) closeColorPop()
|
||||
}, true)
|
||||
window.addEventListener('resize', positionColorPop)
|
||||
}
|
||||
|
||||
// 独立颜色面板:颜色选择后同步当前工具颜色。
|
||||
const setPanelColor = (color) => applyColorChange(color)
|
||||
// 拖动取色期间只拍一次快照:applyColorChange 每改一次颜色都会 saveSnapshot,
|
||||
// 在 SV 里拖一下会连拍几百张全画质 ImageData(4K 图直接吃掉几百 MB)。
|
||||
// pointerdown 先拍(此时颜色还没变,快照是「改之前」),之后每步只改对象。
|
||||
let dragSnapped = false
|
||||
const hasColorTarget = () => {
|
||||
const t = getSelectedText(), sh = getSelectedShape()
|
||||
return !!((t && !t.locked) || (sh && !sh.locked))
|
||||
}
|
||||
const setDragColor = (color) => {
|
||||
if (!dragSnapped) {
|
||||
if (hasColorTarget()) { saveSnapshot(); dragSnapped = true }
|
||||
}
|
||||
applyColorChange(color, { skipHistory: true })
|
||||
}
|
||||
const panelHexInput = runtime.el.querySelector('.iwb-editor-color-hex-input')
|
||||
if (panelHexInput) panelHexInput.addEventListener('change', () => { if (/^#[0-9a-f]{6}$/i.test(panelHexInput.value)) setPanelColor(panelHexInput.value) })
|
||||
runtime.el.querySelectorAll('.iwb-editor-color-panel-swatch').forEach(btn => btn.addEventListener('click', (e) => { e.stopPropagation(); setPanelColor(btn.dataset.panelColor) }))
|
||||
const palettePick = runtime.el.querySelector('[data-action="palettePick"]')
|
||||
if (palettePick) { palettePick.addEventListener('mousedown', (e) => e.stopPropagation()); palettePick.addEventListener('click', () => setTool('picker')) }
|
||||
if (palettePick) {
|
||||
palettePick.addEventListener('mousedown', (e) => e.stopPropagation())
|
||||
// 取色要回画布点,弹层必须先收起,否则它会挡住取样点
|
||||
palettePick.addEventListener('click', () => { closeColorPop(); setTool('picker') })
|
||||
}
|
||||
const sv = runtime.el.querySelector('.iwb-color-sv')
|
||||
const hue = runtime.el.querySelector('.iwb-color-hue')
|
||||
const initHsv = (() => {
|
||||
@@ -1316,10 +1483,34 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
const y = clamp((e.clientY - r.top) / r.height, 0, 1)
|
||||
if (target === hue) hueValue = y * 360
|
||||
else { satValue = x; valValue = 1 - y }
|
||||
setPanelColor(hsvToHex(hueValue, satValue, valValue))
|
||||
setDragColor(hsvToHex(hueValue, satValue, valValue))
|
||||
}
|
||||
// 推荐色 / hex / 吸管改色时,闭包里的 h/s/v 会过期(v1.3 修:以前点了绿色再拖 SV 会跳回红色)。
|
||||
// 每次按下前从 S.color 重新同步;灰阶(d=0,如 #000)反推不出色相,就沿用旧色相。
|
||||
const syncFromColor = () => {
|
||||
const { r, g, b } = hexToRgb(S.color)
|
||||
const rr = r / 255, gg = g / 255, bb = b / 255
|
||||
const max = Math.max(rr, gg, bb), min = Math.min(rr, gg, bb), d = max - min
|
||||
if (d > 0) {
|
||||
let h = 0
|
||||
if (max === rr) h = 60 * (((gg - bb) / d) % 6)
|
||||
else if (max === gg) h = 60 * ((bb - rr) / d + 2)
|
||||
else h = 60 * ((rr - gg) / d + 4)
|
||||
if (h < 0) h += 360
|
||||
hueValue = h
|
||||
}
|
||||
satValue = max ? d / max : 0
|
||||
valValue = max
|
||||
}
|
||||
const beginDrag = (target, e) => { syncFromColor(); dragSnapped = false; pick(target, e) }
|
||||
if (sv) {
|
||||
sv.addEventListener('pointerdown', e => { sv.setPointerCapture(e.pointerId); beginDrag(sv, e) })
|
||||
sv.addEventListener('pointermove', e => { if (e.buttons) pick(sv, e) })
|
||||
}
|
||||
if (hue) {
|
||||
hue.addEventListener('pointerdown', e => { beginDrag(hue, e) })
|
||||
hue.addEventListener('pointermove', e => { if (e.buttons) pick(hue, e) })
|
||||
}
|
||||
if (sv) { sv.addEventListener('pointerdown', e => { sv.setPointerCapture(e.pointerId); pick(sv, e) }); sv.addEventListener('pointermove', e => { if (e.buttons) pick(sv, e) }) }
|
||||
if (hue) { hue.addEventListener('pointerdown', e => { pick(hue, e) }); hue.addEventListener('pointermove', e => { if (e.buttons) pick(hue, e) }) }
|
||||
}
|
||||
|
||||
/** 裁剪约束控件已迁入选项栏(bindLiteUI 的点击委托统一处理),旧的直连绑定移除。 */
|
||||
@@ -1431,6 +1622,18 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
bindAll('[data-action="addBlankLayer"]', 'click', () => {
|
||||
addBlankLayer()
|
||||
})
|
||||
|
||||
// 图层合并(v1.6):⌘/Ctrl 点击图层多选后可合并;未多选时向下合并
|
||||
bindAll('[data-action="mergeLayers"]', 'mousedown', (e) => e.stopPropagation())
|
||||
bindAll('[data-action="mergeLayers"]', 'click', () => {
|
||||
const r = mergeLayers()
|
||||
toast(r.msg, r.ok ? 'success' : 'warn')
|
||||
})
|
||||
bindAll('[data-action="mergeVisible"]', 'mousedown', (e) => e.stopPropagation())
|
||||
bindAll('[data-action="mergeVisible"]', 'click', () => {
|
||||
const r = mergeVisibleLayers()
|
||||
toast(r.msg, r.ok ? 'success' : 'warn')
|
||||
})
|
||||
}
|
||||
|
||||
/** 底部动作:关闭 / 作为新节点 / 替换(导出入口) */
|
||||
@@ -1487,7 +1690,9 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
if (!S.penPath || S.penPath.pts.length < 2) { S.penPath = null; renderObjects(); return }
|
||||
saveSnapshot()
|
||||
const shape = { id: 's' + Date.now() + Math.floor(Math.random() * 1000), 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 }
|
||||
S.shapeLayers.push(shape); selectUnit('shape', shape.id); S.penPath = null; renderObjects(); renderLayerPanel()
|
||||
// 路径落成即回 V 并选中(v1.5):连续画多条就再按一次 P;节点编辑仍走 V 下双击
|
||||
S.shapeLayers.push(shape); S.penPath = null; renderObjects(); renderLayerPanel()
|
||||
finishCreateTool('shape', shape.id)
|
||||
}
|
||||
|
||||
/** 将 canvas 鼠标事件绑定到活跃图层 canvas(在 setupCanvas 后调用,仅绑定一次) */
|
||||
@@ -1506,53 +1711,14 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
})
|
||||
S.canvasStack.addEventListener('mouseleave', () => {
|
||||
if (S.placingImage) return
|
||||
// 离开画布:笔刷环清掉,同时忘掉悬停点,免得调大小时把环画到旧位置
|
||||
S.hoverPos = null
|
||||
if ((S.tool === 'brush' || S.tool === 'eraser') && !S.isDrawing) clearToolRing()
|
||||
if (S.tool === 'picker') hidePickerTip()
|
||||
})
|
||||
|
||||
// 双击文字 → 重新编辑内容;双击钢笔形状 → 进入节点编辑
|
||||
S.canvasStack.addEventListener('dblclick', (e) => {
|
||||
if (S.placingImage) return
|
||||
const pos = getPos(e)
|
||||
if (S.tool === 'pen' && S.penPath) { commitPenPath(); return }
|
||||
if (S.tool === 'select' || S.tool === 'pen') {
|
||||
const penShape = getPenEditingShape()
|
||||
if (penShape) {
|
||||
// 双击节点 → 删除节点
|
||||
const pi = hitPenPoint(pos, penShape, Math.max(14 / S.zoom, 8))
|
||||
if (pi >= 0) {
|
||||
e.preventDefault()
|
||||
saveSnapshot()
|
||||
const pts = penShape.pts
|
||||
const minPts = penShape.closed ? 3 : 2
|
||||
if (pts.length <= minPts) {
|
||||
removeVecCanvas(penShape)
|
||||
S.shapeLayers = S.shapeLayers.filter(x => x.id !== penShape.id)
|
||||
S.penEditId = null
|
||||
S.selectedShapeId = null
|
||||
} else {
|
||||
pts.splice(pi, 1)
|
||||
if (penShape.closed && pts.length < 3) penShape.closed = false
|
||||
}
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
return
|
||||
}
|
||||
return // 正在编辑:避免误触发新建文字
|
||||
}
|
||||
// 未在编辑:双击命中钢笔形状进入编辑
|
||||
const hitPen = hitShapeLayer(pos, true)
|
||||
if (hitPen && hitPen.type === 'pen') { e.preventDefault(); beginPenEdit(hitPen); return }
|
||||
}
|
||||
if (S.tool !== 'text' && S.tool !== 'select') return
|
||||
const hit = hitTextLayer(pos)
|
||||
if (hit) {
|
||||
selectUnit('text', hit.id)
|
||||
if (hit.locked) return
|
||||
renderObjects()
|
||||
showTextInput(hit.x, hit.y, hit)
|
||||
}
|
||||
})
|
||||
// 双击不再挂 dblclick:画布上它不可靠(选中重绘会换掉命中元素,浏览器干脆不派发)。
|
||||
// 双击语义统一由 onMouseDown → isDoubleClick / onCanvasDoubleClick 处理,见文件上方。
|
||||
}
|
||||
|
||||
// 裁剪手柄 hover 光标
|
||||
@@ -1590,6 +1756,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
S.lastPos = p
|
||||
updateStatusbar()
|
||||
}
|
||||
S.hoverPos = p
|
||||
if (isOverRotationHandle(p)) { S.drawCanvasCursor(ROT_CURSOR); return }
|
||||
const handler = Object.prototype.hasOwnProperty.call(HOVER_HANDLERS, S.tool) ? HOVER_HANDLERS[S.tool] : null
|
||||
if (handler) handler(p, e)
|
||||
@@ -1700,6 +1867,8 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
if (e.key === 'Enter' && S.tool === 'crop' && S.cropRect) { e.preventDefault(); confirmCrop(); return }
|
||||
if (e.key === 'Escape') {
|
||||
if (isTyping(e)) { hideTextInput(); return }
|
||||
// 色板弹层先关:它是最上层的浮层,Esc 应该先收它
|
||||
if (closeColorPop()) { e.preventDefault(); return }
|
||||
// 裁剪优先:有裁剪框时 Esc 取消裁剪
|
||||
if (S.tool === 'crop' && S.cropRect) { e.preventDefault(); cancelCrop(); return }
|
||||
// 选区优先:Esc 一步取消,不进菜单
|
||||
@@ -1769,6 +1938,7 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
S.brushSize = clamp(S.brushSize + (e.key === ']' ? step : -step), 1, 300)
|
||||
syncOptionBar()
|
||||
updateCursor()
|
||||
refreshBrushRing()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1793,6 +1963,14 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
|
||||
if (mod && key === 'j') { e.preventDefault(); runCommand('sel.copy'); return }
|
||||
if (mod && key === 'x' && S.selection && S.selection.active) { e.preventDefault(); runCommand('sel.cut'); return }
|
||||
|
||||
// 图层合并(PS 习惯):Ctrl+E 合并(多选优先,否则向下合并)/ Ctrl+Shift+E 合并可见
|
||||
if (mod && key === 'e') {
|
||||
e.preventDefault()
|
||||
const r = e.shiftKey ? mergeVisibleLayers() : mergeLayers()
|
||||
toast(r.msg, r.ok ? 'success' : 'warn')
|
||||
return
|
||||
}
|
||||
|
||||
// 文件类:Ctrl+Shift+N 新建图层 / Ctrl+O 导入图片 / Ctrl+S 导出下载
|
||||
if (mod && e.shiftKey && key === 'n') {
|
||||
e.preventDefault()
|
||||
|
||||
@@ -251,6 +251,7 @@ import { toast } from './commands.js'
|
||||
S.bitmapDrag = null
|
||||
S.penPath = null
|
||||
S.penEditId = null
|
||||
S.layerMulti.length = 0
|
||||
// 撤销不动选区:选区是「视图状态」,不是像素状态,避免 Ctrl+Z 后框消失还要重画
|
||||
reorderLayerCanvas()
|
||||
updateLayerCanvasStyles()
|
||||
@@ -344,6 +345,7 @@ import { toast } from './commands.js'
|
||||
S.bitmapDrag = null
|
||||
S.penPath = null
|
||||
S.penEditId = null
|
||||
S.layerMulti.length = 0
|
||||
S.cropRect = null
|
||||
S.cropHandle = null
|
||||
S.cropMoving = false
|
||||
|
||||
@@ -294,8 +294,10 @@ import { toast } from './commands.js'
|
||||
texts: S.textLayers.map(t => ({ id: t.id, text: t.text })),
|
||||
selectedShapeId: S.selectedShapeId,
|
||||
selectedTextId: S.selectedTextId,
|
||||
penEditId: S.penEditId,
|
||||
activeLayerId: S.activeLayerId,
|
||||
selectedLayerId: S.selectedLayerId,
|
||||
layerMulti: S.layerMulti.map(x => x.type + ':' + x.id),
|
||||
selection: selectionInfo(),
|
||||
toolOptions: {
|
||||
brushSize: S.brushSize,
|
||||
@@ -318,6 +320,19 @@ import { toast } from './commands.js'
|
||||
const l = S.layers.find(v => v.id === id)
|
||||
if (!l || !l.ctx) return null
|
||||
try { return Array.from(l.ctx.getImageData(Math.round(x), Math.round(y), 1, 1).data) } catch (e) { return null }
|
||||
},
|
||||
// 区域透明像素统计:断言「合并后两半都有内容」比逐点采样快一个量级
|
||||
alphaIn: (id, x0, y0, x1, y1) => {
|
||||
const l = S.layers.find(v => v.id === id)
|
||||
if (!l || !l.ctx) return 0
|
||||
try {
|
||||
const w = Math.max(1, Math.round(x1 - x0))
|
||||
const h = Math.max(1, Math.round(y1 - y0))
|
||||
const d = l.ctx.getImageData(Math.round(x0), Math.round(y0), w, h).data
|
||||
let n = 0
|
||||
for (let i = 3; i < d.length; i += 4) if (d[i] > 0) n++
|
||||
return n
|
||||
} catch (e) { return 0 }
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import { boxCorners, clamp, drawRotationHandles, hitRotationHandle, rotPt, unrot
|
||||
import { drawShape } from './tools.js'
|
||||
import { saveSnapshot, snapshotState } from './history.js'
|
||||
import { placeImageDirectly } from './placement.js'
|
||||
import { updateBrushParamUI, updateColorUI } from './events.js'
|
||||
import { updateBrushParamUI, updateColorUI, refreshBrushRing } from './events.js'
|
||||
import { isDrawableLayer } from '../vendor/layer-logic.js'
|
||||
|
||||
|
||||
@@ -505,9 +505,17 @@ export function setActiveLayer(id) {
|
||||
const list = runtime.el.querySelector('.iwb-editor-layer-list')
|
||||
if (!list) return
|
||||
|
||||
// 先剔除已不存在的多选项(图层被删 / 已被合并),避免面板留着看不见的选择
|
||||
if (S.layerMulti.length) {
|
||||
const alive = new Set(layerUnits().map(u => u.kind + ':' + u.obj.id))
|
||||
S.layerMulti = S.layerMulti.filter(r => alive.has(r.type + ':' + r.id))
|
||||
}
|
||||
|
||||
// 面板顺序直接取统一 z 序的倒序(与画布叠放完全一致)。
|
||||
// 旧实现位图用 S.layers 数组序、矢量用 allObjects() 再 sort,z 相同时两者次序相反。
|
||||
const items = []
|
||||
// 多选集合(⌘/Ctrl 点击累积):只影响「合并」目标,不抢单选高亮
|
||||
const multiSet = new Set(S.layerMulti.map(x => x.type + ':' + x.id))
|
||||
for (const { kind, obj } of layerUnitsDesc()) {
|
||||
if (kind === 'bitmap') {
|
||||
items.push({
|
||||
@@ -516,6 +524,7 @@ export function setActiveLayer(id) {
|
||||
color: obj.color || S.color, lineWidth: obj.lineWidth || S.brushSize,
|
||||
// 高亮只代表「选中」;画笔作用目标独立用 ✎ 标记,避免两个图层同时亮
|
||||
active: obj.id === S.selectedLayerId,
|
||||
multi: multiSet.has('bitmap:' + obj.id),
|
||||
paintTarget: obj.id === S.activeLayerId,
|
||||
locked: !!obj.locked, canDelete: S.layers.length > 1
|
||||
})
|
||||
@@ -527,6 +536,7 @@ export function setActiveLayer(id) {
|
||||
visible: obj.visible !== false, z: obj.z || 0,
|
||||
color: obj.color || S.color, lineWidth: obj.lw || S.brushSize,
|
||||
active: (kind === 'text' && obj.id === S.selectedTextId) || (kind === 'shape' && obj.id === S.selectedShapeId),
|
||||
multi: multiSet.has(kind + ':' + obj.id),
|
||||
paintTarget: false, locked: !!obj.locked, canDelete: true
|
||||
})
|
||||
}
|
||||
@@ -535,6 +545,7 @@ export function setActiveLayer(id) {
|
||||
let html = ''
|
||||
for (const item of items) {
|
||||
const activeClass = item.active ? ' active' : ''
|
||||
const multiClass = item.multi ? ' multi' : ''
|
||||
const visClass = item.visible ? '' : ' hidden'
|
||||
// SVG 图标
|
||||
let typeIconSvg = ''
|
||||
@@ -554,7 +565,7 @@ export function setActiveLayer(id) {
|
||||
? '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="10" width="14" height="10" rx="2"/><path d="M8 10V7a4 4 0 0 1 8 0v3"/></svg>'
|
||||
: '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="10" width="14" height="10" rx="2"/><path d="M8 10V7a4 4 0 0 1 7-2"/></svg>'
|
||||
const delSvg = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>'
|
||||
html += `<div class="iwb-layer-item${activeClass}${visClass}" draggable="${item.id !== 'base'}" data-layer-id="${item.id}" data-layer-type="${item.type}">
|
||||
html += `<div class="iwb-layer-item${activeClass}${multiClass}${visClass}" draggable="${item.id !== 'base'}" data-layer-id="${item.id}" data-layer-type="${item.type}">
|
||||
<button class="iwb-layer-vis" data-vis-id="${item.id}" data-vis-type="${item.type}" title="${item.visible ? '隐藏' : '显示'}">${visSvg}</button>
|
||||
<span class="iwb-layer-icon">${typeIconSvg}</span>
|
||||
<span class="iwb-layer-name">${item.name}</span>${item.paintTarget ? '<span class="iwb-layer-paint" title="当前画笔 / 橡皮作用图层">✎</span>' : ''}
|
||||
@@ -566,6 +577,17 @@ export function setActiveLayer(id) {
|
||||
}
|
||||
list.innerHTML = html
|
||||
|
||||
// 侧栏「快速效果」的目标层名:效果和画笔共用同一个目标层,这里一起刷,
|
||||
// 免得切层后标签还停在上一个图层名上。
|
||||
const fxTarget = runtime.el.querySelector('.iwb-editor-fx-target')
|
||||
if (fxTarget) {
|
||||
const active = getActiveLayer()
|
||||
fxTarget.textContent = active ? active.name : '无图层'
|
||||
fxTarget.title = active
|
||||
? '效果作用于当前位图图层:' + active.name + '(切换图层可改变目标)'
|
||||
: '当前没有可处理的位图图层'
|
||||
}
|
||||
|
||||
// 绑定图层面板事件
|
||||
bindLayerPanelEvents()
|
||||
}
|
||||
@@ -615,6 +637,15 @@ export function setActiveLayer(id) {
|
||||
if (e.target.closest('.iwb-layer-vis') || e.target.closest('.iwb-layer-lock') || e.target.closest('.iwb-layer-del')) return
|
||||
const id = item.dataset.layerId
|
||||
const type = item.dataset.layerType
|
||||
// ⌘/Ctrl 点击:加入/移出合并集合(不改变画笔目标与单选高亮)
|
||||
if (e.metaKey || e.ctrlKey) {
|
||||
e.preventDefault()
|
||||
toggleLayerMulti(type, id)
|
||||
renderLayerPanel()
|
||||
return
|
||||
}
|
||||
// 普通点击回到单选语义:先把合并集合清掉,避免留下看不见的选择
|
||||
if (S.layerMulti.length) S.layerMulti.length = 0
|
||||
if (type === 'bitmap') {
|
||||
setActiveLayer(id)
|
||||
} else if (type === 'text' || type === 'shape') {
|
||||
@@ -647,7 +678,7 @@ export function setActiveLayer(id) {
|
||||
const type = input.dataset.widthType
|
||||
const value = clamp(parseInt(input.value, 10) || 1, 1, 300)
|
||||
const obj = type === 'bitmap' ? S.layers.find(l => l.id === id) : S.shapeLayers.find(s => s.id === id)
|
||||
if (obj) { obj.lineWidth = value; if (type === 'shape') obj.lw = value; else S.brushSize = value; renderObjects(); updateBrushParamUI(); renderLayerPanel() }
|
||||
if (obj) { obj.lineWidth = value; if (type === 'shape') obj.lw = value; else { S.brushSize = value; refreshBrushRing() } renderObjects(); updateBrushParamUI(); renderLayerPanel() }
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -716,3 +747,195 @@ export function setActiveLayer(id) {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// ============ 图层合并(v1.6,用户裁定) ============
|
||||
|
||||
const multiKey = (type, id) => type + ':' + id
|
||||
|
||||
/** 当前单选的是哪个单元(多选的起点);没有选中返回 null */
|
||||
function currentUnitRef() {
|
||||
if (S.selectedLayerId) return { type: 'bitmap', id: S.selectedLayerId }
|
||||
if (S.selectedTextId) return { type: 'text', id: S.selectedTextId }
|
||||
if (S.selectedShapeId) return { type: 'shape', id: S.selectedShapeId }
|
||||
return null
|
||||
}
|
||||
|
||||
/** ⌘/Ctrl 点击图层项:加入或移出「合并集合」。
|
||||
* 第一次加选时把当前单选层一起纳入,符合「先选一层再按住 ⌘ 加选」的习惯。 */
|
||||
export function toggleLayerMulti(type, id) {
|
||||
const key = multiKey(type, id)
|
||||
const i = S.layerMulti.findIndex(x => multiKey(x.type, x.id) === key)
|
||||
if (i >= 0) { S.layerMulti.splice(i, 1); return }
|
||||
if (!S.layerMulti.length) {
|
||||
const cur = currentUnitRef()
|
||||
if (cur && multiKey(cur.type, cur.id) !== key) S.layerMulti.push(cur)
|
||||
}
|
||||
S.layerMulti.push({ type, id })
|
||||
}
|
||||
|
||||
export function clearLayerMulti() { S.layerMulti.length = 0 }
|
||||
|
||||
/** 把一组单元按 z 从低到高叠进目标位图层的像素。
|
||||
* alpha 规则与 getCompositeCanvas(导出/吸管)保持一致,保证「合并后看到的就是导出结果」。 */
|
||||
function composeUnitsInto(layer, units) {
|
||||
const tmp = document.createElement('canvas')
|
||||
tmp.width = S.imgW
|
||||
tmp.height = S.imgH
|
||||
const tctx = tmp.getContext('2d')
|
||||
for (const u of units) {
|
||||
const el = u.kind === 'bitmap' ? u.obj.canvas : u.obj._canvas
|
||||
if (!el || el.nodeType !== 1) continue
|
||||
tctx.globalAlpha = u.obj.opacity == null ? 1 : u.obj.opacity
|
||||
tctx.drawImage(el, 0, 0)
|
||||
}
|
||||
tctx.globalAlpha = 1
|
||||
// 图层 ctx 平时带视图变换,写像素必须回到设备坐标;copy 一并覆盖透明区域
|
||||
const ctx = layer.ctx
|
||||
ctx.save()
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
ctx.globalAlpha = 1
|
||||
ctx.globalCompositeOperation = 'copy'
|
||||
ctx.filter = 'none'
|
||||
ctx.drawImage(tmp, 0, 0)
|
||||
ctx.restore()
|
||||
}
|
||||
|
||||
/** 删除一个图层单元:位图连 DOM 画布一起释放,矢量移除自己的画布 */
|
||||
function dropUnit(u) {
|
||||
if (u.kind === 'bitmap') {
|
||||
const i = S.layers.indexOf(u.obj)
|
||||
if (i >= 0) S.layers.splice(i, 1)
|
||||
try {
|
||||
if (u.obj.canvas && u.obj.canvas.parentNode) u.obj.canvas.parentNode.removeChild(u.obj.canvas)
|
||||
} catch (e) { /* 单个图层释放失败不阻断合并 */ }
|
||||
} else if (u.kind === 'text') {
|
||||
S.textLayers = S.textLayers.filter(t => t !== u.obj)
|
||||
removeVecCanvas(u.obj)
|
||||
} else if (u.kind === 'shape') {
|
||||
S.shapeLayers = S.shapeLayers.filter(s => s !== u.obj)
|
||||
removeVecCanvas(u.obj)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 把若干单元合成一张位图,并删掉参与合并的单元。
|
||||
*
|
||||
* 有「原图(base)」参与时写回 base 本身:base 的快照走 pixels 路径,撤销能原样恢复,
|
||||
* 而且「还原原图」永远有锚点可回。其余情况新建一张普通位图承载 —— 导入图片层走
|
||||
* image 重绘路径,如果原地改像素再清掉 image,撤销时 history 的 restorePath 会按
|
||||
* 「像素」去读一份根本没拍的快照(详见 history.js 的注释),像素就丢了。
|
||||
*/
|
||||
function mergeUnits(units) {
|
||||
const sorted = units.slice().sort((a, b) => (a.obj.z || 0) - (b.obj.z || 0))
|
||||
const lowUnit = sorted[0]
|
||||
const baseUnit = sorted.find(u => u.kind === 'bitmap' && u.obj.id === 'base')
|
||||
// 结果层要落回「原最低层」的位置:先数清它下面还有几个不参与合并的层
|
||||
const all = layerUnits()
|
||||
const lowIdx = all.findIndex(u => u.obj === lowUnit.obj)
|
||||
const chosenSet = new Set(sorted.map(u => u.obj))
|
||||
const insertAt = all.slice(0, Math.max(lowIdx, 0)).filter(u => !chosenSet.has(u.obj)).length
|
||||
|
||||
let carrier
|
||||
if (baseUnit) {
|
||||
carrier = baseUnit.obj
|
||||
// 合并后它就是纯像素层:断掉 image/sourceCanvas,避免后续按原图重新重绘
|
||||
carrier.image = null
|
||||
carrier.sourceCanvas = null
|
||||
carrier._srcBox = null
|
||||
carrier.transformable = false
|
||||
carrier.x = 0
|
||||
carrier.y = 0
|
||||
carrier.w = S.imgW
|
||||
carrier.h = S.imgH
|
||||
carrier.rotation = 0
|
||||
carrier.visible = true
|
||||
carrier.opacity = 1
|
||||
carrier._bounds = undefined
|
||||
composeUnitsInto(carrier, sorted)
|
||||
for (const u of sorted) if (u.obj !== carrier) dropUnit(u)
|
||||
// base 永远压在最底,其余层保持原有相对顺序
|
||||
const rest = layerUnits().filter(u => u.obj !== carrier)
|
||||
rest.unshift({ kind: 'bitmap', obj: carrier })
|
||||
assignLayerZ(rest)
|
||||
} else {
|
||||
const canvas = createLayerCanvas()
|
||||
const ctx = canvas.getContext('2d', { willReadFrequently: true })
|
||||
carrier = {
|
||||
id: 'm' + Date.now() + Math.floor(Math.random() * 1000),
|
||||
name: lowUnit.obj.name || '合并图层',
|
||||
canvas,
|
||||
ctx,
|
||||
opacity: 1,
|
||||
visible: true,
|
||||
locked: false,
|
||||
x: 0, y: 0, w: S.imgW, h: S.imgH,
|
||||
rotation: 0,
|
||||
z: lowUnit.obj.z || 0
|
||||
}
|
||||
composeUnitsInto(carrier, sorted)
|
||||
for (const u of sorted) dropUnit(u)
|
||||
S.layers.push(carrier)
|
||||
// carrier 已在 layerUnits() 里,先排掉再按原最低层的位置插回去 —— 否则同一个对象会被计两次 z
|
||||
const rest = layerUnits().filter(u => u.obj !== carrier)
|
||||
rest.splice(Math.min(insertAt, rest.length), 0, { kind: 'bitmap', obj: carrier })
|
||||
assignLayerZ(rest)
|
||||
}
|
||||
|
||||
S.activeLayerId = carrier.id
|
||||
S.selectedLayerId = carrier.id
|
||||
S.selectedTextId = null
|
||||
S.selectedShapeId = null
|
||||
S.textDrag = null
|
||||
S.shapeDrag = null
|
||||
S.bitmapDrag = null
|
||||
S.layerMulti.length = 0
|
||||
S.pickerComposite = null
|
||||
sortLayersByZ()
|
||||
reorderLayerCanvas()
|
||||
updateLayerCanvasStyles()
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
if (S.renderAll) S.renderAll()
|
||||
return carrier
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并图层(Ctrl/⌘+E)
|
||||
* - 图层列表里有 2 个以上多选(⌘/Ctrl 点击)→ 合并这些图层
|
||||
* - 否则 → 「向下合并」:当前层合进下面一层,结果继承下层名字与位置
|
||||
* 隐藏层不参与合并、原样保留(看不见的内容不该被烘进结果)。
|
||||
*/
|
||||
export function mergeLayers() {
|
||||
const units = layerUnits()
|
||||
if (units.length < 2) return { ok: false, msg: '只有一个图层,没有可合并的对象' }
|
||||
|
||||
let chosen
|
||||
if (S.layerMulti.length >= 2) {
|
||||
chosen = units.filter(u => S.layerMulti.some(r => r.type === u.kind && r.id === u.obj.id))
|
||||
if (chosen.length < 2) return { ok: false, msg: '先选两个以上图层(⌘/Ctrl 点击图层列表)' }
|
||||
} else {
|
||||
const cur = currentUnitRef()
|
||||
const idx = cur ? units.findIndex(u => u.kind === cur.type && u.obj.id === cur.id) : -1
|
||||
if (idx < 0) return { ok: false, msg: '先在图层列表里选中一层' }
|
||||
if (idx === 0) return { ok: false, msg: '已经是最底层,没有可合并的下一层' }
|
||||
chosen = [units[idx - 1], units[idx]]
|
||||
if (chosen[1].obj.visible === false) return { ok: false, msg: '当前层已隐藏,先显示再合并' }
|
||||
if (chosen[0].obj.visible === false) return { ok: false, msg: '下一层已隐藏,先显示再合并' }
|
||||
}
|
||||
|
||||
const visible = chosen.filter(u => u.obj.visible !== false)
|
||||
if (visible.length < 2) return { ok: false, msg: '可见图层不足 2 个,没有可合并的内容' }
|
||||
|
||||
saveSnapshot('合并图层')
|
||||
mergeUnits(visible)
|
||||
return { ok: true, msg: '已合并 ' + visible.length + ' 个图层 · Ctrl+Z 撤销' }
|
||||
}
|
||||
|
||||
/** 合并可见图层(Ctrl/⌘+Shift+E):隐藏层保留不动 */
|
||||
export function mergeVisibleLayers() {
|
||||
const visible = layerUnits().filter(u => u.obj.visible !== false)
|
||||
if (visible.length < 2) return { ok: false, msg: '可见图层不足 2 个,没有可合并的对象' }
|
||||
saveSnapshot('合并可见图层')
|
||||
mergeUnits(visible)
|
||||
return { ok: true, msg: '已合并 ' + visible.length + ' 个可见图层 · Ctrl+Z 撤销' }
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import { boxCorners, clamp, drawRotationHandles, hitRotationHandle, rotPt, unrot
|
||||
import { clearOverlay, drawCropPreview } from './crop.js'
|
||||
import { drawBitmapSelection, drawVectorToCanvas, hitBitmapAt, removeVecCanvas, renderLayerPanel, reorderLayerCanvas } from './layers.js'
|
||||
import { drawPlacementPreview } from './placement.js'
|
||||
import { drawShape } from './tools.js'
|
||||
import { drawShape, setTool } from './tools.js'
|
||||
import { saveSnapshot, snapshotState } from './history.js'
|
||||
import { toast } from './commands.js'
|
||||
import { renderOptionBar, updateLayerUI } from './events.js'
|
||||
@@ -170,6 +170,8 @@ import { isDrawableLayer } from '../vendor/layer-logic.js'
|
||||
}
|
||||
/** 选中态唯一入口:四个 id 一起写,杜绝「两个图层同时高亮 / 排序作用错对象」 */
|
||||
export function selectUnit(kind, id) {
|
||||
// 单选变了就退出「合并多选」:两套选择同时留着会让面板出现说不清的多个高亮
|
||||
S.layerMulti.length = 0
|
||||
S.selectedLayerId = kind === 'bitmap' ? id : null
|
||||
S.selectedTextId = kind === 'text' ? id : null
|
||||
S.selectedShapeId = kind === 'shape' ? id : null
|
||||
@@ -639,6 +641,22 @@ import { isDrawableLayer } from '../vendor/layer-logic.js'
|
||||
committed = true
|
||||
}
|
||||
hideTextInput()
|
||||
// 文字落成即回 V 并选中(用户 2026-11-05):输入完下一步通常是挪位置 / 改字号颜色。
|
||||
// 必须延后一个微任务 —— setTool 第一行就是 commitTextInput(),同步调用会自我递归。
|
||||
// 延后期间若又开了新输入框(在 T 下连续点着输入),就不要把工具抢走。
|
||||
if (committed) {
|
||||
const id = S.selectedTextId
|
||||
queueMicrotask(() => {
|
||||
if (S.tool !== 'text') return
|
||||
const box = runtime.el && runtime.el.querySelector('.iwb-editor-text-input')
|
||||
if (box && box.style.display !== 'none') return
|
||||
setTool('select')
|
||||
if (!id) return
|
||||
selectUnit('text', id)
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
})
|
||||
}
|
||||
return committed
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
brushHardness: 100, // 画笔硬度 0~100:100=硬边描边,<100=径向渐变软边章
|
||||
brushOpacity: 1, // 画笔透明度 0.05~1(一笔整体透明度,笔划内不叠加)
|
||||
prevTool: null, // 吸管工具激活前的工具(取色后切回)
|
||||
// 画布内最后一次悬停点(图片坐标):用 [ ] 调笔刷大小时要按这个点立刻重画笔刷环,
|
||||
// 否则光标环会停在旧尺寸,直到用户再动一下鼠标才更新(v1.6)
|
||||
hoverPos: null,
|
||||
lastClick: null, // 上一次画布按下 {t,x,y}:自算双击用(dblclick 在画布上不可靠)
|
||||
altPicker: false, // 按住 Alt 的临时吸管(画笔/橡皮下),松开 Alt 回到原工具
|
||||
pickerComposite: null, // 吸管取样用的合成画布缓存(切工具/画布变化时失效)
|
||||
rectFill: false, // 矩形/圆形是否实心填充
|
||||
@@ -57,6 +61,9 @@
|
||||
textDrag: null, // { mode:'move'|'scale', start:{x,y}, layer:{x,y}, fontSize, baseX }
|
||||
textEditingId: null,
|
||||
selectedLayerId: null, // 选择工具当前选中的可编辑位图图层
|
||||
// 图层多选集合 [{id,type}](v1.6):只为「合并选中图层」服务,
|
||||
// 不参与单选语义(selectedLayerId / selectedTextId 仍各管各的)。
|
||||
layerMulti: [],
|
||||
bitmapDrag: null, // { mode:'move'|'scale', handle, start, layer, pending }
|
||||
// 形状图层(矩形/箭头,独立对象,可选中/移动/调手柄)
|
||||
shapeLayers: [], // [{ id, type:'rect'|'arrow', x1,y1,x2,y2, color, lw, fill, opacity, visible, z }]
|
||||
|
||||
@@ -332,9 +332,12 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
S.prevTool = null
|
||||
// 回到的若不是选择/形状类工具,选中态按 setTool 同一套规则清掉,避免画布残留选中框
|
||||
const back = S.tool
|
||||
if (back !== 'select') S.selectedLayerId = null
|
||||
if (back !== 'text' && back !== 'select') S.selectedTextId = null
|
||||
if (back !== 'rect' && back !== 'circle' && back !== 'arrow' && back !== 'pen' && back !== 'select') S.selectedShapeId = null
|
||||
// 与 setTool 同一套规则(v1.3):只有选择工具保留选中态
|
||||
if (back !== 'select') {
|
||||
S.selectedLayerId = null
|
||||
S.selectedTextId = null
|
||||
S.selectedShapeId = null
|
||||
}
|
||||
S.pickerComposite = null
|
||||
hidePickerTip()
|
||||
updateToolUI()
|
||||
@@ -370,18 +373,22 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
exitPicker()
|
||||
}
|
||||
|
||||
/** 统一颜色应用:设置当前色 + 同步选中文字/形状颜色 */ export function applyColorChange(color) {
|
||||
/** 统一颜色应用:设置当前色 + 同步选中文字/形状颜色。
|
||||
* opts.skipHistory:连续取色(拖 SV/色相条)时由调用方在拖动开始时已拍过快照,
|
||||
* 这里不再逐步 saveSnapshot —— 否则拖一下就是几百张全画质 ImageData。 */
|
||||
export function applyColorChange(color, opts) {
|
||||
const skipHistory = !!(opts && opts.skipHistory)
|
||||
S.color = color
|
||||
updateColorUI()
|
||||
const t = getSelectedText()
|
||||
if (t && !t.locked && t.color !== S.color) {
|
||||
saveSnapshot()
|
||||
if (!skipHistory) saveSnapshot()
|
||||
t.color = S.color
|
||||
renderObjects()
|
||||
}
|
||||
const sh = getSelectedShape()
|
||||
if (sh && !sh.locked && S.tool !== 'text' && sh.color !== S.color) {
|
||||
saveSnapshot()
|
||||
if (!skipHistory) saveSnapshot()
|
||||
sh.color = S.color
|
||||
renderObjects()
|
||||
}
|
||||
@@ -393,7 +400,9 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
commitTextInput()
|
||||
// 用户主动切到别的工具 = 放弃「按住 Alt 临时吸管」,否则松 Alt 会把工具抢回去
|
||||
if (tool !== 'picker') S.altPicker = false
|
||||
if (tool !== 'select' && tool !== 'pen') { S.penEditId = null; S.penDragPt = -1; S.penDragPending = null }
|
||||
// 钢笔节点编辑与文字编辑都只属于 V(v1.5):切到任何创建类工具都退出编辑态,
|
||||
// 否则从 V 带着 penEditId 切到 P 会出现「钢笔下能拖节点但点不动」的半状态。
|
||||
if (tool !== 'select') { S.penEditId = null; S.penDragPt = -1; S.penDragPending = null }
|
||||
if (tool === 'picker' && S.tool !== 'picker') S.prevTool = S.tool
|
||||
if (tool !== 'pen') S.penPath = null
|
||||
// 选区与裁剪互斥:进裁剪必须清掉选区;离开选区工具要丢弃未完成的拉框/套索
|
||||
@@ -406,14 +415,20 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
S.tool = tool
|
||||
// 吸管是临时取色工具:必须保留选中态,否则「选中形状 → 按 I 取色」时选中被清掉,
|
||||
// applyColorChange 找不到对象,颜色只写进画笔色、形状不变(用户反馈 2026-11-04)
|
||||
// 选中态只属于「选择(V)」与临时吸管(v1.3,用户裁定 2026-11-05):
|
||||
// 矩形/圆形/箭头/钢笔/文字都只负责新建,切过去就清掉选中 ——
|
||||
// 否则矢量工具下点到已有图形会被当成拖动它,没法在它上面继续画。
|
||||
const keepSel = tool === 'select' || tool === 'picker'
|
||||
if (!keepSel) S.selectedLayerId = null
|
||||
if (tool !== 'text' && !keepSel) S.selectedTextId = null
|
||||
if (tool !== 'rect' && tool !== 'circle' && tool !== 'arrow' && tool !== 'pen' && !keepSel) S.selectedShapeId = null
|
||||
if (!keepSel) {
|
||||
S.selectedLayerId = null
|
||||
S.selectedTextId = null
|
||||
S.selectedShapeId = null
|
||||
}
|
||||
S.bitmapDrag = null
|
||||
S.textDrag = null
|
||||
S.shapeDrag = null
|
||||
S.pickerComposite = null
|
||||
S.lastClick = null // 切工具即断掉双击序列,避免拿上一个工具的最后一次点击配对
|
||||
hidePickerTip()
|
||||
updateToolUI()
|
||||
updateBrushParamUI()
|
||||
|
||||
Reference in new issue
Block a user