Add addMask method to MaskTool for overlaying masks

Introduces the addMask method to MaskTool in both JS and TS implementations, allowing new masks to be overlaid without clearing existing ones. Updates CanvasView to use addMask instead of setMask when applying SAM detector results.
This commit is contained in:
Dariusz L
2025-07-22 23:39:56 +02:00
parent 1d520eca01
commit 472f8768a5
4 changed files with 33 additions and 6 deletions

View File

@@ -1056,9 +1056,9 @@ async function handleSAMDetectorResult(node, resultImage) {
});
throw new Error("Mask tool not available or not initialized");
}
log.debug("Applying SAM mask to canvas using setMask method");
// Use the setMask method which handles positioning automatically
canvas.maskTool.setMask(maskAsImage);
log.debug("Applying SAM mask to canvas using addMask method");
// Use the addMask method which overlays on existing mask without clearing it
canvas.maskTool.addMask(maskAsImage);
// Update canvas and save state (same as CanvasMask)
canvas.render();
canvas.saveState();