function draw(ctx) {
const width = ctx.canvas.width;
const height = ctx.canvas.height;
ctx.clearRect(0, 0, width, height);
ctx.lineCap = 'square';
ctx.fillStyle = '#f8f8f4';
ctx.fillRect(0, 0, width, height);
for (let x = 0; x < width; x += step) {
for (let y = 0; y < height; y += step) {
ctx.lineWidth = Math.floor(Math.random() * colors.length + 1);
ctx.strokeStyle = colors[ctx.lineWidth - 1];
ctx.beginPath();
if (Math.random() >= 0.5) {
ctx.moveTo(x, y);
ctx.lineTo(x + step, y + step);
} else {
ctx.moveTo(x + step, y);
ctx.lineTo(x, y + step);
}
ctx.stroke();
}
}
}