深度画布橡皮擦记录

This commit is contained in:
lzp
2026-03-27 09:50:09 +08:00
parent b3aedd3fce
commit 43cf097a2a
2 changed files with 20 additions and 2 deletions

View File

@@ -221,12 +221,13 @@ export class AISelectboxToolManager {
if (!this.demoObject) return if (!this.demoObject) return
const fobject = this.demoObject const fobject = this.demoObject
this.clearDemoObject() this.clearDemoObject()
const canvas = getObjectAlphaToCanvas(fobject, null, 0, { r: 255, g: 0, b: 0, a: 255 }); const tcanvas = await this.createStaticCanvas(fobject)
const canvas = getObjectAlphaToCanvas(tcanvas, null, 0, { r: 255, g: 0, b: 0, a: 255 });
const arr = traceImageContour(canvas);
const scaleY = fobject.scaleY const scaleY = fobject.scaleY
const scaleX = fobject.scaleX const scaleX = fobject.scaleX
const top = fobject.top const top = fobject.top
const left = fobject.left const left = fobject.left
const arr = traceImageContour(canvas);
let minX = fobject.width; let minX = fobject.width;
let minY = fobject.height; let minY = fobject.height;
const str = arr.map((v) => { const str = arr.map((v) => {

View File

@@ -753,6 +753,23 @@ export class CanvasEventManager {
this.canvas.on("object:removed", (e) => { this.canvas.on("object:removed", (e) => {
// updateLayers(e); // updateLayers(e);
}); });
this.canvas.on("erasing:start", (e) => {
// console.log("erasing:start", e);
});
this.canvas.on("erasing:end", async (e) => {
// console.log("erasing:end", e);
const targets = e.targets;
var isRecord = false;
for (let i = 0; i < targets.length; i++) {
const target = targets[i];
const id = target?.info?.id;
if (id) {
isRecord = true;
await this.layerManager.updateLayerThumbnailsById(id)
}
}
if (isRecord) this.stateManager.recordState();
});
} }
setupDoubleClickEvents() { setupDoubleClickEvents() {
// 双击处理 // 双击处理