xxxxxxxxxx
float r = 255;
float b = 255;
float g = 0;
void setup() {
size(500, 500);
}
void draw() {
background(r,g,b);
stroke(255);
line(width/2,0,width/2,height);
line(0,height/2,width,height/2);
// If the mouse is on the right hand side of the window, increase red.
// Otherwise, it is on the left hand side and decrease red.
if (mouseX > width/2) {
r = r + 1;
fill(random(255));
rect(width/2,0, width/2,height/2);
} else {
r = r - 1;
}
// If the mouse is on the bottom of the window, increase blue.
// Otherwise, it is on the top and decrease blue.
if (mouseY > height/2) {
b = b + 1;
fill(random(255));
rect(0,height/2, width/2, height/2);
} else {
b = b - 1;
}
// If the mouse is pressed (using the system variable mousePressed)
if (mousePressed) {
fill(0,255,0);
rect(0,height/2,width/2,height/2);
g = g + 1;
} else {
g = g - 1;
}
}