feat(image-annotate): 选区编辑 + 便利版 UI + 单张输出预设(1.1.0)
This commit is contained in:
1 parent
b9ace636ef
commit
662d7eae77
22 files changed
+3795
-343
No files matched your search
@@ -77,6 +77,7 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
const ctx = getActiveCtx()
|
||||
if (!ctx) return
|
||||
ctx.save()
|
||||
if (S.selection && S.selection.active) ctx.clip(S.selection.path, S.selection.fillRule)
|
||||
ctx.globalCompositeOperation = 'destination-out'
|
||||
ctx.globalAlpha = S.brushOpacity
|
||||
ctx.lineWidth = Math.max(1, S.brushSize)
|
||||
@@ -135,6 +136,7 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
const ctx = getActiveCtx()
|
||||
if (!ctx) return
|
||||
ctx.save()
|
||||
if (S.selection && S.selection.active) ctx.clip(S.selection.path, S.selection.fillRule)
|
||||
if (S.tool === 'eraser') {
|
||||
ctx.globalCompositeOperation = 'destination-out'
|
||||
}
|
||||
@@ -216,10 +218,22 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
return rect.width ? rect.width / S.imgW : S.zoom
|
||||
}
|
||||
|
||||
/** 圆形笔刷光标 */
|
||||
/** 清笔刷环专用层(不碰裁剪框 / 选中框 / 蚂蚁线) */
|
||||
export function clearToolRing() {
|
||||
const ctx = S.cursorCtx
|
||||
if (!ctx) return
|
||||
const pad = S.overlayPad || 0
|
||||
ctx.save()
|
||||
ctx.setTransform(1, 0, 0, 1, 0, 0)
|
||||
ctx.clearRect(0, 0, S.imgW + pad * 2, S.imgH + pad * 2)
|
||||
ctx.restore()
|
||||
ctx.setTransform(1, 0, 0, 1, pad, pad)
|
||||
}
|
||||
|
||||
/** 圆形笔刷光标:画在独立 cursorCanvas,避免 clearOverlay() 擦掉其它交互层 */
|
||||
export function drawToolRing(pos) {
|
||||
clearOverlay()
|
||||
const ctx = S.overlayCtx
|
||||
clearToolRing()
|
||||
const ctx = S.cursorCtx || S.overlayCtx
|
||||
const r = getToolBrushRadius()
|
||||
const k = 1 / screenScale()
|
||||
const rMin = 2 * k
|
||||
@@ -348,6 +362,13 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
if (tool !== 'select' && tool !== 'pen') { 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
|
||||
// 选区与裁剪互斥:进裁剪必须清掉选区;离开选区工具要丢弃未完成的拉框/套索
|
||||
if (tool === 'crop') { S.selection = null; S.marquee = null; S.lassoPts = null }
|
||||
if (tool !== 'marquee' && tool !== 'lasso') {
|
||||
if (S.marquee || S.lassoPts) { S.isDrawing = false; S.interaction = 'idle' }
|
||||
S.marquee = null
|
||||
S.lassoPts = null
|
||||
}
|
||||
S.tool = tool
|
||||
if (tool !== 'select') S.selectedLayerId = null
|
||||
if (tool !== 'text' && tool !== 'select') S.selectedTextId = null
|
||||
@@ -368,4 +389,6 @@ import { hexToRgb, rgbToHex } from '../vendor/image-math.js'
|
||||
}
|
||||
renderObjects()
|
||||
renderLayerPanel()
|
||||
// 让蚂蚁线/浮动条按新的工具与选区状态同步(由 index.js 注入)
|
||||
if (S.renderAll) S.renderAll()
|
||||
}
|
||||
Reference in new issue
Block a user