On Generative Algorithms

Linetrace Github

As opposed to the biology inspired Hyphae and tree algorithms, the next example is based on hand drawings by John Franzen. Essentially Franzen draws lines where each line traces the outline of the previously drawn line. As each hand drawn line will have slight variations, interesting patterns soon emerge.

Drawing shapes on the computer is fairly straight forward. A line consists of a number of vertices (points) with an edge (segment) between them. To create a triangle you need three edges, and you connect them with three vertices. To draw a circle you do the same thing, but you need sufficiently many vertices to make it "impossible" to see that it is not actually a circle. If you are wondering: there are more sophisticated ways of drawing shapes, but this is an easy one.

This means that drawing these lines the same way that Franzen does can be done by drawing curvy shapes with many vertices in them. The tracing behaviour is a bit more tricky, but there are a number of ways you can try. I wanted the behaviour to mimic how you actually draw the shape little by little, whilst following the previous path. The algorithm I came up with does not quite work—in the sense that it does not avoid collisions—but the results look very nice.

linetrace

To trace the outline you can sample some of the nearby edges on the previous line, calculate the average direction of those edges and add a vertex to the current line along that direction. Then add some random motion to mimic free hand drawing. This seems to work quite well for a while, but there is some "inertia" that can be seen in the results—the shape adapts too slowly.

The amount of noise you add to each vertex is crucial. This noise is what drives the whole system to make interesting shapes since the tracing behaviour is always forced to attempt to replicate both the general movement and some of the random jitter as it progresses.

These images don't really scale down well, so I made a somewhat larger one available.

Next is a somewhat more complex system that also involves lines.