Advertisement
xeromino

tv

Jul 3rd, 2014
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.28 KB | None | 0 0
  1. //based on code found here: http://www.generative-gestaltung.de/P_2_1_1_04
  2.  
  3. int tileCount;
  4. float tileWidth, tileHeight, shapeSize;
  5. float newShapeSize = shapeSize;
  6. float shapeAngle = 0;
  7. float maxDist, angle, x, y, radius, theta;
  8.  
  9. color shapeColor = color(0, 130, 164);
  10. int fillMode = 0;
  11. int sizeMode = 0;
  12.  
  13. void setup() {
  14.   size(500, 500);
  15.   background(255);
  16.   smooth();
  17.  
  18.   tileCount = 250;
  19.   shapeSize = width/tileCount;
  20.  
  21.   tileWidth = width/float(tileCount);
  22.   tileHeight = height/float(tileCount);
  23.   maxDist = sqrt(sq(width)+sq(height));
  24.   radius = width/3;
  25. }
  26.  
  27.  
  28. void draw() {
  29.  
  30.   background(255);
  31.  
  32.   for (int gridY=0; gridY<tileCount; gridY++) {
  33.     for (int gridX=0; gridX<tileCount; gridX++) {
  34.  
  35.       float posX = tileWidth*gridX + tileWidth/2;
  36.       float posY = tileHeight*gridY + tileWidth/2;
  37.  
  38.       newShapeSize = shapeSize;
  39.  
  40.       x = width/2 + sin(theta+TWO_PI/tileCount*gridX*gridY)*radius;
  41.       y = height/2 + cos(theta+TWO_PI/tileCount*gridX*gridY)*radius;
  42.  
  43.       angle = atan2(y-posY, x-posX) + radians(shapeAngle);
  44.       float a = map(dist(x, y, posX, posY), 0, maxDist, 0, 255);
  45.       fill(shapeColor, a);  
  46.  
  47.       noStroke();
  48.       rect(posX, posY, newShapeSize, newShapeSize);
  49.       //popMatrix();
  50.     }
  51.   }
  52.   theta += 0.0523;
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement