html, body {
background: #000;
}
canvas {
margin-left: calc(50% - 300px);
margin-top: 100px;
}
let x = 0;
let y = 0;
let spacing = 10;
//Set up basic canvas
function setup() {
createCanvas(600, 400);
background(0);
}
function draw() {
//If y is within the height of the canvas
if(y < height) {
//Pirck a random gray color
stroke(random(100, 255));
//Generate a random number upto 1. If it's less than .5
if(random(1) < .5) {
//backslash line \
line(x, y, x + spacing, y + spacing);
} else { //More than .5
//forwardslash line /
line(x, y + spacing, x + spacing, y);
}
// Move along one space
x = x + spacing;
//If we're at the end of the canvas, go down one line
if(x > width) {
x = 0;
y = y + spacing;
}
}
}
This Pen doesn't use any external CSS resources.