Advertisement
xeromino

pulse

Jan 15th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. float theta, lx, ly, sz;
  2. int frames=60, rows, cols, edge=0;
  3.  
  4. void setup() {
  5.   size(500, 500);
  6.   rows=height/5;
  7.   cols=width/5;
  8.   lx = width/cols;
  9.   ly = height/rows;
  10.   noStroke();
  11. }
  12.  
  13. void draw() {
  14.   background(#202020);
  15.   drawStuff(width*.5, height*.33, #ffffff,1,2);
  16.   drawStuff(width*.5, height*.5, #ffffff,1,3);
  17.   drawStuff(width*.5, height*.66, #ffffff,1,4);
  18.   theta -=TWO_PI/frames;
  19.   if (frameCount<=frames) saveFrame("image-###.gif");
  20. }
  21.  
  22. void drawStuff(float ox, float oy, color col, int r, int o) {
  23.   for (int i=edge; i<cols-edge; i++) {
  24.     for (int j=edge; j<rows-edge; j++) {
  25.       fill(col,20);
  26.       float x = (i+.5)*lx;
  27.       float y = (j+.5)*ly;
  28.       float distance = dist(x, y, ox, oy);
  29.       //float distance = dist(x,y,width/2,height/2);
  30.       float offSet = map(distance, 0, sqrt(sq(width/2)+sq(height/2)), 0, TWO_PI);
  31.       float sz = map(sin(theta*r+offSet*o), -1, 1, 0, 35);
  32.       ellipse(x, y, sz, sz);
  33.     }
  34.   }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement