Home page

Python Patterns

Updated December 2011

These pages provides python source code for a creating a variety of patterns and saving them as Windows Bitmaps (.bmp) files. There is also source code for taking a set of GIF files and converting them into an animated GIF.

The GIF File support is currently limited to sets of files that have the same colour map and are the same size, but is sufficient to create the animations in this section.

I don't have any code for converting BMP to GIF, I usually use some other application for this.

Source Code

The source code can be downloaded from here.

Each source code module includes methods do draw these patterns and includes some example code showing how to use it. The easiest way to generate your own patterns is to vary the parameters in the examples and see what happens. An alternative would to be to create new python scripts based on the example code.

Line Patterns

The line pattern module was developed mainly as a test for the line drawing algorithm. The module comes with an example function that draws patterns like these below.

Eaxmples 1-50 draw what are known as complete graphs (the graph obtained by joining every point in a set to every other point). You can read more about these at Wolfram Research's Mathworld. The first image below is the complete graph for 10.

Passing a tuple such as (11,4) to the 'example' method will draw a star. The second image is the (11,4) star, it has eleven points with the edges joining every 4th point.

The third and fourth images are examples 100 and 100 respectively third and fourth images are generated by drawing a set of stars and show sets of starts based on (5,2) and(7,1) with varying phases and sizes.

The source for these patterns can be downloaded from the source code page.

This is an animation of the first 29 complete graphs (except 1 and 2) drawn using examples 2-29 in the source code.

(c) John Whitehouse 2010