Advertisement
xeromino

spinner

Jan 27th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float segmentCount, angleStep, radius, theta;
  2.  
  3. void setup() {
  4.   size(500, 500);
  5.   colorMode(HSB, 360, 100, 100);
  6.   stroke(350);
  7.   strokeWeight(8);
  8. }
  9.  
  10. void draw() {
  11.   background(350);
  12.   segmentCount = map(sin(theta), -1, 1, 6, 12);
  13.   angleStep=360/segmentCount;
  14.  
  15.   float div = map(sin(theta), -1, 1, 6, 5);
  16.   radius = width/div;
  17.  
  18.   beginShape(TRIANGLE_FAN);
  19.   vertex(width/2, height/2);
  20.   for (float angle=0;angle <=360*4; angle+=angleStep) {
  21.     float vx = width/2 + cos(radians(angle))*radius;
  22.     float vy = height/2 + sin(radians(angle))*radius;
  23.     vertex(vx, vy);
  24.     fill(angle%360, 100, 90, 80);
  25.     radius *=1.02;
  26.   }
  27.   endShape();
  28.  
  29.   theta += 0.0523;
  30.  
  31.   //if (frameCount % 2 == 0 && frameCount < 121) saveFrame("image-###.gif");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement