Ask coding questions

← Back to all posts
circle
THREE1 (0)

Hi How do I repeat circles without these lines


Comments
hotnewtop
Coder100 (18903)

here is the code to close the path which you need to do:

ca.beginPath();
ca.arc(...);
ca.closePath();

like that

Coder100 (18903)

np
mark as correct answer? @THREE1

THREE1 (0)

No, the result did not turn out as I would like
Thank you for helping me

@Coder100

Coder100 (18903)

@THREE1 you implemented my solution wrong, your code has:

ca.beginPath();
ca.closePath();

which does nothing.

THREE1 (0)

What is the correct method for your code

Coder100 (18903)

@THREE1

			var ar = document.getElementById("dor");
			var ca = ar.getContext("2d");

			
			ca.fillStyle = '#00000';
			ca.fillRect(0, 0, 1000, 1000);

			for (i = 0; i <= 10; i++) {
				ca.lineWidth = 3;
				ca.fillStyle = '#ff0000';
				ca.strokeStyle = '#ff0000';

				ca.beginPath();
				ca.arc(Math.random() * 1000, Math.random() * 1000, 10, 0, 2 * Math.PI);
				ca.fill();
				ca.stroke();
			}

try this ^^

THREE1 (0)

@Coder100 What is the correct method for your code

THREE1 (0)

@Coder100 Thank you the lines are gone but how can I space out the circles like this

Coder100 (18903)

use the position to move the circles @THREE1