Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //based on code found here: http://www.generative-gestaltung.de/P_2_1_1_04
- int tileCount;
- float tileWidth, tileHeight, shapeSize;
- float newShapeSize = shapeSize;
- float shapeAngle = 0;
- float maxDist, angle, x, y, radius, theta;
- color shapeColor = color(0, 130, 164);
- int fillMode = 0;
- int sizeMode = 0;
- void setup() {
- size(500, 500);
- background(255);
- smooth();
- tileCount = 250;
- shapeSize = width/tileCount;
- tileWidth = width/float(tileCount);
- tileHeight = height/float(tileCount);
- maxDist = sqrt(sq(width)+sq(height));
- radius = width/3;
- }
- void draw() {
- background(255);
- for (int gridY=0; gridY<tileCount; gridY++) {
- for (int gridX=0; gridX<tileCount; gridX++) {
- float posX = tileWidth*gridX + tileWidth/2;
- float posY = tileHeight*gridY + tileWidth/2;
- newShapeSize = shapeSize;
- x = width/2 + sin(theta+TWO_PI/tileCount*gridX*gridY)*radius;
- y = height/2 + cos(theta+TWO_PI/tileCount*gridX*gridY)*radius;
- angle = atan2(y-posY, x-posX) + radians(shapeAngle);
- float a = map(dist(x, y, posX, posY), 0, maxDist, 0, 255);
- fill(shapeColor, a);
- noStroke();
- rect(posX, posY, newShapeSize, newShapeSize);
- //popMatrix();
- }
- }
- theta += 0.0523;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement