Animación en Loop infinito

Hola,

Quiero programar que la siguiente animación se repita indefinidamente cada segundo o segundo y medio, de forma que siempre estén saliendo circunferencias nuevas. ¿Podéis ayudarme? Gracias por adelantado.


void setup(){
  
  size(270,540);
  background(0,0,0);
  noStroke();
} 

int x=0;
int y=255;

void draw (){
  background(0,0,0);
  strokeWeight(3);
  stroke(255,255,255);
  noFill();
  circle(width/2, height/2, 30);
  stroke(255,255,255,y);
  circle(width/2, height/2, 30+x);
  x=x+1; 
  y=y-1;
}

I‘m not sure if i got what you want, but maybe something like this? :

float s = 0;
float y = 0;
float f = 10;

void setup() {
   size(300, 600);
   frameRate(10);
}
void draw() {
   background(255);
   for (int i = 30; i > 0; i--) {
      ellipse(200, 200+y, i*f+s, i*f+s);
   }
   s++;
   y--;
   if (s > f) s = 0;
}

gracias por la respuesta, pero es mas bien algo como la animación, la onda que se expande ha de repetirse cada segundo. gracias!

Circle[] circles;

void setup() {
   size(screen.width, screen.height);
   
   circles = new Circle[5];
   
   for (int i = 0; i < circles.length; i++) {
      circles[i] = new Circle(screen.width/2,screen.height/2,20, color(255, 255, 0, 100));
   }
}

void draw() {
   background(255);
   for (int i = 0; i < circles.length; i++) {
      circles[i].display();
      //circles[i].move(0, -1);
      circles[i].scale(1);
      circles[i].fade(3);
   }
   
   if (frameCount%30 == 0) {
      pushCircles();
   }
   
}

void pushCircles () {
   for (int i = 0; i < circles.length-1; i++) {
      circles[i] = circles[i+1];
   }
   circles[circles.length-1] = new Circle(screen.width/2,screen.height/2,20,color(255,255,0));
}

class Circle {
   PVector pos;
   float s;
   color cFill;
   
   Circle (float x, float y, float s_, color f) {
      pos = new PVector(x, y);
      s = s_;
      cFill = f;
   }
   
   void move(float x, float y) {
      pos.add(new PVector(x, y));
   }
   
   void scale(float s_) {
      s += s_;
   }
   
   void fade(float a) {
      cFill = color(red(cFill), green(cFill), blue(cFill), alpha(cFill) - a >= 0 ? alpha(cFill) - a : 0);
   }
   
   void display() {
      stroke(cFill);
      fill(cFill);
      ellipse(pos.x, pos.y, s, s);
   }
}

Edited version.

I really apreciate last answers, but they are not what I’m looking for.

I need to repeat indefinitely the second circle of my code, the one that is moving, once every second. Thank you so much.

float x=0;
float y=255;


void setup(){
  
  size(270,540);
  background(0,0,0);
  noStroke();
} 


void draw (){
  background(0,0,0);
  strokeWeight(3);
  stroke(255,255,255);
  noFill();
  circle(width/2, height/2, height/10);
  
  stroke(255,255,255,y);
  circle(width/2, height/2, height/10+x);
  x=x+1; 
  y=y-1;

}

double post!

1 Like

sorry kll, Im a little bit desperate :sweat_smile: