The canvas arcTo() Method is used to create an arc/curve between two tangents on the canvas.This method defines an arc in the extension of a straight line or another figure. This method is generally used to create rounded corners.
Syntax:
context.arcTo( x1, y1, x2, y2, r );
Parameters:
- x1: This parameter specifies the x-coordinate of the first tangent.
- y1: This parameter specifies the y-coordinate of the first tangent.
- x2: This parameter specifies the x-coordinate of the second tangent.
- y2: This parameter specifies the y-coordinate of the second tangent.
- r: This parameter specifies the radius of the arc.
Example 1:
<!DOCTYPE html> <html> <head> <title> HTML canvas arcTo() Method </title> </head> <body style="text-align:center;"> <h1>GeeksforGeeks</h1> <h2>HTML canvas arcTo() 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.lineWidth = 6; context.moveTo(200, 30); context.arcTo(100, 30, 100, 50, 50); context.stroke(); </script> </body> </html> |
chevron_right
filter_none
Output:

Example 2:
<!DOCTYPE html> <html> <head> <title> HTML canvas arcTo() Method </title> </head> <body style="text-align:center;"> <h1>GeeksforGeeks</h1> <h2>HTML canvas arcTo() 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.lineWidth = 3; context.moveTo(60, 60); context.arcTo(250, 60, 250, 110, 50); context.stroke(); </script> </body> </html> |
chevron_right
filter_none
Output:

Supported Browsers: The browser supported by HTML canvas arcTo() Method are listed below:
- Google Chrome
- Internet Explorer 9.0
- Firefox
- Safari
- Opera
Recommended Posts:
- HTML | canvas rect() Method
- HTML | canvas clearRect() Method
- HTML | canvas strokeRect() Method
- HTML | canvas fillRect() Method
- HTML | canvas fill() Method
- HTML | canvas stroke() Method
- HTML | canvas translate() Method
- HTML canvas rotate() Method
- HTML | canvas scale() Method
- HTML | canvas createLinearGradient() Method
- HTML | canvas beginPath() Method
- HTML | canvas quadraticCurveTo() Method
- HTML | canvas moveTo() Method
- HTML | canvas closePath() Method
- HTML | canvas isPointInPath() Method
- HTML | canvas strokeText() Method
- HTML | canvas arc() Method
- HTML | canvas fillText() Method
- HTML | canvas lineTo() Method
- HTML | canvas measureText() 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.


