@@ -628,19 +628,30 @@ def ellipse(x, y, width, height, segments=ELLIPSE_SEGMENTS, **kwargs):
628628 if not segments in _ellipses :
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.
631- _ellipses [segments ] = []
632- for mode in (GL_POLYGON , GL_LINE_LOOP ):
633- _ellipses [segments ].append (precompile (lambda :(
634- glBegin (mode ),
635- [glVertex2f (cos (t )/ 2 , sin (t )/ 2 ) for t in [2 * pi * i / segments for i in range (segments )]],
636- glEnd ()
637- )))
631+ 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+
646+ _ellipses [segments ] = commands
647+
638648 fill , stroke , strokewidth , strokestyle = color_mixin (** kwargs )
639649 for i , clr in enumerate ((fill , stroke )):
640650 if clr is not None and (i == 0 or strokewidth > 0 ):
641651 if i == 1 :
642652 glLineWidth (strokewidth )
643- glLineDash (strokestyle )
653+ if strokestyle != _strokestyle :
654+ glLineDash (strokestyle )
644655 glColor4f (clr [0 ], clr [1 ], clr [2 ], clr [3 ] * _alpha )
645656 glPushMatrix ()
646657 glTranslatef (x , y , 0 )
0 commit comments