Skip to content

Commit

Permalink
Fallback to simpler algorithm for chaining using itertools
Browse files Browse the repository at this point in the history
Ignores the case when self._points is a mix of list/tuple/float
Only works in cases where self._points is a list of iterables
  • Loading branch information
udiboy1209 committed Jan 5, 2016
1 parent 171fd32 commit 0be548f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions examples/canvas/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class LinePlayground(FloatLayout):
alpha = NumericProperty(0.5)
close = BooleanProperty(False)
points = ListProperty([(500, 500),
300, 300, 500, 300,
[300, 300, 500, 300],
[500, 400, 600, 400]])
points2 = ListProperty([])
joint = OptionProperty('none', options=('round', 'miter', 'bevel', 'none'))
Expand All @@ -152,12 +152,12 @@ def on_touch_down(self, touch):
if super(LinePlayground, self).on_touch_down(touch):
return True
touch.grab(self)
self.points = self.points + list(touch.pos)
self.points.append(touch.pos)
return True

def on_touch_move(self, touch):
if touch.grab_current is self:
self.points[-2:] = list(touch.pos)
self.points[-1] = touch.pos
return True
return super(LinePlayground, self).on_touch_move(touch)

Expand Down
11 changes: 4 additions & 7 deletions kivy/graphics/vertex_instructions_line.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,10 @@ cdef class Line(VertexInstruction):
return self._points

def __set__(self, points):
tmp = []
for p in points:
if isinstance(p, (list, tuple)):
tmp = tmp + list(p)
else:
tmp.append(p)
self._points = tmp
import itertools
if points and isinstance(points[0], (list, tuple)):
self._points = list(itertools.chain(*points))

self.flag_update()

property dash_length:
Expand Down

0 comments on commit 0be548f

Please sign in to comment.