How do i update 1 circle instead of it drawing a circle every time you move the mouse?

edited April 2014 in How To...

here is the code

int cx = 200;
int cy = 200;

void setup(){
  size(400,400);
}

void draw(){ 
  float mx = mouseX;
  float my = mouseY;
  float radius = sqrt(sq(mouseX-cx) + sq(mouseY-cy));
  ellipseMode(RADIUS);
  ellipse(cx,cy,radius,radius);
}

Answers

  • here

    int cx = 200; 
    int cy = 200;
    
    void setup() { 
      size(400, 400);
      background(255);
    }
    
    void draw() { 
      background(255);
      float mx = mouseX; 
      float my = mouseY; 
      float radius = sqrt(sq(mouseX-cx) + sq(mouseY-cy)); 
      ellipseMode(RADIUS); 
      ellipse(cx, cy, radius, radius);
    }
    
  • background(255); 
    

    does the trick

  • No i mean that I do not want it to draw a ellipse wherever the mouse goes. I want there to be 1 ellipse that updates the size.

  • it changes the size according to mouse position.

  • yeah but i only want 1 ellipse

  • Answer ✓

    did you run my code?

    ;-)

  • yep thanks!!!!

Sign In or Register to comment.