Advertisement
xeromino

vertex

Aug 25th, 2015
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. int num = 6, frames = 150;
  2. float angle, theta, d, d2;
  3.  
  4. void setup() {
  5.   size(540, 540,P2D);
  6.   colorMode(HSB,360,100,100);
  7.   noStroke();
  8. }
  9.  
  10. void draw() {
  11.   background(#000000);
  12.   beginShape();
  13.   for (int i=0; i<num; i++) {
  14.     float offSet=TWO_PI/num*i;
  15.     d = 150;
  16.     d2 = 50;
  17.     float x = width/2 + sin(angle)*d;
  18.     float y = height/2 + cos(angle)*d;
  19.     float x2 = x + sin(theta+offSet)*d2;
  20.     float y2 = y + cos(theta+offSet*2)*d2;
  21.     if (i%3==0) fill(360.0/num*i,90,90);
  22.     vertex(x2, y2);
  23.     angle = offSet;
  24.   }
  25.   endShape(CLOSE);
  26.   theta += TWO_PI/frames;
  27.   if (frameCount>10 && frameCount<=(frames+10)) saveFrame("image-###.gif");
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement