Skip to content

Commit 9ef982d

Browse files
committed
properly close ellipse; avoid apparently extraneous glVertex calls using GL_TRIANGLE_FAN; avoid precompile bug
1 parent 9e5ea01 commit 9ef982d

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

nodebox/graphics/context.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -629,20 +629,15 @@ def ellipse(x, y, width, height, segments=ELLIPSE_SEGMENTS, **kwargs):
629629
# For the given amount of line segments, calculate the ellipse once.
630630
# Then reuse the cached ellipse by scaling it to the desired size.
631631
commands = []
632-
v = [glVertex2f(cos(t)/2, sin(t)/2) for t in [2*pi*i/segments for i in range(segments)]]
633-
commands.append(precompile(lambda:(
634-
glBegin(GL_TRIANGLE_FAN),
635-
[glVertex2f(0, 0)] +
636-
v +
637-
[glVertex2f(0, 0)],
638-
glEnd()
639-
)))
640-
commands.append(precompile(lambda:(
641-
glBegin(GL_LINE_LOOP),
642-
v,
643-
glEnd()
644-
)))
645-
632+
f = 2 * pi / segments
633+
v = [(cos(t)/2, sin(t)/2) for t in [i*f for i in range(segments)+[0]]]
634+
for mode in (GL_TRIANGLE_FAN, GL_LINE_LOOP):
635+
commands.append(precompile(lambda:(
636+
glBegin(mode),
637+
[glVertex2f(x, y) for (x, y) in v],
638+
glEnd()
639+
)))
640+
646641
_ellipses[segments] = commands
647642

648643
fill, stroke, strokewidth, strokestyle = color_mixin(**kwargs)

0 commit comments

Comments
 (0)