Golden Spiral Collages

Over at Randomly Inspired!, one of my other projects, I have just released something that I think you’ll find interesting…and perhaps even beautiful. The golden ratio has been appearing in my life a lot lately: from the Fibonacci sequence to paintings by da Vinci to flowers and the shape of galaxies, this form is found in so many places in nature and art. I knew I wanted to put together something using this relationship, and it finally came together when I saw a golden spiral tattoo on someone at the gym.


I’m not into tattoos, but I will give a nod to this particular one—so much classier than an ex-girlfriend’s name or a poorly translated Chinese character. I had a flash of inspiration and thought golden spirals would make a great match for the amazing public domain photo collection at the Flickr Commons (oh, the things you think of while on the stair climber!).

So, I wrote some code that turns random photos from the Commons into golden spiral collages. You can see them here:

Golden Spiral Collages

I find that the proportions of the golden ratio are a pleasing way to view these repeated images. The form also creates interesting relationships between the larger picture and its components, as in this example:

Ellen Crosby Book Talk
(photo: The Library of Virginia)

Sometimes, the spiraling plays with your sense of proportion and depth, making it seem like the photo is a single view, continuing on and on in the repeated frames.

Programming and Troubleshooting Notes:

  • I write and test code on my laptop before pushing it “live.” A great thing about Ruby on Rails is that my development environment is almost exactly the same as the Heroku hosting platform. Rails ensures that the version of Ruby and all the helper applications are the same in both places, so there’s a high probability that a problem encountered in development will also appear in production (and vice versa). I’ve written my fair share of bugs, but when I’ve finally nailed a piece of code in development, it usually works in production. However, this time around I encountered an interesting problem where the Image Magick gem would refuse to fetch remote content when it was deployed on the live site. It turns out that Heroku had disabled this feature (for security reasons), thereby creating a slight difference between the two environments. While finding a workaround was easy, the hard part was discovering this discrepancy!
  • The final version of the program that generates the golden spirals was surprisingly brief. I guess this ties into why the self-repeating form is so prevalent in nature: it’s a very efficient way to encode a growth pattern. However, there was a lot of trial and error before I found the simplest way to turn the golden spiral concept into code. First, I tried the outside=>inside approach (maybe I should’ve begun with a middle-out scheme), starting with the largest block of the golden spiral and working towards smaller blocks. The problem with this method is that individual pixels can’t be cut in the middle, meaning that the precision of this method becomes sloppier (yes, very scientific term) as the size of the building blocks decrease. The solution was to reverse the process, starting with the smallest blocks and adding the larger ones to it. I got the idea by looking at this graph:
    By 克勞棣 (CC BY-SA 4.0) via Wikimedia Commons.

    This construction scheme was aided by the fact that Image Magick will scale an image to any resolution—even as small as 1×1! This meant that the photo collages could be built as Fibonacci spirals, an approximation of the golden ratio which gets more accurate as the blocks get larger. Here’s a table showing how successive pairs of the Fibonacci sequence converge on the golden ratio:

    Fibonacci Numbers Ratio
    1 1 1
    1 2 2
    2 3 1.5
    3 5 1.66666666666667
    5 8 1.6
    8 13 1.625
    13 21 1.61538461538462
    21 34 1.61904761904762
    34 55 1.61764705882353
    55 89 1.61818181818182
    89 144 1.61797752808989
    144 233 1.61805555555556
    233 377 1.61802575107296
    377 610 1.61803713527851
    610 987 1.61803278688525
    987 1597 1.61803444782168
    1597 2584 1.61803381340013
    2584 4181 1.61803405572755
    4181 6765 1.61803396316671
    6765 10946 1.6180339985218
    10946 17711 1.61803398501736
    17711 28657 1.6180339901756
    28657 46368 1.61803398820533
    46368 75025 1.6180339889579
    75025 121393 1.61803398867044
    121393 196418 1.61803398878024
    196418 317811 1.6180339887383
    317811 514229 1.61803398875432
    514229 832040 1.6180339887482
    832040 1346269 1.61803398875054
    1346269 2178309 1.61803398874965


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close