I'm trying to draw an array of circles that are supposed to break an array of lines. Everything looks good if circles are far away from each other, but if the circles overlap - a stroke appears underneath.
Any tips on how to remove this stroke when circles overlap? Here's what I'm talking about:
Here is my code:
let canvas = document.getElementById('myCanvas')
let ctx = canvas.getContext('2d');
document.body.style.backgroundColor = "#121212";
ctx.lineWidth = 1;
ctx.fillStyle = '#121212';
ctx.strokeStyle = '#9f9999';
ctx.lineCap = "round";
let width = canvas.width;
let height = canvas.height;
let lines = new Array(height);
let singleLine = new Array(width);
let step = 30;
for (let y = step; y < height; y += step) {
ctx.beginPath();
for (let x = step; x < width; x += step) {
if (Math.random() < 0.85) {
ctx.lineTo(x, y);
} else {
drawCircle(y, x);
}
}
ctx.stroke();
ctx.fill();
}
function drawCircle(x, y) {
ctx.arc(y, x, 20, Math.PI, 0, false);
}
<canvas id="myCanvas"></canvas>
