Advertisement
xeromino

blackholesun

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