openobject.org

Ben's final hand in

From Physical Programming

Well, that a roller-coaster semester. Let me start by uploading my rationale and the journey I've been on. I started with grand ideas to make a Facebook Application and ended up making pretty pictures in processing.

documentation

In the last 3 weeks I resigned myself to learning and writing stuff in Processing instead of jumping ahead and trying something outrageous like PHP... anyway.

I worked towards using pictures in Processing and ended up with this script (see below) which takes random photos from an album of 100 and displays them. by pressing the up and down arrows you increase or decrease the pixelation, and the pixel colour is taken from the centre of that area. Thanks to Scott for helping me to take my maths and turning it into processing language...

final processing .jar

SCRIPT

int x,y; int n = 1; color cc;


void setup(){

 size(400,400);
 smooth();
 rectMode(CENTER);
 noStroke();

}


void draw(){

 int b = floor ((random (100)));
 PImage myimage;
 myimage= loadImage(b+".jpg");
 image(myimage, 0,0, width, height);
 loadPixels();
 int cw = width/n;
 int ch = height/n;
 for (int c = 1; c<=n; c++) {
   for (int r=1;  r<=n; r++){
     x=floor(((c-1)*cw)+(cw/2));
     y=floor(((r-1)*ch)+(ch/2));
     cc = pixels[y*width+x];
     fill (cc);
     rect(x,y,cw,ch);
   }
 }

}


void keyPressed(){

   if (key == CODED) {
     if (keyCode == UP) {
       n=n+1;
   }
   }
   
       if (key == CODED) {
     if ((keyCode == DOWN) && (n>1)) {
       n=n-1;
   }
   }
   
   
   

}


END SCRIPT

I have also done about 15 other short programs along the way. Because most of them deal with photos, they are too large to put up here all together, so I can show them in class, and I'll bring them in on CD (remember those?).