rotating more than one offset circle

i think my question is about offset shapes and rotation

very new to this

right now i have one roatating circle followed by a trail of other circles.. i want to create multiples of this same effect on the screen but cant figure it out? i have tried copying that part of the code with other coordinates where" x" and "y" are but that circle fails to move.

here's what I have :

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

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

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

}

and i just want to add more of the same thing

gah so simple i bet i just can't figure it out

Answers

  • edited September 2014

    You can either turn every ellipse()'s property into arrays or define a class to hold those properties.

  • edited September 2014

    Here is an example using a loop:

    int numCircles = 12;
    
    float angle = 0.0;
    float scalar = 30.0;
    float speed = 0.05;
    
    void setup() {
      size(780, 120);
      smooth();
    }
    
    void draw() {
      for (int i = 0; i < numCircles; i++) {
        float x = scalar*2 + i*scalar*2.0 + cos(angle)*scalar;
        float y = scalar*2 + sin(angle)*scalar;
        ellipse(x, y, 40, 40);
      }
      angle += speed;
    }
    
Sign In or Register to comment.