19/02/2020
[Tutorial]
import processing.pdf.*;
void setup() {
size(300, 300), PDF, "cubic_disarray.pdf");
}
void drawRect(float x, float y, int squareSize) {
pushMatrix();
translate(x, y);
float rand = random(90);
float randAngle = rand*random(-1,1)*(y-2*squareSize)/height;
rotate(radians(randAngle));
translate(-x, -y);
float randShift = random(-1,1)*(y-2*squareSize)/width*random(20);
print(randAngle);
print(' ');
fill(123, 123, 0, 255/90*randAngle);
rect(x - squareSize*0.5 + randShift,
y - squareSize*0.5,
squareSize, squareSize);
popMatrix();
}
void draw() {
int squareSize = 30;
background(255);
noFill();
for (float i = 2*squareSize; i <= width - squareSize*2; i += squareSize){
for (float j = 2*squareSize; j <= height - squareSize*2; j += squareSize){
strokeWeight(j/squareSize);
drawRect(i, j, squareSize);
}
}
}