Processing Sessions | The beginning

Today is the start of our processing workshop course with Rob. Previously I had never heard of processing, but from what Ive seen it looks like the outcomes achieved within processing look exciting and fun, so I cant wait to get into writing code properly for my own designs.

In todays session we covered how to call functions like mousePressed, which is an “if” statement. This means that if the statement is true, the following code will become active. The code below is the code for the program we were working on today:

void setup(){
  
  size(800,400);
  frameRate(100);
  colorMode(HSB);
  background(255,255,111);
}
int c = 1;
int d = 1;
void draw(){
  if (mousePressed){
    if (mouseButton==LEFT);{
      
      fill(random(255),155,255);
    }
    
    rect(mouseX,mouseY, c,c);
  }
  
  c = (c+1)%7;
  println(c,d);
}

The void setup determines what the size of the canvas is, the FPS (frames per second), the colour mode the program uses and the background colour. After that, some variables need to be established before the draw setup is completed. The letters “d” and “c” are set to represent the value of “1”, But their use comes into the next part. The void draw setup determines what happens with user input. In this case, its mouse buttons and mouse movement that is going to be what the user interacts with to create their own output. The “if” statements mean that if this function is carried out (in this case its if the user presses the left mouse button) the next piece of code becomes true (active). The next few lines state that if the above statement is true, that depending on the location of the mouse while its being pressed, 100 squares will be drawn (because of the frame rate) per second. These squares will be filled with random colours, and will be drawn at random sizes up to 7% lower or 7% higher than the original established size of the square embedded in the code which in the case in C x C.

Im glad that I was able to enjoy this workshop to the upmost full potential, as I was worried I would struggle to keep up because Im not the quickest of learners. I will be posting more progress on processing soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s