Help with program!!
in
Programming Questions
•
1 year ago
Hi.
I relativity new to Processing and I am in need of some help in my program that I'm trying to make.
Basically I want to create a program which makes four rectangles change to a random colour when the mouse is clicked.
The code I've been trying to work with is below-
I can't figure out a way to make it so that whenever the mouse has been clicked, each rectangle will change to a random colour.
Could somebody help me with this?
int value = 100; // This is defining a global variable
void setup(){
size(600, 600);
}
void draw() {
fill(value);
rect(0, 0, 1000, 1000);
rect(mouseX, mouseY, 1000, 1000);
rect(mouseX, mouseY - 1000, 1000, 1000);
rect(mouseX -1000, mouseY, 1000, 1000);
}
void mouseClicked() {
if(value == 100) {
value = 255;
}
else {
value = 100;
}
}
I relativity new to Processing and I am in need of some help in my program that I'm trying to make.
Basically I want to create a program which makes four rectangles change to a random colour when the mouse is clicked.
The code I've been trying to work with is below-
I can't figure out a way to make it so that whenever the mouse has been clicked, each rectangle will change to a random colour.
Could somebody help me with this?
int value = 100; // This is defining a global variable
void setup(){
size(600, 600);
}
void draw() {
fill(value);
rect(0, 0, 1000, 1000);
rect(mouseX, mouseY, 1000, 1000);
rect(mouseX, mouseY - 1000, 1000, 1000);
rect(mouseX -1000, mouseY, 1000, 1000);
}
void mouseClicked() {
if(value == 100) {
value = 255;
}
else {
value = 100;
}
}
1