Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML canvas quadraticCurveTo() method

HTML canvas quadraticCurveTo() method

HTML canvas Reference HTML canvas Reference Manual

Example

Draw a quadratic Bezier curve:

YourbrowserdoesnotsupporttheHTML5canvastag.

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 Firefox Opera Google Chrome Safari

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 points:

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.

HTML canvas Reference HTML canvas Reference Manual