I’m sure this has been asked a million times, so sorry for the repetition.
I’m having a hell of a time with mousePressed, mouseClicked, etc
To confuse me further I’ve just seen an example in the guidance for beginners that says “if(mouseHasBeenClicked)” - is that for real?! if so, why is it not recognized by 3.5.4 ?
Anyway… I’m trying to do what seems to me at least a very simple thing:
float xCircle = (256);
float yCircle = (256);
float hCircle = (0);
float wCircle = (0);
void setup(){
size (512,512);
}
void draw(){
background(0);
}
void mouseClicked (){
Circle();
}
// println(wCircle);}
//if ((wCircle > 127.99999) && (xCircle > 256 - 64))
//{ xCircle = xCircle-1;}
void Circle(){
noFill();
stroke(128);
strokeWeight(5);
ellipse (xCircle,yCircle,hCircle,wCircle);
if (hCircle < 128)
{hCircle = hCircle+1;
wCircle = wCircle +1;
}
}
the idea being, when I click the mouse, the Circle function is called. But nothing happens.
so, how about not calling a function but rather just drawing a circle:
float xCircle = (256);
float yCircle = (256);
float hCircle = (0);
float wCircle = (0);
void setup(){
size (512,512);
}
void draw(){
background(0);
}
void mouseClicked (){
noFill();
stroke(128);
strokeWeight(8);
ellipse(256,256,128,128);
}
// println(wCircle);}
//if ((wCircle > 127.99999) && (xCircle > 256 - 64))
//{ xCircle = xCircle-1;}
void Circle(){
noFill();
stroke(128);
strokeWeight(5);
ellipse (xCircle,yCircle,hCircle,wCircle);
if (hCircle < 128)
{hCircle = hCircle+1;
wCircle = wCircle +1;
}
}
so now the circle appears for a brief moment - not when I press the mouse but rather on relase.
OK so here’s the silly question which I feel incredibly dumb for asking but searching the various mouse functions in reference has not helped me answer…
actually it might be a two-part question…
-
How do I get the circle to be drawn ON mouse click and STAY there?
-
How to I call the function Circle(); and get it not to disappear when I release the mouse?
Somebody please end my misery!