Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final int SIZE = 120;
- float angle = 0;
- float maxAngle = 0.2;
- float dAngle = 0.001;
- void setup() {
- size(600, 600);
- rectMode(CENTER);
- stroke(0);
- strokeWeight(2);
- noFill();
- }
- void draw() {
- background(255);
- int dir = 1;
- for (int y = SIZE / 2; y < height; y += SIZE) {
- for (float x = SIZE / 2; x < width; x += SIZE) {
- drawSquare(x, y, SIZE, angle, dir);
- dir = -dir;
- }
- }
- angle += dAngle;
- if (angle > maxAngle || angle < 0) {
- dAngle = -dAngle;
- }
- }
- void drawSquare(float xc, float yc, float size, float angle, int dir) {
- pushMatrix();
- translate(xc, yc);
- float coef = 1 / (sin(angle) + cos(angle));
- for (int i = 0; i < 20; i++) {
- rect(0, 0, size, size);
- size *= coef;
- rotate(dir * angle);
- }
- popMatrix();
- }
Add Comment
Please, Sign In to add comment