Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int num = 20;
- color bg = #ffffff;
- color s = #000000;
- Circle circles[] = new Circle[num];
- void setup() {
- size(500, 500);
- background(bg);
- stroke(s,150);
- fill(s,50);
- float maxw = 0;
- float theta = 0;
- for (int i=0; i<num; i++) {
- maxw += 20;
- circles[i] = new Circle(maxw, theta);
- theta += TAU/num;
- }
- }
- void draw() {
- background(bg);
- for (int i=0; i<circles.length; i++) {
- circles[i].run();
- }
- //if (frameCount % 4 == 0 && frameCount < 121) saveFrame("image-####.gif");
- }
- class Circle {
- float w, maxw, h, theta, str;
- Circle(float _maxw, float _theta) {
- maxw = _maxw;
- theta = _theta;
- }
- void run() {
- move();
- display();
- }
- void move() {
- w = map(sin(theta), -1, 1, -maxw, maxw);
- h = map(cos(theta), -1, 1, maxw/3, maxw);
- theta += 0.0523;
- }
- void display() {
- ellipse(width/2, height/2, w, h);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement