Subdividing Equilateral Triangles in Processing

With some time to kill on the Ferry (once it got dark), I was casting about for a quick code project I could play around with. I wanted to use photography as the input to generate an image, and came up with this subdividing triangles thing.

Above: The code output. Triangles.

Above: The source image, Horseshoe Bay.

It’s a Processing sketch that draws a triangle, filled with the colour from its centre point. Clicking on a triangle subdivides it into four, each filled with a new colour from its own center. The idea is that each click will selectively increase the resolution of the image. Parts of the image can be made identifiable, albeit in a triangular-sort-of-way, through furious clicking.

The sketch is a bit quirky – there are some rounding errors that stop the lines lining up perfectly, and the recursive hit testing for clicking on a tri doesn’t always work. Rather than fix these bugs, I’m going to move on and rebuild it in Scriptographer: it’d be a nice tool to have in Illustrator.

If you do want to try it out, the sketch can be downloaded here: equilateral_triangles

Update: I’ve completed a quick Scriptographer thing of this. It’s available here.