During a lecture on the history of computer graphics, I decided that I needed to understand the way that bezier curves work. Since I’ve done a lot of work recently with pygame (see: Propellor & Ratchet Games) I decided to quickly hack together something to help me visualise it.

bezier.py as attached
Thus, with a quick visit to Wikipedia for the algorithm and a quick debug, I had a bezier curve drawn in pygame. The next job was to provide some sort of interactivity. Tying one of the points to the mouse position was a start, but left a lot to be desired. I’d seen editable bezier curves (such as in Inkscape) draw the control points, so I decided to follow suit.
Pygame’s pygame.draw.rect function requires a pygame.Rect object to be passed, so I decided to convert the bezier curve’s control points into pygame.Rect objects. This is also handy for detecting mouse collisions using the pygame.Rect.collidepoint function.
The final code (as attached) has been commented and cleaned up. Hopefully it provides a good view of how handy the pygame.Rect object can be in addition to a simple example of a pygame application. (Hint: click-and-drag the grey squares to modify the curve.)
Note: I have also developed the code further using OOP to allow several curves to link and unlink control points dynamically; if it reaches a usable/readable state you might expect to see it posted here.