Skip to content

Commit

Permalink
Fix unconnected segments line-interpolaton when drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
jsbueno committed Jun 6, 2021
1 parent 63d2f6d commit 8af2bf5
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions terminedia_paint/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ def reset(self, drawable):
self.drawable = drawable
self.last_set = None

def set_point(self, pos):
def set_point(self, pos, interpolate=False):
if self.last_set:
self.drawable.line(pos, self.last_set, erase=self.erase)
if interpolate:
self.drawable.line(pos, self.last_set, erase=self.erase)
self.last_set = None
elif not self.erase:
self.drawable.set(pos)
Expand Down Expand Up @@ -97,7 +98,7 @@ def state_reset(self):
# self.help_active = False
if getattr(self, "menu", None):
self.menu.sprite.active = True
# self.toggle_help()
self.drag_drawing = False

def run(self):
with self.sc:
Expand Down Expand Up @@ -136,7 +137,7 @@ def key_dispatcher(self, event):
if getattr(self.active_tool, "one_to_last_click", False):
self.active_tool.last_set = self.active_tool.one_to_last_click
self.active_tool.one_to_last_click = None
self.active_tool.set_point(self.pos)
self.active_tool.set_point(self.pos, interpolate=True)
self.active_tool.last_set = self.pos
self.dirty = True
if key == "x":
Expand All @@ -160,18 +161,23 @@ def mouse_click(self, event):
self.active_tool.one_to_last_click = self.active_tool.last_set
self.active_tool.last_set = None
self.active_tool.set_point(event.pos)
self.active_tool.last_set = event.pos
# self.active_tool.last_set = event.pos
self.pos = event.pos
self.drag_drawing = False
self.dirty = True

def mouse_double_click(self, event):
#FIXME - provisional to test double-click event
self.sc.context.char = random.choice("#*!|><")

def mouse_move(self, event):
if event.tick - getattr(self, "last_dragging_tick", 0) > 1:
self.drag_drawing = False
if event.buttons:
self.active_tool.set_point(event.pos)
self.active_tool.set_point(event.pos, interpolate=self.drag_drawing)
self.active_tool.last_set = event.pos
self.drag_drawing = True
self.last_dragging_tick = event.tick
self.dirty = True
self.pos = event.pos

Expand Down

0 comments on commit 8af2bf5

Please sign in to comment.