Advertisement
xeromino

crescent

Jun 8th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. float x, y, t, theta;
  2. int points = 50, num = 56, num2= 28, frms = 10;
  3.  
  4. void setup() {
  5.   size(900, 900, P2D);
  6.   smooth(8);
  7.   //colorMode(HSB,360,100,100);
  8.   noStroke();
  9.   //noFill();
  10. }
  11.  
  12. void draw() {
  13.   background(0);
  14.  
  15.   for (int j = 0; j< num; j++) {
  16.     float offSet = TWO_PI/num*j;
  17.     pushMatrix();
  18.     translate(width/2, height/2);
  19.     scale(map(cos(theta), -1, 1, .5, 4));
  20.     rotate(PI+offSet+theta);
  21.     pushMatrix();
  22.     translate(0, -180);
  23.     //rotate(theta*5);
  24.     //rotate(offSet*3+theta*5);
  25.     fill(255);
  26.     float sz = map(sin(theta+offSet*3), -1, 1, 30, 60);
  27.     beginShape();
  28.     for (int i=0; i<points; i++) {
  29.       t = TWO_PI/points*i;
  30.       x = (sin(t) < 0) ? sin(t) * sz : -sin(t) * sz*.8;
  31.       y = cos(t) * sz;
  32.       vertex(x, y);
  33.     }
  34.     endShape(CLOSE);
  35.     popMatrix();
  36.     popMatrix();
  37.   }
  38.  
  39.   for (int j = 0; j< num2; j++) {
  40.     float offSet = TWO_PI/num2*j;
  41.     pushMatrix();
  42.     translate(width/2, height/2);
  43.     scale(map(sin(theta*2), -1, 1, .25, 2.5));
  44.     rotate(PI+offSet-theta);
  45.     pushMatrix();
  46.     translate(0, -70);
  47.     //rotate(theta*5);
  48.     //rotate(offSet*3+theta*5);
  49.     fill(255);
  50.     beginShape();
  51.     for (int i=0; i<points; i++) {
  52.       t = TWO_PI/points*i;
  53.       x = (sin(t) < 0) ? sin(t) * 30 : -sin(t) * 25;
  54.       y = cos(t) * 30;
  55.       vertex(x, y);
  56.     }
  57.     endShape(CLOSE);
  58.     popMatrix();
  59.     popMatrix();
  60.   }
  61.  
  62.   theta += TWO_PI/num2/frms;
  63.   if (theta<TWO_PI) saveFrame("image-###.tga");
  64.   //if (frameCount<=frms*5) saveFrame("image-###.tga");
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement