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
@@ -15,13 +15,19 @@ import { getSelectedShape, getSelectedText, renderObjects, shapeBounds, textBoun
|
||||
|
||||
// ============ 画布设置 ============
|
||||
|
||||
/** 三张交互层(选中框/蚂蚁线/笔刷环)共享同一尺寸与坐标基准,但各自清屏互不影响 */
|
||||
function syncOverlayCanvas() {
|
||||
const pad = S.overlayPad || 0
|
||||
const scale = S.imgW ? (S.fitW * S.zoom) / S.imgW : 1
|
||||
S.overlayCanvas.style.left = '0px'
|
||||
S.overlayCanvas.style.top = '0px'
|
||||
S.overlayCanvas.style.width = Math.round((S.imgW + pad * 2) * scale) + 'px'
|
||||
S.overlayCanvas.style.height = Math.round((S.imgH + pad * 2) * scale) + 'px'
|
||||
const w = Math.round((S.imgW + pad * 2) * scale) + 'px'
|
||||
const h = Math.round((S.imgH + pad * 2) * scale) + 'px'
|
||||
for (const c of [S.overlayCanvas, S.selectionCanvas, S.cursorCanvas]) {
|
||||
if (!c) continue
|
||||
c.style.left = '0px'
|
||||
c.style.top = '0px'
|
||||
c.style.width = w
|
||||
c.style.height = h
|
||||
}
|
||||
}
|
||||
|
||||
export function setupCanvas(img) {
|
||||
@@ -40,9 +46,12 @@ import { getSelectedShape, getSelectedText, renderObjects, shapeBounds, textBoun
|
||||
S.strokeCanvas.style.display = 'none'
|
||||
// 裁剪越界区域属于交互工作区,不改变图片本身的画布尺寸。
|
||||
S.overlayPad = Math.max(96, Math.ceil(Math.max(S.imgW, S.imgH) * 0.18))
|
||||
S.overlayCanvas.width = S.imgW + S.overlayPad * 2
|
||||
S.overlayCanvas.height = S.imgH + S.overlayPad * 2
|
||||
S.overlayCtx.setTransform(1, 0, 0, 1, S.overlayPad, S.overlayPad)
|
||||
for (const [c, cx] of [[S.overlayCanvas, S.overlayCtx], [S.selectionCanvas, S.selectionCtx], [S.cursorCanvas, S.cursorCtx]]) {
|
||||
if (!c || !cx) continue
|
||||
c.width = S.imgW + S.overlayPad * 2
|
||||
c.height = S.imgH + S.overlayPad * 2
|
||||
cx.setTransform(1, 0, 0, 1, S.overlayPad, S.overlayPad)
|
||||
}
|
||||
|
||||
// 创建图层 1: 原图
|
||||
const baseCanvas = createLayerCanvas()
|
||||
|
||||
Reference in new issue
Block a user