Advertisement
xeromino

p211_3

Feb 2nd, 2014
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 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 = 10;
  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)*radius;
  41.       y = height/2 + cos(theta)*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.       pushMatrix();
  48.       translate(posX, posY);
  49.       //rotate (angle);
  50.       rectMode(CENTER);
  51.  
  52.       noStroke();
  53.       rect(0, 0, newShapeSize, newShapeSize);
  54.       popMatrix();
  55.     }
  56.   }
  57.   theta += 0.0523;
  58.  
  59.   if (frameCount % 2 == 0 && frameCount < 121) saveFrame("image-###.gif");
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement