Implement erasing
This commit is contained in:
parent
87a59a5207
commit
0b17893b45
18
canvas.py
18
canvas.py
@ -21,10 +21,12 @@ class EditorCanvas(tkinter.Canvas):
|
|||||||
self.view_y=0
|
self.view_y=0
|
||||||
self.bind("<B1-Motion>",self.handle_draw)
|
self.bind("<B1-Motion>",self.handle_draw)
|
||||||
self.bind("<Button-1>",self.handle_draw)
|
self.bind("<Button-1>",self.handle_draw)
|
||||||
self.bind("<Button-3>",self.handle_move_start)
|
self.bind("<Button-2>",self.handle_move_start)
|
||||||
self.bind("<B3-Motion>",self.handle_move)
|
self.bind("<B2-Motion>",self.handle_move)
|
||||||
|
self.bind("<Button-3>",self.handle_erase)
|
||||||
|
self.bind("<B3-Motion>",self.handle_erase)
|
||||||
if platform.system()=="Windows" or platform.system()=="Darwin":
|
if platform.system()=="Windows" or platform.system()=="Darwin":
|
||||||
self.bind("<MouseWheel>",lambda event: self.handle_zoom(event.delta))
|
self.bind("<MouseWheel>",lambda event: self.handle_zoom(event.delta/120))
|
||||||
else:
|
else:
|
||||||
# This will probably work only on X11
|
# This will probably work only on X11
|
||||||
self.bind("<Button-4>",lambda _: self.handle_zoom(1))
|
self.bind("<Button-4>",lambda _: self.handle_zoom(1))
|
||||||
@ -76,6 +78,16 @@ class EditorCanvas(tkinter.Canvas):
|
|||||||
self.draw()
|
self.draw()
|
||||||
|
|
||||||
|
|
||||||
|
def handle_erase(self,event):
|
||||||
|
pixel_pos=self.cursor_pos_to_pixel((event.x,event.y))
|
||||||
|
if not pixel_pos:
|
||||||
|
return
|
||||||
|
self.current_char_modified=True
|
||||||
|
self.project.modified=True
|
||||||
|
self.current_char_pixels[pixel_pos[0]*self.project.char_res[1]+pixel_pos[1]]=0
|
||||||
|
self.draw()
|
||||||
|
|
||||||
|
|
||||||
def handle_zoom(self,delta):
|
def handle_zoom(self,delta):
|
||||||
self.grid_size+=delta
|
self.grid_size+=delta
|
||||||
self.width=self.project.char_res[0]*self.grid_size
|
self.width=self.project.char_res[0]*self.grid_size
|
||||||
|
Loading…
Reference in New Issue
Block a user