The other day I learned a little about the pygame python module that provides access to sdl functions on Linux along with some higher level functions. Basically, this means that you can use pygame to access some pretty low level graphics to draw things. I thought it might be fun to use it to make pretty pictures. Here’s an example where points are plotted, with the colour of each point a function of the coordinates. These simple examples should indicate how this type of low-level drawing can be used, perhaps to visualise complicated data or make interesting animations.

In sdl as with many computer graphics systems, coordinates start from the top left with $(0,0)$, and proceed positively right and down. The equations presented below give the red-green-blue (RGB) values of the color of the point at $(x,y)$. Each value is taken modulo $255$ (actually, I should have taken the value modulo $256$, since each color goes from $0$ to $255$, but I didn’t think carefully about this when I wrote the program!).

$\begin{align*} r &= x\\ g &= x-y\\ b &= x + y \end{align*} $ |