User Tools

Site Tools


more_cm_examples

More Examples

These examples of using Continuous mode, with both continuous drawing and one-time drawing (via noLoop), come from the Processing website.

Draws circles, with a programmer-defined circles function. Note that draw runs only once.

void setup() {
  size(200,200);
  noStroke();
  background(255);
  fill(0, 102, 153, 204);
  smooth();               // look this one up
  noLoop();
}

void draw() {
  circles(40, 80);
  circles(90, 70);
}

void circles(int x, int y) {
  ellipse(x, y, 50, 50);
  ellipse(x+20, y+20, 60, 60);
}

Draws rectangles that follow the mouse. Note the use of system variables mouseX and mouseY to capture the current position of the mouse. The motion happens because of the continuous calling of the draw function.

void setup() {
  size(200, 200);
  rectMode(CENTER);
  noStroke();
  fill(0, 102, 153, 204);
}

void draw() {
  background(255);
  rect(width-mouseX, height-mouseY, 50, 50);
  rect(mouseX, mouseY, 50, 50); 
}


Back to Continuous Mode

more_cm_examples.txt · Last modified: 2007/09/13 06:40 by scarl