Christmas Fireflies

Exploring some more fun and simple examples of generative art I stumbled on this example which uses Perlin Noise to generate a sort of "Drunkards Walk" around the canvas.

first

I stared with plain white circles but then thought it might be more fun to try using random colours for each dot. The effect is very much like a house fly or fire fly flying around the screen and leaving coloured dots behind, almost as if they were stringing up Christmas lights as they moved about - hence the name of this example.


tx = 0
ty = 1000

def setup():
  global displayWidth, displayHeight
  size(displayWidth, displayHeight)
  background(0)
  fill(255)
  stroke(255, 25)


def draw():

  global tx, ty
  
  x = map(noise(tx), 0, 1, 0, width)
  y = map(noise(ty), 0, 1, 0, height)
  
  tx += 0.01
  ty += 0.01        
  
  r = random(255)
  g = random(255)
  b = random(255)
  
  fill(r, g, b)
  circle(x, y, 5)
    
  if x <= width / 4 and y <= height / 4:
    noLoop()
    

second

I found that leaving this sketch to run too long ruined the effect against the black background so put in an arbitrary end condition when the firefly gets to the top left quadrant of the canvas.