xxxxxxxxxx
77
let n = 60;
let widthMult = 3;
let heightMult = 6;
let startR, startG, startB;
let rotationX = 0;
let rotationY = 0;
let easycam;
function setup() {
createCanvas(800, 800, WEBGL);
frameRate(2);
setAttributes('antialias', true);
cam = createEasyCam({ distance: 800 });
document.oncontextmenu = function() { return false; }
document.onmousedown = function() { return false; }
angleMode(DEGREES);
strokeWeight(0.75);
//noLoop(0);
loop(2);
startR = random(160);
startG = random(160);
startB = random(160);
}
function draw() {
background(startR + 45, startG + 45, startB + 45, 150);
//perspective(20 * PI/400, width/height, 1, 400);
for (let x = width; x > -n * widthMult; x -= n) {
for (let y = height; y > -n * heightMult; y -= n) {
let shape = random(1);
let fillR = random(250);
let fillG = random(250);
let fillB = random(250);
push();
translate(x + n / 2, y + n / 2);
let dx = mouseX - width / 2;
let dy = mouseY - height / 2;
rotationY = map(dx, -width / 2, width / 2, -30, 30);
rotationX = map(dy, -height / 2, height / 2, -30, 30);
rotateX(rotationX);
rotateY(rotationY);
if (shape < 0.9) {
let rectWidth = n * floor(random(-1, widthMult));
let rectHeight = n * floor(random(-1, heightMult));
stroke(250, 250, 250);
fill(fillR, fillG, fillB, 200);
box(rectWidth, rectHeight, n);
}
pop();
}
}
}
function mouseClicked() {
if ((mouseX > 0) & (mouseX < width) & (mouseY > 0) & (mouseY < height)) {
startR = random(150);
startG = random(150);
startB = random(150);
redraw();
}
}