HTML canvas quadraticCurveTo() method
Example
Draw a quadratic Bezier curve:
JavaScript:
var
c
=
document
.
getElementById
(
"
myCanvas
"
)
;
var
ctx
=
c
.
getContext
(
"
2d
"
)
;
ctx
.
beginPath
(
)
;
ctx
.
moveTo
(
20
,
20
)
;
ctx
.
quadraticCurveTo
(
20
,
100
,
200
,
20
)
;
ctx
.
stroke
(
)
;
Try it »
Browser support

Internet Explorer 9, Firefox, Opera, Chrome and Safari support the quadraticCurveTo() method.
**Note:** Internet Explorer 8 and earlier versions do not support
Definition and Usage
The quadraticCurveTo() method adds a point to the current path by using the specified control point that represents the quadratic Bezier curve.
A quadratic Bezier curve needs two points. The first point is the control point used in the quadratic Bezier calculation, and the second point is the end point of the curve. The start point of the curve is the last point in the current path. If the path does not exist, please use beginPath() and moveTo() the method to define the start point.
- Start point: moveTo(20,20)
- Control point: quadraticCurveTo(20,100,200,20)
- End point: quadraticCurveTo(20,100,200,20)
**Tip:** See the bezierCurveTo() method. It has two control points instead of one.
| JavaScript syntax: | context.quadraticCurveTo(cpx,cpy,x,y); |
|---|
Parameter value
| Parameters | Description |
|---|---|
| cpx | The x-coordinate of the Bezier control point. |
| cpy | The y-coordinate of the Bezier control point. |
| x | The x-coordinate of the end point. |
| y | The y-coordinate of the end point. |
Canvas object