English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML tag大全

HTML canvas quadraticCurveTo() method

quadraticCurveTo() is a Canvas 2D API adds a method for quadratic bezier curve paths. It requires2Points. The first point is the control point, the second point is the endpoint. The starting point is the latest point on the current path; you can change it by using the moveTo() method before creating the quadratic bezier curve.

HTML canvas Reference Manual

Online Example

Draw a quadratic bezier curve:

Your browser does not support HTML5 canvas tag.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8>
<title>Using HTML canvas bezierCurveTo() method-Basic Tutorial(oldtoolbag.com)</<title>
</<head>
<body>
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3>
Your browser does not support HTML5 canvas tag.
</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(20,20);
ctx.quadraticCurveTo(20,100,200,20);
ctx.stroke();
</script> 
</body>
</html>
Test to see ‹/›

Browser compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 9Firefox, Opera, Chrome, and Safari support quadraticCurveTo() Method.

Note:Internet Explorer 8 Previous versions do not support the <canvas> element.

Definition and Usage

quadraticCurveTo() method to add a point to the current path by using the specified control points that represent the quadratic Bezier curve.

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, 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 bezierCurveTo() Method. It has two control points instead of one.


JavaScript Syntax:context.quadraticCurveTo(cpx,cpy,x,y);

Parameter Value

ParameterDescription
cpxThe x-coordinate of the Bezier control point.
cpyThe y-coordinate of the Bezier control point.
xThe x-coordinate of the endpoint.
yThe y-coordinate of the endpoint.
HTML canvas Reference Manual