/**
* Scope demonstration.
*
*
Elie Zananiri
* CART 253, Winter 2008
*/
// global variables, accessible throughout the program
int circleSize = 25;
void setup() {
size(400, 400);
smooth();
background(255);
stroke(0);
// xPos and yPos are local variables
int xPos = 200;
int yPos = 100;
circle(xPos, yPos);
fill(255, 0, 0);
ellipse(width/2, height/2, circleSize, circleSize);
}
void draw() {
// mouseX and mouseY are global built-in variables
circle(mouseX, mouseY);
}
// x and y are local variables passed as parameters
void circle(int x, int y) {
// fillColor is a local variable
int fillColor = 255;
fill(fillColor);
ellipse(x, y, circleSize, circleSize);
}