# Tag: libraries

### Rainbow Flag in Pygame

This little Pygame program paints the Rainbow Flag, as used by the LGBT movement. It illustrates:

- Importing the Pygame library
- RGB colours in hexadecimal
- Python’s for loop using the enumerate() function
- Filling a rectangular area in Pygame
- Updating display

### Drawing Fractals with Lindenmayer Systems

Lindenmayer systems, or L-systems, provide a very powerful way to construct fractals. Lindenmayer used L-systems to describe the behaviour of plant cells and to model the growth processes of plant development. An L-system is a rewriting system and a …

### A Fake Circle made of Straight Lines

Inspired by this post on Reddit, I wrote this little script to do the same thing. The circle is an illusion created by 100 straight-line tangents to an invisible circle. The tangents are created by drawing a chord in a …

### Easy Graph Plotting with Pyplot

Graphs (also known as charts) are an indispensible visual aid for conveying a lot of data in an easy-to-digest form. Everyone is familiar with graphs in everyday life, such as those showing trends over time, e.g. world population, global …

### Sierpinski Triangle, drawn by a Turtle

This is a classic fractal drawn with a recursion algorithm and Turtle graphics. The Sierpinski Triangle’s sides are bisected and the triangle they form is removed. The procedure is then applied to the 3 remaining triangles, and to them recursively …

### Square Spiral

This is a very simple introduction to Turtle graphics. The turtle starts in the middle of the window, moves forward a small distance, turns right, moves forward a slightly longer distance, right again, even further this time… until the distance …