Advertisement
xeromino

sincos

Nov 1st, 2016
386
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int num = 200, frms=180;
  2. float angle, theta;
  3. float d = 150;
  4.  
  5. void setup() {
  6.   size(540, 540);
  7.   noStroke();
  8. }
  9.  
  10. void draw() {
  11.   background(238);
  12.   fill(34);
  13.   translate(width/2, height/2);
  14.   beginShape();
  15.   for (int i=0; i<num; i++) {
  16.     angle = TWO_PI/num*i;
  17.     float offSet = PI/num*i;
  18.     float sc = map(sin(theta+offSet*2), -1, 1, 0.5, 1);
  19.     float x = sin(angle+offSet*3*sc)*d*sc;
  20.     float y = cos(angle+offSet*sc)*d*sc;
  21.     vertex(x, y);
  22.   }
  23.   endShape(CLOSE);
  24.  
  25.   theta += TWO_PI/frms;
  26.   if (frameCount<frms) saveFrame("image-###.gif");
  27. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement