Advertisement
xeromino

catch

Feb 4th, 2014
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. int tileCount;
  2. float tileWidth, tileHeight, shapeSize;
  3. float newShapeSize = shapeSize;
  4. float shapeAngle = 0;
  5. float maxDist, angle, x, y, radius, theta;
  6.  
  7. color shapeColor = color(0, 130, 164);
  8. int fillMode = 0;
  9. int sizeMode = 0;
  10.  
  11.  
  12. void setup() {
  13.   size(500, 500);
  14.   background(#202020);
  15.   smooth();
  16.  
  17.   tileCount = 15;
  18.   shapeSize = width/tileCount;
  19.  
  20.   tileWidth = width/float(tileCount);
  21.   tileHeight = height/float(tileCount);
  22.   maxDist = sqrt(sq(width)+sq(height));
  23.   radius = width/3;
  24. }
  25.  
  26.  
  27. void draw() {
  28.  
  29.   background(#202020);
  30.  
  31.   for (int gridY=0; gridY<tileCount; gridY++) {
  32.     for (int gridX=0; gridX<tileCount; gridX++) {
  33.  
  34.       float posX = tileWidth*gridX + tileWidth/2;
  35.       float posY = tileHeight*gridY + tileWidth/2;
  36.  
  37.       newShapeSize = shapeSize*.8;
  38.  
  39.       x = width/2 + sin(theta)*radius;
  40.       y = height/2 + cos(theta)*radius;
  41.  
  42.       angle = atan2(y-posY, x-posX) + radians(shapeAngle);
  43.       float a = map(dist(x, y, posX, posY), 0, maxDist, 0, 1);
  44.       //fill(shapeColor, a);  
  45.       noFill();
  46.       if (a>.4 || a<.1) {
  47.         fill(#F5D014);
  48.         strokeWeight(2);
  49.         stroke(255);
  50.       }
  51.       else
  52.       {
  53.         //fill(0);
  54.         noStroke();
  55.       }
  56.  
  57.  
  58.       pushMatrix();
  59.       translate(posX, posY);
  60.       //rotate (angle);
  61.       rectMode(CENTER);
  62.  
  63.       //noStroke();
  64.      
  65.       rect(0, 0, newShapeSize, newShapeSize);
  66.       popMatrix();
  67.     }
  68.   }
  69.   theta += 0.0523/2;
  70.   //angle += 0.01;
  71.  
  72.   if (frameCount % 4 == 0 && frameCount < 241) saveFrame("image-###.gif");
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement