Fibonacci Spectrum

This is a spectrum of sums of Fibonacci numbers.


During each frame, Fibonacci numbers are chosen randomly from a list for inclusion in a sum. Each sum determines the hue and x position of a vertical line that is added to the spectrum. The strokes of the lines are given some transparency, so that the color intensities in the spectrum reflect frequencies of occurrences of particular sums. Note, from the image, that some sums are considerably more likely than others.

Code for Processing Python Mode:

# fibonacci numbers
fibs = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377]
# opacity of stroke in percent
alph = 10
# likelihood of each number to be included in tot during each frame
likelihood = 0.25
def setup():
    size(987, 144)
    colorMode(HSB, width, 100, 100, 100)
    background(0, 0, 0)
def draw():
    # total of the randomly chosen fibonacci numbers
    tot = 0 
    for i in range(len(fibs)):
        if random(1) < likelihood:
            tot += fibs[i]
    # tot determines the hue and the x location of the line
    stroke(tot, 100, 100, alph)
    line(tot, 0, tot, height)
4 Likes