How to use this code with mousePressed?

I want to appear this circile when mouse is pressed only. Please help with this

float   angle  =   0.00; 
float  offset  =  60 ; 
float   scalar  =   30; 
float   speed   =  0.05; 

void setup  () {
  size   (120, 120);  
  smooth  () ;
}


void  draw  () {  
  float  x  =  offset  +  cos (angle)  *  scalar ; 
  float  y  =  offset  + sin  (angle)  * scalar ; 
  ellipse  ( x, y,  40, 40); 
  angle  +=  speed;
}
1 Like

Hey There!

There is a void mousePressed method within processing !

https://processing.org/reference/mousePressed_.html

I want to make it like when and where i click the mouse this will appear there only. I am unable to figure out. would u plz help me?

1 Like

Just put all that code into the mousePressed() method from draw()!

Yes.

Also look at mouseX and mouseY in the reference

https://www.processing.org/reference/