openobject.org

S3239499 Processing sketch - PROJECT 3

From Physical Programming

Media:processing_sketch.zip

To complete my Processing Sketch I used codes from the processing site and from tutorials by Andy West at http://vimeo.com/switchboard as a starting point. The codes used were blended together and then altered to create something new.

The processing sketch I now I have consists of a mustard yellow background with flashing coloured points/dots and a thick horizontal line that flashes and slides up the window.

To begin, a window needs to be created. To do this, the code


size(width, height);


is typed. The width and height are replaced with values of '500,500' which relate to the width of the window and its height.

When the play button is clicked

Image:play_button.jpg

the window appears with a grey background.

Image:grey_background.jpg

To change the background colour I used the code


void setup() {

 size(500,500); //size of window

}

void draw(){

 background(255, 200, 0);

}


The numbers next to 'background' correlate to their Red Green Blue (RGB) colour values. The numbers shown create a mustard yellow colour.

Image:mustard_yellow_background.jpg

Now to begin drawing: To draw the horizontal line the codes below were used:


float yPos = 0.0;

void setup()

size(500,500);

void draw()

 background(255, 200, 0);
 yPos = yPos - 1.0;
 if(yPos < 0
 yPos = height; // all of this allows the line to repeat 

its sequence

 line(0, yPos, width, yPos);


and to make the horizontal line thicker, slide up the window and flash multiple colours the codes below were added in certain parts of the already existing code:


 frameRate(30); //controls speed of the line
 strokeWeight(100); //thickens the line
 stroke( random(255), random(255), random(255) ); //causes the line to flash multiple colours


Now the points/dots: To add points/dots to the window the codes below were used:


point( random(width), random(height)); // creates points at 

random positions


and to make them larger and flash multiple colours, the following codes were used:


 strokeWeight(20); // this sets the width ofthe line in pixles
 
 stroke( random(255), random(255), random(255) ); // gives each 

point a random colour


In the end the order of the code looked like this:


float yPos = 0.0;

void setup() {

 size(500,500);
 frameRate(30);

}

void draw(){

 background(255, 200, 0);
 strokeWeight(100);
 yPos = yPos - 1.0;
 if(yPos < 0) {
   yPos = height;
 }
 
 line(0, yPos, width, yPos);
 strokeWeight(20);
 stroke( random(255), random(255), random(255) );
 point( random(width), random(height));

}


It was very difficult to get a good picture of the processing sketch in action so to see it for yourself, you're going to have to download and open the zip file.


References:

http://processing.org/ http://vimeo.com/7578280