Spirograph², 2024
Pen plot: Recursive spirals that interleave horizontal and vertical branches
Spirograph² is a generative pen plot of branching spirals, inspired by the way mycelia grow. Every mark in the drawing is a half circle. I wrote a recursive algorithm in Processing that chains half circles into spirals and grows new branches off of them at right angles, interleaving horizontal and vertical lines of spirals as it spreads across the page. The drawings are plotted in pen with an Axidraw.
I made Spirograph² in 2024 for Golan Levin’s Drawing with Machines course at Carnegie Mellon. The drawing is made by a single recursive function in Processing that only draws half circles.
How it works
The function works along a straight line. Given a stretch of line, it picks a new point partway along it and draws a half circle from the start of the stretch to that point. The first stretch runs horizontally across the middle of the page.
To keep these diagrams readable, the new point always lands 70 percent of the way along.
From the new point, the function calls itself twice, and both of the new half circles go on the opposite side of the line from the first one. One call heads back toward the start of the stretch, and the other heads on toward the end.
Each of those calls does the same thing again, and so on, until the stretches are less than 3 pixels long. If you follow only the calls that head back, each half circle is smaller than the one before it and sits on the opposite side of the line, so together they curl into a spiral (dark, below). The calls that head on start new spirals further along, which is where the chain of smaller spirals along the line comes from.
A half circle can also start a branch. The branch starts at the top of the half circle and runs straight away from the line, and the function fills it in the same way, just turned 90 degrees. Branches off a horizontal line are vertical, and branches off a vertical line are horizontal again. This back and forth between horizontal and vertical is what I mean by interleaved. The bigger the half circle, the more likely it is to branch, so big ones almost always do and small ones rarely do.
Only one branch is shown. In the sketch, every half circle gets a chance to branch.
Two variants
The repository has two variants of the sketch, v2 and v3. Both use the same base algorithm but implement parts of it differently. I wrote them while working out how to get the most beautiful drawings out of it. They differ in three ways:
Where the new point lands. In v2 it can land anywhere along the stretch. In v3 it always lands between 50 and 90 percent of the way along, so each half circle in a spiral is between half and nine tenths as wide as the one before it, which makes the spirals more regular.
How far branches reach. A branch ends 1.4 times the width of its half circle away from the line in v2, and 1.15 times in v3.
How often branches happen. The branching chance in v3 is double the one in v2, so more of the medium and small half circles branch.
The sketch saves each drawing as an SVG. The canvas is 1056 x 816 pixels, which is a landscape 11 x 8.5 inch sheet at 96 pixels per inch. I plotted the drawings on an Axidraw.
The source code for both variants is on GitHub.