I am using the same color for both lines and circles on canvas, however, it is giving me a weird effect. I would like it to not show the line in the circle.
Why is it that adding an alpha value would make such a difference?
Here is my code:
function draw() {
let color = "rgba(192,192,192,0.5)";
//draw circle
for (let i = 0; i < circleArray.length; i++) {
let circle = circleArray[i]
context.beginPath();
context.arc(circle.x, circle.y, circle.radius, 0, Math.PI * 2);
context.fillStyle = color;
context.fill();
};
//draw line
context.beginPath();
for (let i = 0; i < circleArray.length; i++) {
let circleI = circleArray[i];
context.moveTo(circleI.x, circleI.y);
for (let j = 0; j < circleArray.length; j++) {
let circleII = circleArray[j];
if (distance(circleI, circleII) < 350) {
context.lineTo(circleII.x, circleII.y);
}
}
}
context.lineWidth = 2;
context.strokeStyle = color;
context.stroke();
}
Expected. This is what I wanted, but this is with opacity of 1. I would like it to have opacity of 0.5.