HTML canvas quadraticCurveTo() Method

Introduction

Draw a quadratic curve:

View in separate window

<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="300" height="180" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.</canvas>

<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.beginPath();//from  w ww.j a v a  2 s. c  o  m
ctx.moveTo(20, 20);
ctx.quadraticCurveTo(20, 100, 200, 20);
ctx.stroke();
</script>

</body>
</html>

The quadraticCurveTo() method adds a point to the current path by using the control points that represent a quadratic bezier curve.

A quadratic bezier curve requires two points.

context.quadraticCurveTo(cpx, cpy, x, y);

Parameter Values

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 ending point
y The y-coordinate of the ending point



PreviousNext

Related