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

+46
View File
@@ -1757,6 +1757,13 @@
.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; }
/* v1.8:当前生效的效果。必须与 hover 一眼区分 —— 拖动强度滑杆时要能看出在调哪个效果 */
.iwb-editor-fx-btn.is-active {
background: #2c2735; border-color: #e8a735; color: #f3dcb0;
}
.iwb-editor-fx-btn.is-active .iwb-editor-fx-ico {
box-shadow: inset 0 0 0 1px rgba(232, 167, 53, 0.75);
}
.iwb-editor-fx-ico {
width: 22px; height: 22px; border-radius: 5px; display: block;
background-color: #d9d9e3;
@@ -1780,6 +1787,45 @@
margin: 0; font-size: 10px; line-height: 1.55; color: #6c7086;
}
/* v1.8:效果参数滑杆。范围与单位随效果切换(马赛克=块大小 px、柔化=半径 px、其余=强度 %)。
未点效果 / 目标层被切走时加 .iwb-editor-fx-adj-off 整条置灰。 */
.iwb-editor-fx-adj {
display: flex; flex-direction: column; gap: 4px;
padding: 6px 8px 5px; border-radius: 7px;
background: #1e1e2c; border: 1px solid #2f2f42;
transition: opacity 0.12s ease;
}
.iwb-editor-fx-adj-head {
display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.iwb-editor-fx-adj-name {
font-size: 10.5px; font-weight: 500; color: #b9c0d8;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.iwb-editor-fx-adj-val {
font-size: 10.5px; color: #e8a735; font-variant-numeric: tabular-nums; flex: 0 0 auto;
}
.iwb-editor-fx-adj-off { opacity: 0.5; }
.iwb-editor-fx-range {
-webkit-appearance: none; appearance: none;
width: 100%; height: 14px; margin: 0; background: transparent; cursor: pointer;
}
.iwb-editor-fx-range::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: #313244; }
.iwb-editor-fx-range::-webkit-slider-thumb {
-webkit-appearance: none; appearance: none;
width: 12px; height: 12px; margin-top: -4px; border-radius: 50%;
background: #e8a735; border: 1px solid #1e1e2c;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
.iwb-editor-fx-range::-moz-range-track { height: 4px; border-radius: 2px; background: #313244; }
.iwb-editor-fx-range::-moz-range-thumb {
width: 12px; height: 12px; border-radius: 50%; background: #e8a735; border: 1px solid #1e1e2c;
}
.iwb-editor-fx-range:disabled { cursor: default; }
.iwb-editor-fx-range:disabled::-webkit-slider-thumb { background: #585b70; }
.iwb-editor-fx-range:disabled::-moz-range-thumb { background: #585b70; }
.iwb-editor-fx-range:focus-visible { outline: 2px solid #89b4fa; outline-offset: 2px; }
/* ================================================================
v1.6:图层面板多选(⌘/Ctrl 点击)+ 合并按钮
多选用青色侧条与单选(橙色 #e8a735)区分:一个图层可以「被选中但不在合并集合里」,
+9 -1
View File
@@ -194,7 +194,15 @@ import { bindEvents } from './events.js'
<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">
+192 -25
View File
@@ -1,4 +1,4 @@
/* effects.js - 侧栏「快速效果」(v1.4)
/* effects.js - 侧栏「快速效果」(v1.4,v1.8 加可调参数)
*
* 作用对象只有一个:当前位图图层(侧栏标题后面实时显示层名)。
* 全部走 canvas 2D 的 ctx.filter / 缩放重采样,不引入依赖、不动矢量层、
@@ -7,38 +7,82 @@
* 撤销:应用前 saveSnapshot()。base 与画笔层走像素快照(putImageData),
* 天然可回退;导入图片层走 image/sourceCanvas 重绘,原地改像素会被下一次
* 重绘冲掉,所以先按 PS「栅格化」的做法落一个普通位图副本(原层隐藏)。
*
* v1.8 可调参数的关键设计:**效果不能叠加在自身结果上**。
* 点效果时把目标层当时的像素备份进 S.fx.source,之后拖滑杆一律「先还原 source
* 再按新参数渲染」。否则「马赛克 12px → 40px → 12px」会变成三次采样、块越来
* 越碎且不可逆。历史粒度也因此干净:点效果拍一次快照,拖滑杆不再拍。
*/
'use strict'
import { S } from './state.js'
import { S, runtime } 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_MIN = 1.2
const SOFT_MAX = 8
function softRadius(canvas) {
// 默认半径跟短边走:800px 图 ≈2px(v1.4 是 1.6px,小图上几乎看不出模糊,
// 现在有了滑杆可自己拉,但默认值也要先看得出效果)
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))
}
/**
* 效果表。参数语义分两类:
* unit '%' → 强度 0~100,0 等于不处理(invert/grayscale 原生支持比例)
* unit 'px' → 物理量(马赛克块边长 / 模糊半径),默认值按图短边缩放
* def 是函数:px 类要拿到 canvas 才能算默认值。
*/
export const 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) }
}
}
/** 效果目标:当前活跃位图图层;没有就退回「原图」 */
export function effectTarget() {
const active = getActiveLayer()
@@ -72,8 +116,9 @@ import { toast } from './commands.js'
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
@@ -92,6 +137,16 @@ import { toast } from './commands.js'
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
}
/**
* 把「导入图片层」栅格化成普通位图,插在它上面一层。
* 只拷当前 canvas 的可见结果(已含旋转/缩放),所以视觉不变。
@@ -132,7 +187,86 @@ import { toast } from './commands.js'
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 = undefined
S.pickerComposite = null
}
/** 数值展示:px 保留到 0.5(柔化),百分比取整 */
function fmtValue(fx, v) {
if (fx.unit === 'px') return (Math.round(v * 10) / 10) + ' px'
return Math.round(v) + '%'
}
/**
* 刷新侧栏「强度」这一条:滑杆范围随效果切换,目标层对不上时置灰。
* 切图层后源属于旧层,此时拖动会把旧像素写进新层 —— 所以必须靠 layerId 拦住。
* 切回原层自动恢复可用(源还在)。
*/
export 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()
// 当前生效的效果按钮高亮:面板是静态 DOM,只同步类名,不重建
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 + '」,切回该层可继续调整'
}
}
/** 唯一入口:应用一个效果(同层同效果再点 = 重置回默认参数,不叠加) */
export function applyQuickEffect(key) {
const fx = QUICK_EFFECTS[key]
if (!fx) return false
@@ -143,19 +277,52 @@ import { toast } from './commands.js'
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))
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)
// 基准必须是「应用前」的像素:saveSnapshot 只写历史,不改画布,所以这里拍
S.fx = { key, layerId: target.id, source: snapshotCanvas(target.canvas), value: fx.def(target.canvas) }
renderFromSource(target, key, S.fx.value)
target._bounds = undefined
S.pickerComposite = null
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
}
/**
* 拖动强度滑杆。不拍快照(历史粒度 = 一次效果操作),也不重建图层面板
* (拖动中每帧 innerHTML 会闪,缩略图交给松开后的 renderAll 刷新)。
*/
export 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
}
+17 -1
View File
@@ -19,7 +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 { applyQuickEffect, setEffectValue } from './effects.js'
import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
@@ -1245,6 +1245,22 @@ import { hexToRgb, parseRatio, rgbToHex } from '../vendor/image-math.js'
})
})
// 快速效果强度滑杆(v1.8):input 只改像素与该行数字 —— 拖动中每帧重建图层面板会闪,
// 缩略图与状态栏交给松开时的 renderAll。用 class 精确匹配,别误伤图层不透明度滑杆。
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())
+38
View File
@@ -35,6 +35,7 @@ import { setupCanvas } from './viewport.js'
import { updateAllUI, bindLiteUI, renderOptionBar, updateStatusbar } from './events.js'
import { disposeSelection, renderSelection, selectionInfo, syncAnts, registerSelectionCommands } from './selection.js'
import { bindFloating, positionFloating, hideSelectionContext } from './floating.js'
import { renderFxPanel } from './effects.js'
import { loadExportOptions, prepareOutput, downloadBlob, bindExportUI, renderExportUI } from './export.js'
import { toast } from './commands.js'
@@ -46,6 +47,7 @@ import { toast } from './commands.js'
// 命令层 / 蚂蚁线的渲染出口走注入,避免新模块与 events.js 形成顶层求值循环
S.renderAll = renderAll
S.positionFloating = positionFloating
S.renderFxPanel = renderFxPanel
try {
const img = await loadImage(options.imageBase64)
@@ -119,6 +121,8 @@ import { toast } from './commands.js'
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
@@ -147,6 +151,7 @@ import { toast } from './commands.js'
if (!S.open || !runtime.el) return
renderObjects()
renderLayerPanel()
renderFxPanel()
renderOptionBar()
updateStatusbar()
renderExportUI()
@@ -209,6 +214,8 @@ import { toast } from './commands.js'
// 2) 原图引用与吸管合成缓存(各为一张全幅位图)
S.originalImage = null
S.pickerComposite = null
// 2b) 快速效果的基准像素:又一张全幅位图,不释放就白占一份图大小的内存
S.fx = { key: null, value: 0, layerId: null, source: null }
// 3) 交互态复位:关闭后 window mouseup 等全局监听仍活着,靠标志位保证不落到绘制路径
S.isDrawing = false
S.panning = false
@@ -324,9 +331,40 @@ import { toast } from './commands.js'
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
+4
View File
@@ -317,6 +317,10 @@ export function setActiveLayer(id) {
if (!changed) return
renderLayerPanel()
renderObjects()
// 效果参数滑杆绑的是「上次点效果的那个层」:切层后必须立刻置灰/恢复,
// 否则用户会在新层上拖出一个属于旧层的像素结果(v1.8)。
// 走注入而不是直接 import effects.js —— 后者已经 import 本模块,硬连会成环。
if (S.renderFxPanel) S.renderFxPanel()
}
/** 添加位图图层(导入图片)— 便利版:一步落层,不再需要 Enter 二次确认
+4
View File
@@ -29,6 +29,10 @@
lastNameClick: null,
altPicker: false, // 按住 Alt 的临时吸管(画笔/橡皮下),松开 Alt 回到原工具
pickerComposite: null, // 吸管取样用的合成画布缓存(切工具/画布变化时失效)
// v1.8 快速效果的「可重调」状态:source 是点效果那一刻的像素备份,
// 拖强度滑杆时一律从 source 重算,绝不在上一次结果上叠加(否则来回拖会越拖越糊)。
// layerId 用于判断源是否还对得上当前目标层:切层后滑杆自动置灰,切回即恢复。
fx: { key: null, value: 0, layerId: null, source: null },
rectFill: false, // 矩形/圆形是否实心填充
penFill: true, // 钢笔闭合路径是否实心填充(只对闭合路径有意义)
// v1.2 工具参数解耦:形状线宽与文字字号不再借用画笔粗细,