English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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.
Draw a quadratic bezier curve:
<!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 ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 9Firefox, Opera, Chrome, and Safari support quadraticCurveTo() Method.
Note:Internet Explorer 8 Previous versions do not support the <canvas> element.
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.
Tip:See bezierCurveTo() Method. It has two control points instead of one.
JavaScript Syntax: | context.quadraticCurveTo(cpx,cpy,x,y); |
---|
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. |