Loading...
Logo
Processing Forum

I think all the graph I draw will not be erase . But the code below only show a circle expanding , if the previous circle I draw will not disappear , it should show many circles but not a expanding circle ..

Copy code
  1. int posx = 500 ; int posy = 250 ; int radius = 50 ;

  2. void setup(){
  3.    background(255,255,255);
  4.    size(1000,500);
  5. }

  6. void draw(){
  7.   ellipse(posx,posy,radius,radius);
  8.   radius = radius + 10;
  9. }

I change the center of the circle , but the result doesn't looks like a circle is moving . It looks I draw many circle , the previous circle doesn't erase ...

Copy code
  1. int posx = 500 ; int posy = 250 ; int radius = 50 ;

  2. void setup(){
  3.    background(255,255,255);
  4.    size(1000,500);
  5. }

  6. void draw(){
  7.   ellipse(posx,posy,radius,radius);
  8.   posx = posx + 10;
  9.   posy = posy + 10;
  10. }

why it appear only a circle when I change the radius , why it appear many circle when I change the center of the circle?

thanks ..

 

Replies(4)

Try this

Copy code
  1. int posx = 500 ; int posy = 250 ; int radius = 50;

  2. void setup(){
  3.    background(255,255,255);
  4.    size(1000,500);
  5. }

  6. void draw(){ 
  7.   background(255,255,255);
  8.   ellipse(posx,posy,radius,radius);
  9.   posx = posx + 10;
  10.   posy = posy + 10;
  11. }
Line 9 will clear the background at the start of each frame.
If I only change the radius , why I don't need to clear the background and the previous circle which with small radius still disappear ?
Because the new one that was drawn on top is bigger and covers the small one
Maybe this example will help. Click to toggle the call to background().

Copy code
  1. boolean b = false;

  2. void setup(){
  3.   size(220,220);
  4.   noStroke();
  5.   ellipseMode(CENTER);
  6. }

  7. void draw(){
  8.   if( b ) background(0);
  9.   translate(110,110);
  10.   fill(random(255),random(255),random(255));
  11.   float r = 20 + 100 * abs(sin(radians((millis()/60))));
  12.   ellipse(0,0,r,r);
  13.   fill(random(255),random(255),random(255));
  14.   rotate(map(millis()%5000,0,5000,0,TWO_PI));
  15.   ellipse(80,0,20,20);
  16. }

  17. void mousePressed(){
  18.   b=!b;
  19. }