HTML canvas arcTo() Method
Example
Creates an arc between two tangents on the canvas:
JavaScript:
var
c
=
document
.
getElementById
(
"
myCanvas
"
)
;
var
ctx
=
c
.
getContext
(
"
2d
"
)
;
ctx
.
beginPath
(
)
;
ctx
.
moveTo
(
20
,
20
)
;
//
Create a starting point
ctx
.
lineTo
(
100
,
20
)
;
//
Create the horizontal line
ctx
.
arcTo
(
150
,
20
,
150
,
70
,
50
)
;
//
Create the arc
ctx
.
lineTo
(
150
,
120
)
;
//
Create the vertical line
ctx
.
stroke
(
)
;
//
Draw it
Try it »
Browser support
The numbers in the table indicate the first browser version that supports this method.
| Method | |||||
|---|---|---|---|---|---|
| arcTo() | Yes | 9.0 | Yes | Yes | No |
Definition and Usage
The arcTo() method creates an arc/curve between two tangents on the canvas.

**Tip:** Please use stroke() The method draws the exact arc on the canvas.
| JavaScript syntax: | context.arcTo(x1,y1,x2,y2,r); |
|---|
Parameter value
| Parameters | Description |
|---|---|
| x1 | The x-coordinate of the intersection of the two tangent lines. |
| y1 | The y-coordinate of the intersection of the two tangent lines. |
| x2 | The x-coordinate of a point on the second tangent line. |
| y2 | The y-coordinate of a point on the second tangent line. |
| r | The radius of the arc. |
The x and y coordinates of any point on the first line are the position of the previous point, in this example 100,20. The three points (x1,y1), (x2,y2), and (100,20) determine the positions of the two lines, and then the radius determines the position of the arc.
HTML canvas Reference Manual