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 the start 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
Try it »
Browser support





Internet Explorer 9, Firefox, Chrome, and Safari support the arcTo() method.
**Note:** Opera does not support the arcTo() method.
**Note:** Internet Explorer 8 and earlier versions do not support
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 first control point. |
| y1 | The y-coordinate of the first control point. |
| x2 | The x-coordinate of the second control point. |
| y2 | The y-coordinate of the second control point. |
| r | The radius of the arc. |
Canvas object