This is a simple harmonograph simulator to generate random-ish harmonographs. It asks for the number of pendulums, and exits if the number is 0. It also asks for the frequency spread, which means roughly, how far from integer may the …

## Spectral Harmonographs

This Python + Pygame program draws the trace of 4 decaying sine waves, 2 per axis, with rainbow colours. It generates a sequence of random harmonographs.

A harmonograph is a mechanical device typically seen in science museums, that has two …

## Harmonograph in Pygame

You may have seen those devices at the Science Museum or Exploratorium or Techniquest… There’s a drawing surface and some arrangement of pendula with a pen touching the paper on the drawing surface, set in motion it draws these …

## Stars and Stripes

A variation on the Stars and Stripes American Flag for Independence Day. It’s an exercise in the use of transparency in Pygame. The stripes are made transparent so the stars image behind shows through.…

## 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 …

## Tweetable Python Code Golf

Code Golf is the amusement of writing as short as possible a program to perform a given task. So for example, if the task is to compute the average of a list of numbers (which could be changed at any …

## Fast Mandelbrot Set by QuadTree

Most Mandelbrot Set programs proceed along the display area, pixel by pixel horizontally, row by row from top to bottom. This one doesn’t. It divides up the screen into 6 horizontal squares in 2 rows, then for each one, checks …

## Extensible Harmonograph

Often seen in science museums, the harmonograph is a device that combines wave motions (e.g. from some pendulums) to move a pen resting on a sheet of paper. These movements result in attractive patterns. This device can be simulated easily …

## 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 …

## Random Walk

A colourful random walk. The basic idea is very simple: choose a random heading in the range 0:360 degrees. Step in that direction. Choose another random heading & step again. Do this 2,000 times. As a bonus, we go through …

## Turtle Star

A very simple Turtle program. Turtle can draw intricate shapes using programs that repeat simple moves.

Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzig …

## 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 …

## Naive Mandelbrot Set

This is your basic Mandelbrot Set plotter. Very little effort made to speed it up, except for plotting top & bottom pixels together as they’re mirrored across the x-axis. Later I’ll show you some much faster programs!

The heart of …

## Fractal Tree

This program draws a ‘tree’ by drawing a trunk (initially; later it’s a branch) and appending a tree, recursively. Uses Pillow.…

## Black & White Harmonographs

Black & White Harmonographs. Because colour gets boring after a while…

Harmonographs are those devices often seen in science museums, that consist of a pen connected to a number of pendulums, suspended over a sheet of paper on a board, …

## Lorenz Attractor

These 3D pictures (except the last) were generated by a Python + Vpython program, translated from Paul Bourke’s C program (which has a bunch more pretty pictures). See below for code.

The **Lorenz system** is a system of ordinary differential …

## Mandelbrot Gallery

**Benoit B.** **Mandelbrot** (20 November 1924 – 14 October 2010) was a Polish-born, French and American mathematician, noted for developing a “theory of roughness” and “self-similarity” in nature and the field of fractal geometry to help prove it, which …

## Fractal Python Programs

These fractals were generated by Python programs from the Active State website. They often make use of recursion.

**Recursion** is the process of repeating items in a self-similar way. For instance, when the surfaces of two mirrors are exactly parallel …

## Buddhabrots – Ghosts of the Mandelbrot Set

The Buddhabrot is an interesting variation on the well-known Mandelbrot Set, invented by Melinda Green in 1993. It’s a density plot of the orbits of points outside the Mandelbrot Set. The Mandelbrot Set is defined as the set of …

## Orbits of The Starship Mandelbrot, in 3D

Orbits of The Starship Mandelbrot, in 3D.

In fractal mathematics, an orbit is the sequence of points in the complex plane traced out by the iteration of the function that generates the fractal. In the case of the Mandelbrot Set, …

## Online 3D Harmonograph

### Online 3D Harmonograph

This is an online 3d harmonograph version of those harmonograph devices often seen in science museums – except that instead of drawing pretty harmonic patterns on paper, here we plot them in 3D-space! Glowscript code and my …