Sunday, October 3, 2010

Light Painting Automata - 10/3

/*The code in this exercise acts heavily on the mouseX, mouseY, and pmouseX, pmouseY
data. Depending on the difference between the current mouse position and previous mouse
position, Processing draws ellipses the sizes of which correspond to that difference.
At the same time, bezier curves are beign drawn with an origin at the mouse cursor and having random
control point values. By holding down the LMB, these bexier curves are drawn as straight lines.
The RGB values of the ellipses, beziers, and lines all change depending on the current mouse position
on the stage.*/

void setup(){
  size(600,600);
 smooth();
 background(0);

}
void draw(){
fill( 0,0,0,5);
  rectMode(CORNER);
  rect(0,0,width,height);
  noFill();
  noStroke();
  stroke(pmouseY,pmouseX,pmouseX-pmouseY);
  if (mousePressed){
    line(mouseX,mouseY,random(width),random(height));
    fill(mouseY,mouseX,mouseX,255);
  }else{
    bezier(mouseX,mouseY,random(width),random(height),random(width),random(height),random(width),random(height));
    fill(mouseX,mouseY,mouseX-mouseY,255);
  }
    ellipse(mouseX,mouseY,mouseX-pmouseX,mouseY-pmouseY);
}

No comments:

Post a Comment