xxxxxxxxxx
const randArr = [1,2]
const palette = [
"#fdf1cc",
"#c6d6b8",
"#987f69",
"#e3ad40",
"#fcd036"
]
const gapsize = 20
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
noLoop()
}
function draw() {
drawGrid()
}
function drawGrid() {
for (column = 0; column < height; column+=gapsize) {
stroke(random(palette))
for (row = 0; row < width; row+=gapsize) {
drawLines(row, column)
}
}
function drawLines(row, column) {
const r = random(randArr)
strokeWeight(3)
if (r === 1) {
line(row, column, row + gapsize, column + gapsize)
} else if (r === 2) {
line(row + gapsize, column, row, column + gapsize)
}
}
}
function keyTyped() {
switch (key) {
case " ":
background(0)
redraw()
}
}