Advertisement
xeromino

crazyMAth

Mar 21st, 2017
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. int num = 5000, frms = 180, slices = 100;
  2. float theta;
  3. PGraphics pg;
  4.  
  5. void setup() {
  6.   size(540, 540);
  7.   gradient();
  8. }
  9.  
  10. void draw() {
  11.   background(34);//
  12.   image(pg, 0, 0);
  13.   fill(255);
  14.   noStroke();
  15.   translate(width/2, height/2);
  16.   float d = 150;
  17.   float s = map(sin(theta), -1, 1, -0.5, 1);
  18.   float n =  9.15;
  19.   float sz = 25;
  20.   for (int i=0; i<num; i++) {
  21.     float x = cos((TWO_PI*n*i)/num)*(.5-s*sq(cos((TWO_PI*18*i)/num)))*d;
  22.     float y = sin((TWO_PI*n*i)/num)*(.5-s*sq(cos((TWO_PI*18*i)/num)))*d;
  23.     float r = (1.0/200 + .1*pow(sin((32*TWO_PI*i)/num), 6))*sz;
  24.     ellipse(x, y, r, r);
  25.   }
  26.   theta += TWO_PI/frms;
  27.   if (frameCount<=frms) saveFrame("image-###.gif");
  28. }
  29.  
  30. void gradient() {
  31.   pg = createGraphics(width, height);
  32.   pg.beginDraw();
  33.   for (int i=0; i<slices; i++) {
  34.     pg.noStroke();
  35.     pg.fill(map(i, 0, slices, 0, 75));
  36.     float sz = map(i, 0, slices, width*1.5, 5);
  37.     pg.ellipse(width/2, height/2, sz, sz);
  38.   }
  39.   pg.endDraw();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement