Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int amount = 40;
- color s = #202020;
- color f = #ffffff;
- Thing[] things = new Thing[amount];
- void setup() {
- size(500, 500);
- background(255);
- stroke(0);
- //f = s;
- float theta=0;
- for (int i=0; i<amount; i++) {
- float x = sin(theta);
- float y = cos(theta);
- PVector vOrg = new PVector(x, y);
- vOrg.normalize();
- int cat = amount%2;
- println(cat);
- things[i]= new Thing(vOrg, theta, cat);
- theta += TAU/amount;
- }
- }
- void draw() {
- background(255);
- for (int i=0; i<things.length; i++) {
- things[i].run(200);
- }
- fill(255);
- noStroke();
- ellipse(width/2, height/2, 20, 20);
- if (frameCount % 2 == 0 && frameCount < 241) saveFrame("image-####.gif");
- }
- class Thing {
- PVector vOrg, vDepl;
- int cat;
- float sz, x, y, theta, mg, mag;
- Thing(PVector _vOrg, float _theta, int _cat) {
- vOrg = _vOrg;
- vDepl = vOrg.get();
- cat = _cat;
- theta = _theta;
- }
- void run(int _mag) {
- mag = _mag;
- move();
- display(mag);
- }
- void move() {
- mg = map(sin(theta*5), -1, 1, mag-80, mag);
- sz = map(sin(theta*5), -1, 1, 10, 20);
- vOrg.setMag(mg);
- x = width/2 + vOrg.x;
- y = height/2 + vOrg.y;
- theta += 0.0523/2;
- }
- void display(float mag) {
- stroke(s);
- line(width/2, height/2, x, y);
- fill(f);
- ellipse(x, y, sz, sz);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement