Canvas quadraticCurveTo() method
Definition and usage
quadraticCurveTo()
method to add a point to the current path using the specified control points of 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 the path does not exist, then 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
Table numbers indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
注释:Internet Explorer 8 以及更早的版本不支持 <canvas> 元素。