mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-21 20:52:12 -03:00
Add mask editor integration to canvas workflow
Introduces the ability to open the current canvas in a mask editor, upload and retrieve mask edits, and apply them to the mask layer. Adds utility functions for mask editor state detection and control, a new 'Edit Mask' button in the UI, and methods for handling mask updates and preview refresh. Also adds a setMask method to MaskTool for precise mask placement.
This commit is contained in:
@@ -279,4 +279,26 @@ export class MaskTool {
|
||||
this.y += dy;
|
||||
log.info(`Mask position updated to (${this.x}, ${this.y})`);
|
||||
}
|
||||
|
||||
setMask(image) {
|
||||
// `this.x` i `this.y` przechowują pozycję lewego górnego rogu płótna maski
|
||||
// względem lewego górnego rogu widoku. Zatem (-this.x, -this.y) to pozycja
|
||||
// lewego górnego rogu widoku na płótnie maski.
|
||||
const destX = -this.x;
|
||||
const destY = -this.y;
|
||||
|
||||
// Wyczyść tylko ten obszar na dużym płótnie maski, który odpowiada
|
||||
// widocznemu obszarowi wyjściowemu.
|
||||
this.maskCtx.clearRect(destX, destY, this.canvasInstance.width, this.canvasInstance.height);
|
||||
|
||||
// Narysuj nowy obraz maski (który ma rozmiar obszaru wyjściowego)
|
||||
// dokładnie w tym wyczyszczonym miejscu.
|
||||
this.maskCtx.drawImage(image, destX, destY);
|
||||
|
||||
if (this.onStateChange) {
|
||||
this.onStateChange();
|
||||
}
|
||||
this.canvasInstance.render(); // Wymuś odświeżenie, aby zobaczyć zmianę
|
||||
log.info(`MaskTool updated with a new mask image at correct canvas position (${destX}, ${destY}).`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user