JoyDivision.frink

View or download JoyDivision.frink in plain text format


/* Make a graphic like the iconic cover of Joy Division's Unknown Pleasures
   album.  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
   }
}

jd = new JoyDivision

for row = 1 to 80
{
   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
   }

   jd.addLine[line]
}

jd.g.show[]


View or download JoyDivision.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 17651 days, 5 hours, 5 minutes ago.