Browse Source

[Viewer] Add free line drawing tool

Fixes #7
master
octogene 3 years ago
parent
commit
18a605d2f0
2 changed files with 10 additions and 3 deletions
  1. +3
    -0
      hadaly/app.py
  2. +7
    -3
      hadaly/painter.py

+ 3
- 0
hadaly/app.py View File

@ -568,6 +568,9 @@ class Manager(ScreenManager):
elif key == 258 and self.current == 'viewer':
current_slide = self.get_screen('viewer').carousel.current_slide
current_slide.viewer.painter.current_tool = 'line'
elif key == 259 and self.current == 'viewer':
current_slide = self.get_screen('viewer').carousel.current_slide
current_slide.viewer.painter.current_tool = 'freeline'
elif key == 269 and self.current == 'viewer':
current_slide = self.get_screen('viewer').carousel.current_slide
painter = current_slide.viewer.painter


+ 7
- 3
hadaly/painter.py View File

@ -8,8 +8,9 @@ from kivy.properties import StringProperty, DictProperty, BooleanProperty, Bound
class Painter(Widget):
tools = DictProperty({'arrow': {'color': (1, 1, 1, 1), 'thickness': 0.4},
'line': {'color': (1, 1, 1, 1), 'thickness': 0.4},
tools = DictProperty({'arrow': {'color': (1, 1, 1, 1), 'thickness': 0.5},
'line': {'color': (1, 1, 1, 1), 'thickness': 0.5},
'freeline': {'color': (1, 1, 1, 1), 'thickness': 0.5},
'eraser': {'thickness': 0.4}
})
current_tool = StringProperty('arrow')
@ -40,7 +41,10 @@ class Painter(Widget):
def on_touch_move(self, touch):
if not self.locked and self.collide_point(*touch.pos):
try:
touch.ud['line'].points = [touch.ox, touch.oy, touch.x, touch.y]
if self.current_tool == 'freeline':
touch.ud['line'].points += [touch.x, touch.y]
else:
touch.ud['line'].points = [touch.ox, touch.oy, touch.x, touch.y]
except KeyError:
pass
else:


Loading…
Cancel
Save