MousePressed query
in
Programming Questions
•
7 months ago
Hey guys! Pretty new to programming so im having a tinker around with this function (mousePressed). But for the life of me i cannot seem to do what i want to do!
I'm just trying to create an ellipse at the mouse location and fill it with a certain color each time i click. This is my code:
int rad = 50; //ellipseRadius
void setup() {
size(300,300);
background(255);
}
void draw () {
}
void mousePressed () {
int x = mouseX;
int y = mouseY;
int r = 160; //R, B and G are just random numbers
int b = 255;
int g = 190;
fill(0,0,b);
ellipse(x,y,rad,rad);
}
So for instance, the first time i click, i want it blue, the second time i click, maybe i want it light green. No set color really. But i would like it to cycle the colors, so once it reaches the last color, it starts back at blue. Hope this makes sense :)
Any and all help would be appreciated :)
Edit** Is this where a 'case' would be a help?
I'm just trying to create an ellipse at the mouse location and fill it with a certain color each time i click. This is my code:
int rad = 50; //ellipseRadius
void setup() {
size(300,300);
background(255);
}
void draw () {
}
void mousePressed () {
int x = mouseX;
int y = mouseY;
int r = 160; //R, B and G are just random numbers
int b = 255;
int g = 190;
fill(0,0,b);
ellipse(x,y,rad,rad);
}
So for instance, the first time i click, i want it blue, the second time i click, maybe i want it light green. No set color really. But i would like it to cycle the colors, so once it reaches the last color, it starts back at blue. Hope this makes sense :)
Any and all help would be appreciated :)
Edit** Is this where a 'case' would be a help?
1