xxxxxxxxxx
56
function setup() {
createCanvas(510, 510);
frameRate(3);
}
function draw() {
let rColor = 255;
let gColor = 255;
let bColor = 255;
background((random(mouseX, rColor), random(mouseY, gColor), random((mouseX+mouseY)/2, bColor)));
let unitWidth = 20+mouseY/20;
let unitHeight = 20+mouseY/20;
let strokeWidth = 0.3+(mouseX/120);
stroke(0, 0, 0);
if (mouseIsPressed) {
background(0);
fill(255);
let strokeWidth = 0
stroke(0);
}
for (i=0; i<width; i=i+unitWidth) {
for (k=0; k<height; k=k+unitHeight) {
let x = round(random(3))
fill(random(mouseX, rColor), random(mouseY, gColor), random((mouseX+mouseY)/2, bColor));
if (mouseIsPressed) {
//background(255);
fill(0);
let strokeWidth = 0
stroke(255);
}
strokeWeight(strokeWidth);
if (x==0){
rect(i, k+unitHeight/2, i+unitWidth, k+unitHeight/2);
} else if (x==1) {
rect(i+unitWidth/2, k, i+unitWidth/2, k+unitHeight);
} else if (x==2) {
rect(i, k, i+unitWidth, k+unitHeight);
} else if (x==3) {
rect(i+unitWidth, k, i, k+unitHeight);
}
}
}
}