Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- color bg = #ffffff;
- color f = #000000;
- color s = f;
- int steps = 40;
- int isteps = steps/2;
- float oRadius, iRadius, org_x, org_y, theta;
- Circle[] outerCircles = new Circle[steps];
- Circle[] innerCircles = new Circle[isteps];
- void setup() {
- size(500, 500);
- background(bg);
- org_x = width/2;
- org_y = height/2;
- theta = 0;
- oRadius = width/3;
- iRadius = width/6;
- for (int i=0; i < steps; i++) {
- int dir = 1;
- outerCircles[i] = new Circle(theta, dir, oRadius);
- theta += TAU/steps;
- }
- for (int i=0; i < isteps; i++) {
- int dir = -1;
- innerCircles[i] = new Circle(theta, dir, iRadius);
- theta += TAU/isteps;
- }
- }
- void draw() {
- background(bg);
- for (int i=0; i<outerCircles.length; i++) {
- outerCircles[i].run();
- }
- for (int i=0; i<innerCircles.length; i++) {
- innerCircles[i].run();
- }
- if (frameCount % 1 == 0 && frameCount < 61) saveFrame("image-####.gif");
- }
- class Circle {
- float x, y, sz, theta, theta2, radius;
- int dir;
- Circle(float _theta, int _dir, float _radius) {
- theta = _theta;
- dir = _dir;
- radius = _radius;
- //sz = 20;
- }
- void run() {
- move();
- display();
- }
- void move() {
- x = org_x + sin(theta)*radius;
- y = org_y + cos(theta)*radius;
- theta += 0.0523/4*dir;
- }
- void display() {
- switch(dir) {
- case 1:
- sz=map(cos(theta), -1, 1, 20, 50);
- stroke(s);
- //noFill();
- fill(f);
- break;
- case -1:
- sz = 45;
- stroke(s);
- //noStroke();
- fill(f);
- break;
- }
- ellipse(x, y, sz, sz);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement