English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML tag大全

HTML canvas arc() method

arc() is a Canvas 2The arc() method is a Canvas D API method to draw an arc path. The center of the arc path is at (x, y) position, with a radius of r, and starts drawing from startAngle (default is clockwise) and ends at endAngle.

HTML canvas reference manual

Online Example

Draw a circle:

Your browser does not support HTML5 canvas tag.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8>
<title>HTML canvas arc() method usage-Basic Tutorial(oldtoolbag.com)</<title>
</<head>
<body>
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3>
Your browser does not support HTML5 canvas tag.
</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.arc(100,75,50,0,2*Math.PI);
ctx.stroke();
</script> 
</body>
</html>
Test to see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 9and Safari support arc() method.

Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.

Definition and Usage

The arc() method creates an arc./curve (used to create a circle or part of a circle).

Tip:If you create a circle through arc(), please perform the following operations: set the start angle to 0, and set the end angle to2 * Math.PI.

Tip:Please use stroke() orfill() Method to draw an actual arc on the canvas.


Center:
arc(100,75,50,0*Math.PI,1.5*Math.PI)
Start angle:
arc(100,75,50,0,1.5*Math.PI)
End angle:
arc(100,75,50,0*Math.PI,1.5*Math.PI)
JavaScript syntax:context.arc(x,y,r,sAngle,eAngle,counterclockwise);

Parameter value

ParameterDescription
xX coordinate of the center of the circle.
yY coordinate of the center of the circle.
rRadius of the circle.
sAngleStart angle, in radians (the circular three o'clock position is 0 degrees).
eAngleEnd angle, in radians.
counterclockwiseOptional. Specifies whether to draw in a clockwise or counterclockwise direction. False = clockwise, true = counterclockwise.
HTML canvas reference manual