Advertisement
xeromino

math

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