xxxxxxxxxx
28
let tileCount = 10;
function setup() {
createCanvas(400, 400);
drawSlashes();
}
function drawSlashes() {
for (let gridX = 0; gridX < tileCount; gridX+=1) {
for (let gridY = 0; gridY < tileCount; gridY+= 1) {
let tileWidth = width/tileCount;
let tileHeight = height/tileCount;
let posX = gridX * (width/tileCount);
let posY = gridY * (height/tileCount);
let direction = int(random(2));
if (direction === 0) {
line(posX, posY + tileHeight, posX + tileWidth, posY);
} else if (direction === 1) {
line(posX, posY, posX + tileWidth, posY + tileHeight);
}
}
}
}
function mousePressed() {
background(255);
drawSlashes();
}