JoyDivisionAnimated.frink

View or download JoyDivisionAnimated.frink in plain text format


/* Make a graphic like the iconic cover of Joy Division's Unknown Pleasures
   album.

   Did you know that these images came from recordings of radio emissions from
   pulsars?  That's why they're so interesting and clean.

   See:

   http://blogs.scientificamerican.com/sa-visual/2015/02/18/pop-culture-pulsar-origin-story-of-joy-divisions-unknown-pleasures-album-cover-video/
*/

class JoyDivision
{
   var g is graphics = new graphics

   var row = 0

   var rowSpacing = 1.25

   var rowWidth = 50

   var rowHeight = 10

   var bgcolor = new color[0,0,0]
   var fgcolor = new color[1,1,1]

   new[] :=
   {
      g.backgroundColor[bgcolor]
      g.color[fgcolor]
      g.stroke[.3]
   }

   /** Add a line of points to the bottom of the image.  Each point should be
       between 0 and 1. */

   addLine[points] :=
   {
      filled = new filledPolygon
      filled.addPoint[0,row]
      
      trace = new polyline
      size = length[points]
      xstep = rowWidth / size
      x = 0
      
      for point = points
      {
         y = row - point * rowHeight
         filled.addPoint[x, y]
         trace.addPoint[x, y]
         x = x + xstep
      }
      filled.addPoint[x, row]
      
      g.color[bgcolor]
      g.add[filled]
      g.color[fgcolor]
      g.add[trace]
      
      row = row + rowSpacing
   }
}

win = new graphics.show[]

anim = new Animation[1/10 s]

frames = 80
var lines = new array

for row = 1 to frames
{
   line = new array
   lasty = 0
   for x = -20 to 25
   {
      y = .2 * -(abs[x]-20)/20
      line.push[abs[randomGaussian[0,(y+ 3 lasty)/4]]]
      lasty = (y+ 3 lasty)/4
   }
   lines.push[line]
}


for frame = 0 to frames-1
{
   jd = new JoyDivision
   for row = 0 to frames-1
      jd.addLine[lines@((row+frame) mod frames)]

   // Set top border so baselines stay the same.
   gr = jd.g
   gr.color[0,0,0,0]
   gr.line[0,-6,1,-6]
   gr.line[0,105,1,105]
   win.replaceGraphics[gr]
   anim.add[gr]
}

anim.write["JoyDivision.gif", 400, 800]
//browse["JoyDivision.gif"]




View or download JoyDivisionAnimated.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen was born 17591 days, 17 hours, 48 minutes ago.