Archive for the ‘implementation details’ Category


Step 1: Get the basics working

May 31, 2010

Currently I’m working on the very basic features that are also supported by the original pygame.draw module. When looking over these old functions (and its results), I discover more and more blemishes.

One example is pygame.draw.rect, the simplest drawing function of the whole module, you may say, but its a bit tricky, because you have to decide how a passed rect defines the pixels to draw. To be exact, I’m talking about drawing rects of a certain width. Draw around the actual rect or inside or outside? I wanted to see how the current draw module does it:

rect outline behavior

how pygame.drw.rect draws rects with certain widths

As you can see, it draws around the actual rect, ie. +width/2 and -width/2. So far, so good. But now have a look at the corner. A few pixels are missing there! It seems, it’s not a rect but just 4 lines between the vertices of the rect.

I’m going to implement this (position of the line, not the missing pixels) as default behavior, but may add alternatives like completely inside or completely outside:

rect outline position


This would also apply to other shape outlines like ellipses but I’m not sure if this would be really useful, though.