Skip to content

Commit

Permalink
line: fix cython exception when calculating ellipse/circle if segment…
Browse files Browse the repository at this point in the history
…s % 2 == 1. closes kivy#1115
  • Loading branch information
tito committed Apr 15, 2013
1 parent 2f1c613 commit 903767f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions examples/canvas/lines_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@
text: 'Circle from 90 to 180\\n10 segments'
halign: 'center'
<LineCircle4>:
canvas:
Color:
rgba: .1, 1, .1, .9
Line:
width: 2.
circle: (self.center_x, self.center_y, min(self.width, self.height) / 2, 0, 360)
Label:
center: root.center
text: 'Circle from 0 to 360'
halign: 'center'
<LineRectangle>:
canvas:
Color:
Expand Down Expand Up @@ -118,6 +130,9 @@ class LineCircle2(Widget):
class LineCircle3(Widget):
pass

class LineCircle4(Widget):
pass

class LineRectangle(Widget):
pass

Expand All @@ -133,6 +148,7 @@ def build(self):
root.add_widget(LineCircle1())
root.add_widget(LineCircle2())
root.add_widget(LineCircle3())
root.add_widget(LineCircle4())
root.add_widget(LineRectangle())
root.add_widget(LineBezier())
return root
Expand Down
4 changes: 4 additions & 0 deletions kivy/graphics/vertex_instructions_line.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,8 @@ cdef class Line(VertexInstruction):
angle_dir = -1
if segments == 0:
segments = int(abs(angle_end - angle_start) / 2) + 3
if segments % 2 == 1:
segments += 1
# rad = deg * (pi / 180), where pi/180 = 0.0174...
angle_start = angle_start * 0.017453292519943295
angle_end = angle_end * 0.017453292519943295
Expand Down Expand Up @@ -949,6 +951,8 @@ cdef class Line(VertexInstruction):
angle_dir = -1
if segments == 0:
segments = int(abs(angle_end - angle_start) / 2) + 3
if segments % 2 == 1:
segments += 1
# rad = deg * (pi / 180), where pi/180 = 0.0174...
angle_start = angle_start * 0.017453292519943295
angle_end = angle_end * 0.017453292519943295
Expand Down

0 comments on commit 903767f

Please sign in to comment.