p5(sketch => {
let LL, NL, x, y, dh
let w = width/2
let h=width/2
sketch.setup = function() {
sketch.createCanvas(w, h);
LL = h * 0.02
NL = h / LL
sketch.noLoop()
};
sketch.draw = function() {
doLines()
}
function LLine() {
sketch.line(0, 0, LL, LL)
}
function RLine() {
sketch.line(0, LL, LL, 0)
}
function doLines(){
sketch.background(0)
sketch.stroke('red')
sketch.strokeWeight(LL*0.1)
sketch.push()
for (let y = 0; y < NL; y++) {
for (let x = 0; x < NL; x++) {
switch ((sketch.floor(sketch.random(0, 2)))) {
case 0:
LLine()
break;
case 1:
RLine()
break;
}
sketch.translate(LL, 0)
}
sketch.pop()
sketch.push()
sketch.translate(0, LL * (y + 1))
}
}
})