So I was playing around with lines as you can see in the code below and I want to make the gradient color from black to white in the lines to give effect of depth. But I don’t know how to do it. I try to read the gradient function in the library but I couldn’t understand
function setup() {
createCanvas(600, 300);
}
function draw() {
background(220);
for (let y = 20; y <= height - 20; y += 20) {
for (let x = 20; x <= width - 20; x += 20) {
//draw lines
stroke(50);
line(x, y, mouseX, mouseY);
//draw dot
fill(220);
noStroke();
ellipse(x, y, 5, 5);
}
}
}