modified the magic wand logics for erasing.
This commit is contained in:
+3
-2
@@ -70,7 +70,7 @@ class MagicWand {
|
||||
newMaskData.data[index + 0] = parseInt(this.maskingColor.substr(1,2), 16);
|
||||
newMaskData.data[index + 1] = parseInt(this.maskingColor.substr(3,2), 16);
|
||||
newMaskData.data[index + 2] = parseInt(this.maskingColor.substr(5,2), 16);
|
||||
newMaskData.data[index + 3] = 255;
|
||||
newMaskData.data[index + 3] = this.adding ? 255 : 0;
|
||||
});
|
||||
newMaskCtx.putImageData(newMaskData, 0, 0);
|
||||
|
||||
@@ -82,7 +82,7 @@ class MagicWand {
|
||||
return newMaskCvs;
|
||||
}
|
||||
|
||||
constructor(imageCanvas, maskCanvas, sketchCanvas, colorStr, threshold) {
|
||||
constructor(imageCanvas, maskCanvas, sketchCanvas, colorStr, threshold, adding) {
|
||||
this.targetCanvas = document.createElement('canvas');
|
||||
let trgCvs = this.targetCanvas;
|
||||
trgCvs.width = maskCanvas.width;
|
||||
@@ -98,6 +98,7 @@ class MagicWand {
|
||||
|
||||
this.maskingColor = colorStr;
|
||||
this.threshold = threshold;
|
||||
this.adding = adding;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -619,7 +619,9 @@ class MaskEditorDialog extends ComfyDialog {
|
||||
const y = event.offsetY || event.targetTouches[0].clientY - maskRect.top;
|
||||
|
||||
if (this.is_magicWand) {
|
||||
if (window.TouchEvent && event instanceof TouchEvent || event.buttons == 1) {
|
||||
if ((window.TouchEvent && event instanceof TouchEvent || event.buttons == 1)
|
||||
|| (event.buttons == 2 || event.buttons == 5 || event.buttons == 32)) {
|
||||
|
||||
var diff = performance.now() - self.lasttime;
|
||||
|
||||
if(diff > 20 && !this.drawing_mode) {
|
||||
@@ -752,7 +754,8 @@ class MaskEditorDialog extends ComfyDialog {
|
||||
this.maskCanvas,
|
||||
this.sketchCanvas,
|
||||
this.getActiveBrushColor(),
|
||||
16);
|
||||
16,
|
||||
event.button == 0);
|
||||
this.magicWandInst.execute(x, y, 0, this.maskCanvas);
|
||||
|
||||
self.lastx = x;
|
||||
|
||||
Reference in New Issue
Block a user