Advertisement
xeromino

p112

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