Advertisement
xeromino

shave

Mar 12th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. float radius, noiseVal, vari, theta, lx, ly, sz = 5;
  2. int num = 100, fc;
  3. float[] scal = new float[num];
  4. PVector[] dots = new PVector[num];
  5. boolean save = false;
  6. float[] noiseVals = new float[num];
  7.  
  8. void setup() {
  9.   size(500, 500);
  10.   background(20);
  11.   fill(#FFA41A);
  12.   noFill();
  13.   stroke(#FFA41A);
  14.   strokeWeight(1);
  15.   strokeJoin(ROUND);
  16.   radius = width*.3;
  17.  
  18.   for (int i=0; i<num; i++) {
  19.     noiseVals[i] = 1+ noise(noiseVal)*.3;
  20.     noiseVal += .5;
  21.   }
  22.   createSpikeyThing();
  23. }
  24.  
  25. void draw() {
  26.   background(20);
  27.   vari = map(sin(theta), -1, 1, 0, 1);
  28.   createSpikeyThing();
  29.   drawSpikeyThing();
  30.   theta += 0.0523;
  31.  
  32.   if (save) {
  33.     if (frameCount%4==0 && frameCount<fc+121) saveFrame("image-###.gif");
  34.   }
  35. }
  36.  
  37. void createSpikeyThing() {
  38.  
  39.   float angle = -PI;
  40.  
  41.   for (int i=0; i<num; i++) {
  42.     if (i<num*vari && i%4==0) {
  43.       scal[i] = noiseVals[i];
  44.     }
  45.     else {
  46.       scal[i] = 1;
  47.     }
  48.     float px = width/2 + sin(angle)*radius*scal[i];
  49.     float py = height/2 + cos(angle)*radius*scal[i];
  50.     dots[i]= new PVector(px, py);
  51.     angle-=TWO_PI/num;
  52.   }
  53. }
  54.  
  55. void drawSpikeyThing() {
  56.  
  57.   beginShape();
  58.   for (int i=0; i<num; i++) {
  59.     //if (i==0) curveVertex(dots[i].x, dots[i].y);
  60.     curveVertex(dots[i].x, dots[i].y);
  61.     if (i==num-1) curveVertex(dots[i].x, dots[i].y);
  62.   }
  63.   endShape(CLOSE);
  64. }
  65.  
  66. void mouseReleased() {
  67.   noiseVal = random(100);
  68.   for (int i=0; i<num; i++) {
  69.     noiseVals[i] = 1+ noise(noiseVal)*.3;
  70.     noiseVal += .5;
  71.   }
  72. }
  73.  
  74. void keyPressed() {
  75.   fc = frameCount;
  76.   save = true;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement