quadraticCurveTo() Method - Javascript Canvas Reference

Javascript examples for Canvas Reference:quadraticCurveTo

Description

The quadraticCurveTo() method adds control points that represent a quadratic Bezier curve.

JavaScript syntax

context.quadraticCurveTo(a, b, x, y);

Parameter Values

Parameter Description
a The x-coordinate of the Bezier control point
b The y-coordinate of the Bezier control point
x The x-coordinate of the ending point
y The y-coordinate of the ending point

Example

Draw a quadratic Bezier curve:

JavaScript:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<canvas id="myCanvas" width="300" height="250" 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();/* w  w  w  .j  a v  a 2s  . c om*/
ctx.moveTo(20, 20);
ctx.quadraticCurveTo(24, 100, 200, 20);
ctx.stroke();

</script>

</body>
</html>

Related Tutorials