Bricolage programming example

I wrote this for the PPIG newsletter last year, but as there has been a hold-up in publishing the newsletter, I’ve put it here:

/**
* GeSHi (C) 2004 – 2007 Nigel McNie, 2007 – 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
*/
.java .de1, .java .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.java {font-family:monospace;}
.java .imp {font-weight: bold; color: red;}
.java li, .java .li1 {background: #ffffff;}
.java .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.java .li2 {background: #f8f8f8;}
.java .kw1 {color: #000000; font-weight: bold;}
.java .kw2 {color: #000066; font-weight: bold;}
.java .kw3 {color: #003399;}
.java .kw4 {color: #000066; font-weight: bold;}
.java .co1 {color: #666666; font-style: italic;}
.java .co2 {color: #006699;}
.java .co3 {color: #008000; font-style: italic; font-weight: bold;}
.java .coMULTI {color: #666666; font-style: italic;}
.java .es0 {color: #000099; font-weight: bold;}
.java .br0 {color: #009900;}
.java .sy0 {color: #339933;}
.java .st0 {color: #0000ff;}
.java .nu0 {color: #cc66cc;}
.java .me1 {color: #006633;}
.java .me2 {color: #006633;}
.java span.xtra { display:block; }

My paper for PPIG 2010 was about bricolage programmers, in
particular artists who write software without any clear plan, but just
reacting to the results of each edit. From feedback it is clear that
the paper could have done with a decent case study, so I thought I’d
contribute the following example to this newsletter. This is not
meant to illustrate great art, or indeed great programming, but just
to act as a talking point when discussing alternative approaches of
programming. Full versions of the examples are available
on sketchpatch.

Imagine a visual artist, programming their work using the Processing
environment, a language based on Java. They begin with an urge to
draw superimposed curved lines, and come up with the following
program, shown with its output:

  1. float rx() { return(random(width)); }
  2. float ry() { return(random(height)); }
  3.  
  4. void draw() {
  5.   background(255);
  6.   for (int i = 0; i < 20; ++i) {
  7.     bezier(rx(), ry(), rx(), ry(), rx(), ry(), rx(), ry());
  8.   }
  9. }

On seeing the output, they are struck first by how hairy it looks,
but then by the suggestion of a scribble. They decide that they are
interested in the latter, and change their program to join the curves
together, removing the hairiness and accentuating the scribble:

  1. void draw() {
  2.   background(255);
  3.   float x = rx(); float y = ry();
  4.   for (int i = 0; i < 5; ++i) {
  5.     float x1 = rx(); float y1 = ry();
  6.     bezier(x, y, rx(), ry(), rx(), ry(), x1, y1);
  7.     x = x1; y = y1;
  8.   }
  9. }

The artist reflects upon the letter-like quality of the scribble
forms, and decides to try writing letters across the page, grouped
into word-like forms:

  1. float letterSpace = 30;
  2.  
  3. float rx() { return(random(letterSpace + 10)); }
  4. float ry() { return(random(height 10)); }
  5. int rWordlen() { return(3 + int(random(4))); }
  6.  
  7. void draw() {
  8.   background(255);
  9.   int letters = (int) (width / letterSpace) 4;
  10.   int wordLen = rWordlen();
  11.   int word = 0;
  12.   float x = rx(); float y = ry();
  13.   for (int letter = 0; letter < letters; ++letter) {
  14.     float ox = letter * letterSpace + word * letterSpace;
  15.     if (wordLen == 0) {
  16.       wordLen = rWordlen();
  17.       word++;
  18.     }
  19.     for (int i = 0; i < 3; ++i) {
  20.       float x1 = rx() + ox; float y1 = ry();
  21.       bezier(x, y, rx() + ox, ry(), rx() + ox, ry(), x1, y1);
  22.       x = x1; y = y1;
  23.     }
  24.   }
  25. }

The output has a handwritten quality, almost appearing to be readable,
a quality of `automatic writing’ used by mystics to supposedly channel
the spirit world. This may bring further conceptual development in
our artist’s mind, but at this point we leave will them pondering.

Leave a Reply

Your email address will not be published. Required fields are marked *