Hi,
I am trying to create a sketch that does the following:
LEFT mouse button allows circle to be moved
RIGHT mouse button allows circle size to change when moving toward and away from centre
CENTRE mouse button changes colour of circle from red to blue. A second click should bring it back to its previous fill colour. This last thing is what I am stuck on.
I would very much appreciate if anyone has any ideas on how this can be done.
Thanks,
Shane
I am trying to create a sketch that does the following:
LEFT mouse button allows circle to be moved
RIGHT mouse button allows circle size to change when moving toward and away from centre
CENTRE mouse button changes colour of circle from red to blue. A second click should bring it back to its previous fill colour. This last thing is what I am stuck on.
I would very much appreciate if anyone has any ideas on how this can be done.
- float x = 300, y = 150, diameter=100;
- void setup() {
- size(600, 300);
- stroke(1);
- }
- void draw() {
- frameRate(24);
- background(#36B5F2);
- fill(255);
- if (((dist(mouseX, mouseY, x, y))<(diameter/2))&&(mousePressed == true)) {
- if (mouseButton == LEFT) {
- x = mouseX;
- y = mouseY;
- }
- else if (mouseButton == RIGHT) {
- if (((dist(mouseX, mouseY, x, y))-(dist(pmouseX, pmouseY, x, y)))>(0)) {
- diameter++;
- }
- else if (((dist(mouseX, mouseY, x, y))-(dist(pmouseX, pmouseY, x, y)))<(0)) {
- diameter--;
- }
- }
- else if (mouseButton == CENTER) {
- fill(#FF0000);//red
- }
- else if (mouseButton == CENTER) {
- fill(#0000FF);//blue
- }
- }
- ellipse(x, y, diameter, diameter);
- fill(255);
- }
Thanks,
Shane
1