Canvas quadraticCurveTo() method
Definition and usage
quadraticCurveTo()
method to add a point to the current path by using the specified control point that represents the quadratic Bezier curve.
Tip:A quadratic Bezier curve requires two points. The first point is the control point used in the quadratic Bezier calculation, and the second point is the endpoint of the curve. The starting point of the curve is the last point in the current path. If there is no path, please use beginPath() and moveTo() method to define the starting point.

- Starting point: moveTo(
20
,20
) - Control point: quadraticCurveTo(
20
,100
,200,20) - Endpoint: quadraticCurveTo(20,100,
200
,20
)
Tip:See also bezierCurveTo() method. It has two control points instead of one.
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();
Syntax
context.quadraticCurveTo(cpx,cpy,x,y);
Parameter value
Parameter | 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 endpoint. |
y | The y-coordinate of the endpoint. |
Browser support
The numbers in the table indicate the browser version that first fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.