feat(image-annotate): 1.2.1 默认不预建画笔层(按需自动落标注层)+ 侧栏硬度/透明去重
This commit is contained in:
1 parent
d8e4e0cb26
commit
1bf8220c05
10 files changed
+124
-114
No files matched your search
+38
-59
@@ -9,7 +9,7 @@
|
||||
var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
id: 'image-annotate',
|
||||
name: '标注 / 修图',
|
||||
version: '1.2.0',
|
||||
version: '1.2.1',
|
||||
apiVersion: 1,
|
||||
capabilities: ['commands', 'nodeActions', 'canvas', 'canvasWrite'],
|
||||
settings: {
|
||||
@@ -1715,6 +1715,34 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
function addBitmapLayer(img) {
|
||||
placeImageDirectly(img);
|
||||
}
|
||||
function ensureWritableLayer() {
|
||||
const current = getActiveLayer();
|
||||
if (current && !current.locked) return current;
|
||||
const id = S.layers.some((l) => l.id === "draw") ? "L" + Date.now() + Math.floor(Math.random() * 1e3) : "draw";
|
||||
const canvas = createLayerCanvas();
|
||||
const ctx = canvas.getContext("2d", { willReadFrequently: true });
|
||||
ctx.clearRect(0, 0, S.imgW, S.imgH);
|
||||
const layer = {
|
||||
id,
|
||||
name: "标注 " + (S.layers.filter((l) => l.id !== "base").length + 1),
|
||||
canvas,
|
||||
ctx,
|
||||
opacity: 1,
|
||||
visible: true,
|
||||
locked: false,
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: S.imgW,
|
||||
h: S.imgH,
|
||||
rotation: 0,
|
||||
z: ++S.zCounter
|
||||
};
|
||||
S.layers.push(layer);
|
||||
reorderLayerCanvas();
|
||||
setActiveLayer(id);
|
||||
renderLayerPanel();
|
||||
return layer;
|
||||
}
|
||||
function addBlankLayer() {
|
||||
const id = "L" + Date.now() + Math.floor(Math.random() * 1e3);
|
||||
const canvas = createLayerCanvas();
|
||||
@@ -2460,7 +2488,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
return true;
|
||||
}
|
||||
function fillOnActiveLayer() {
|
||||
const layer = writableLayer();
|
||||
const layer = ensureWritableLayer();
|
||||
if (!layer) return false;
|
||||
const sel = S.selection;
|
||||
layer.ctx.save();
|
||||
@@ -2648,7 +2676,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
|
||||
<button class="iwb-editor-tool active" data-tool="brush" title="画笔"><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="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="eraser" title="橡皮:擦除当前活跃图层的内容(画笔标注或原图),与画笔共用大小/硬度/透明度"><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="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg></button>
|
||||
<button class="iwb-editor-tool" data-tool="eraser" title="橡皮:擦除当前活跃图层的内容,与画笔共用大小/硬度/透明度"><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="m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21"/><path d="M22 21H7"/><path d="m5 11 9 9"/></svg></button>
|
||||
|
||||
<button class="iwb-editor-tool" data-tool="pen" title="钢笔:点击添加节点,双击或 Enter 完成自定义形状"><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="m12 19 7-7 3 3-7 7-3-3z"/><path d="m18 13-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="m2 2 7.586 7.586"/><circle cx="11" cy="11" r="2"/></svg></button>
|
||||
|
||||
@@ -2801,16 +2829,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
<button type="button" class="iwb-editor-brush-preset" data-brush-size="24" title="描边 24"><i></i></button>
|
||||
<button type="button" class="iwb-editor-brush-preset" data-brush-size="32" title="描边 32"><i></i></button>
|
||||
</div>
|
||||
<div class="iwb-editor-brush-group">
|
||||
<label class="iwb-editor-brush-label">硬度
|
||||
<input type="range" class="iwb-editor-brush-hardness" min="0" max="100" value="100">
|
||||
<span class="iwb-editor-brush-hardness-val">100</span>
|
||||
</label>
|
||||
<label class="iwb-editor-brush-label iwb-editor-opacity-label">透明
|
||||
<input type="range" class="iwb-editor-brush-opacity" min="5" max="100" step="5" value="100">
|
||||
<span class="iwb-editor-brush-opacity-val">100%</span>
|
||||
</label>
|
||||
</div>
|
||||
<!-- 硬度/透明滑杆已移除:与就地选项栏(画笔/橡皮工具态)完全重复,参数只留选项栏一处 -->
|
||||
|
||||
</div>
|
||||
|
||||
@@ -2831,7 +2850,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
<span class="iwb-editor-status-size">—</span>
|
||||
<span class="iwb-editor-status-pos">x — y —</span>
|
||||
<span class="iwb-editor-status-sel">无选区</span>
|
||||
<span class="iwb-editor-status-layer">当前层:画笔标注</span>
|
||||
<span class="iwb-editor-status-layer">当前层:原图</span>
|
||||
<span class="iwb-editor-status-tool">画笔</span>
|
||||
</div>
|
||||
<div class="iwb-editor-toast" role="status" aria-live="polite"></div>
|
||||
@@ -3085,7 +3104,7 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
return;
|
||||
}
|
||||
function onBrushMouseDown(pos) {
|
||||
if (!getActiveCtx()) return;
|
||||
if (!ensureWritableLayer()) return;
|
||||
S.isDrawing = true;
|
||||
saveSnapshot();
|
||||
beginStroke();
|
||||
@@ -4696,28 +4715,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
locked: true,
|
||||
z: 0
|
||||
});
|
||||
const drawCanvas = createLayerCanvas();
|
||||
const drawCtx = drawCanvas.getContext("2d", { willReadFrequently: true });
|
||||
drawCtx.clearRect(0, 0, S.imgW, S.imgH);
|
||||
S.layers.push({
|
||||
id: "draw",
|
||||
name: "画笔标注",
|
||||
canvas: drawCanvas,
|
||||
ctx: drawCtx,
|
||||
opacity: 1,
|
||||
visible: true,
|
||||
locked: false,
|
||||
transformable: true,
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: S.imgW,
|
||||
h: S.imgH,
|
||||
color: S.color,
|
||||
lineWidth: S.brushSize,
|
||||
z: 1
|
||||
});
|
||||
S.activeLayerId = "draw";
|
||||
S.zCounter = Math.max(S.layers.length - 1, 0);
|
||||
S.activeLayerId = "base";
|
||||
S.zCounter = 1;
|
||||
S.textCtx.clearRect(0, 0, S.imgW, S.imgH);
|
||||
S.strokeCtx.clearRect(0, 0, S.imgW, S.imgH);
|
||||
clearOverlay();
|
||||
@@ -5509,28 +5508,8 @@ var __IWB_ANNOTATE_MANIFEST__ = {
|
||||
base.opacity = 1;
|
||||
base.z = 0;
|
||||
}
|
||||
const drawCanvas = createLayerCanvas();
|
||||
const drawCtx = drawCanvas.getContext("2d", { willReadFrequently: true });
|
||||
const draw = {
|
||||
id: "draw",
|
||||
name: "画笔标注",
|
||||
canvas: drawCanvas,
|
||||
ctx: drawCtx,
|
||||
opacity: 1,
|
||||
visible: true,
|
||||
locked: false,
|
||||
transformable: true,
|
||||
x: 0,
|
||||
y: 0,
|
||||
w: S.imgW,
|
||||
h: S.imgH,
|
||||
rotation: 0,
|
||||
color: S.color,
|
||||
lineWidth: S.brushSize,
|
||||
z: 1
|
||||
};
|
||||
S.layers = base ? [base, draw] : [draw];
|
||||
S.activeLayerId = "draw";
|
||||
S.layers = base ? [base] : [];
|
||||
S.activeLayerId = base ? "base" : null;
|
||||
S.zCounter = 1;
|
||||
clearAllEditState();
|
||||
if (S.renderAll) S.renderAll();
|
||||
|
||||
Reference in new issue
Block a user