Sunday, 27 July 2014

Week 2 Processing sketches

Storing input + linking mouse cursor's position to the HSB spectrum + mouse-pressed condition to activate colour switch
Particle system + mouse-pressed condition to toggle on/off + partially successful effort in linking mouse cursor's position to the HSB spectrum to change the colour of particles

Color changing on mouse press and pattern created by eclipses leaving traces, sizes depend on the speed of the mouse.
Code:

int barWidth = 1;
int lastBar = 1;
  
void setup(){
  size(1000,1000);
  colorMode(HSB,height,height,height);
  noStroke();
}

void draw(){
  variableEllipse(mouseX, mouseY, pmouseX, pmouseY);
  
  
  int whichBar = mouseX/barWidth;
  if (whichBar != lastBar)
{
  if (mousePressed) {

  int barX = whichBar * barWidth;
  fill(mouseX,mouseY,width,50);
   lastBar = whichBar;

  } 
  else {

  }
}
}
void variableEllipse(int x, int y, int px, int py) {
  float speed = abs(x-px) + abs(y-py);
  stroke(speed);
  ellipse(x, y, speed, speed);
}

No comments:

Post a Comment