Fix eraser when mousedown

This commit is contained in:
lnyan 2022-10-21 00:37:08 +08:00
parent ad4281ce68
commit f85c44911b
4 changed files with 7 additions and 5 deletions

3
app.py
View File

@ -819,11 +819,12 @@ with blocks as demo:
label="Init Mode",
choices=[
"patchmatch",
"g_diffuser",
"edge_pad",
"cv2_ns",
"cv2_telea",
"perlin",
"gaussian",
"g_diffuser",
],
value="patchmatch",
type="value",

View File

@ -200,7 +200,7 @@ class InfCanvas:
def handle_mouse_down(event):
self.mouse_state = get_mouse_mode()
if self.mouse_state==BRUSH_MODE:
x,y=get_event_pos()
x,y=get_event_pos(event)
self.use_eraser(x,y)
def handle_mouse_out(event):

View File

@ -372,8 +372,7 @@ async def message_func(event):
elif event.data[0]=="mode":
if event.data[1]!="selection":
await sync_func(event)
if event.data[1]!="eraser":
await eraser_func(event)
await eraser_func(event)
document.querySelector("#mode").value=event.data[1]
elif event.data[0]=="transfer":
await transfer_func(event)

View File

@ -68,7 +68,8 @@ open_setting = function() {
Save() {
this.validate();
let record = this.getCleanRecord();
window.postMessage(["resize",record.width,record.height],"*");
window.postMessage(["resize",record.canvas_width,record.canvas_height],"*");
w2popup.close();
},
custom: {
text: "Cancel",
@ -284,6 +285,7 @@ var toolbar=new w2toolbar({
break;
case "load":
query("#upload_state").click();
this.selection_box=null;
this.setCount("resize_selection","");
break;
case "next":