Skip to content

Commit

Permalink
Allow Line.points definition to be a mix of lists/tuples
Browse files Browse the repository at this point in the history
Fix for issue kivy#3481
Line.points can be defined as list of lists, tuples and
coordinates (float values)
setter method modified to check each element of the argument
list and append it to self._points accordingly
Line example file /examples/canvas/line.py updated with the new
possible way of defining points
  • Loading branch information
udiboy1209 committed Dec 23, 2015
1 parent d5fe4c6 commit 1baeeeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/canvas/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class LinePlayground(FloatLayout):
alpha_controlline = NumericProperty(1.0)
alpha = NumericProperty(0.5)
close = BooleanProperty(False)
points = ListProperty([500, 500, 300, 300, 500, 300, 500, 400, 600, 400])
points = ListProperty([(500, 500), 300, 300, 500, 300, [500, 400, 600, 400]])
points2 = ListProperty([])
joint = OptionProperty('none', options=('round', 'miter', 'bevel', 'none'))
cap = OptionProperty('none', options=('round', 'square', 'none'))
Expand Down
9 changes: 8 additions & 1 deletion kivy/graphics/vertex_instructions_line.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,14 @@ cdef class Line(VertexInstruction):
def __get__(self):
return self._points
def __set__(self, points):
self._points = list(points)
import itertools
tmp=[]
for p in points:
if isinstance(p,(list,tuple)):
tmp=tmp+list(p)
else:
tmp.append(p)
self._points=tmp
self.flag_update()

property dash_length:
Expand Down

0 comments on commit 1baeeeb

Please sign in to comment.