Jump to content

Canvas, drawing of two concentric circles: Abnormal behavior?


nic.sicily
 Share

Recommended Posts

The following simple code draws, in addition to the two circles, also a mysterious horizontal line between the two circles. How can I solve it?

<script>
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.arc (250, 250, 200, 0, 2*Math.PI);
ctx.arc (250, 250, 180, 0, 2*Math.PI);
ctx.stroke();

</script>

circles.png

Link to comment
Share on other sites

Between beginPath and stroke is a single line as if you were holding the pen down on a piece of paper.

You're going to need to put each arc between different beginPath and stroke function calls.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...