@@ -583,19 +583,21 @@ def rect(x, y, width, height, **kwargs):
583583 The current stroke, strokewidth and fill color are applied.
584584 """
585585 fill , stroke , strokewidth , strokestyle = color_mixin (** kwargs )
586- for i , clr in enumerate ((fill , stroke )):
587- if clr is not None and (i == 0 or strokewidth > 0 ):
588- if i == 1 :
589- glLineWidth (strokewidth )
590- glLineDash (strokestyle )
591- glColor4f (clr [0 ], clr [1 ], clr [2 ], clr [3 ] * _alpha )
592- # Note: this performs equally well as when using precompile().
593- glBegin ((GL_POLYGON , GL_LINE_LOOP )[i ])
594- glVertex2f (x , y )
595- glVertex2f (x + width , y )
596- glVertex2f (x + width , y + height )
597- glVertex2f (x , y + height )
598- glEnd ()
586+ if fill is not None :
587+ glColor4f (fill [0 ], fill [1 ], fill [2 ], fill [3 ] * _alpha )
588+ glRectf (x , y , x + width , y + width )
589+
590+ if stroke is not None and strokewidth > 0 :
591+ glLineWidth (strokewidth )
592+ glLineDash (strokestyle )
593+ glColor4f (stroke [0 ], stroke [1 ], stroke [2 ], stroke [3 ] * _alpha )
594+ # Note: this performs equally well as when using precompile().
595+ glBegin (GL_LINE_LOOP )
596+ glVertex2f (x , y )
597+ glVertex2f (x + width , y )
598+ glVertex2f (x + width , y + height )
599+ glVertex2f (x , y + height )
600+ glEnd ()
599601
600602def triangle (x1 , y1 , x2 , y2 , x3 , y3 , ** kwargs ):
601603 """ Draws the triangle created by connecting the three given points.
0 commit comments