While Loop With Mouse Interaction
void setup() {
  size (255, 255);
}
 
void draw() {
  background(0);
  // Start with i as 0
  int i = 0;
  // While i is less than the width of the window
  while (i < width) {
    noStroke();
    // The distance between the current rectangle and the mouse is equal to
    // the absolute value of the difference between i and mouseX
    float distance = abs(mouseX - i);
    // Use this distance as the fill color of rectangle at horizontal location i
    fill (distance);
    rect (i, 0, 10, height);
    i += 10;
  }  
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License