HTML | canvas arc() Method
The arc() method is used to create an arc/curve i.e. circles, or parts of circles.
Syntax:
context.arc(x, y, r, sAngle, eAngle, counterclockwise);
Parameters:
- x: This parameter specifies the x-coordinate of the center of the circle.
- y: This parameter specifies the y-coordinate of the center of the circle.
- r: This parameter specifies the radius of the circle.
- sAngle: This parameter specifies the starting angle, in radians( 3 o’clock position of the arc’s circle denotes 0).
- eAngle: This parameter specifies the ending angle in radians.
- counterclockwise: This parameter specifies the drawing should be clockwise or anticlockwise. It is false by default which denotes clockwise.
Example 1:
<!DOCTYPE html> <html> <head> <title> HTML canvas arc() Method </title> </head> <body style="text-align:left;"> <h1>GeeksforGeeks</h1> <h2>HTML canvas arc() Method</h2> <canvas id="GFG" width="500" height="200"> </canvas> <script> var doc_id = document.getElementById("GFG"); var context = doc_id.getContext("2d"); context.beginPath(); context.strokeStyle = 'green'; context.arc(100, 50, 40, 0, 2 * Math.PI); context.stroke(); </script> </body> </html> |
chevron_right
filter_none
Output:

Example 2:
<!DOCTYPE html> <html> <head> <title> HTML canvas arc() Method </title> </head> <body style="text-align:left;"> <h1>GeeksforGeeks</h1> <h2>HTML canvas arc() Method</h2> <canvas id="GFG" width="500" height="200"> </canvas> <script> var doc_id = document.getElementById("GFG"); var context = doc_id.getContext("2d"); context.beginPath(); context.fillStyle = 'green'; context.arc(100, 50, 40, 0, 2 * Math.PI); context.fill(); </script> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by HTML canvas arc() Method are listed below:
- Google Chrome
- Internet Explorer 9.0
- Firefox
- Safari
- Opera
Recommended Posts:
- HTML | canvas translate() Method
- HTML | canvas arcTo() Method
- HTML | canvas clearRect() Method
- HTML canvas rotate() Method
- HTML | canvas isPointInPath() Method
- HTML | canvas fillRect() Method
- HTML | canvas fill() Method
- HTML | canvas stroke() Method
- HTML | canvas scale() Method
- HTML | canvas closePath() Method
- HTML | canvas moveTo() Method
- HTML | canvas quadraticCurveTo() Method
- HTML | canvas beginPath() Method
- HTML | canvas strokeText() Method
- HTML | canvas createLinearGradient() Method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



