Draws a quadratic Bezier curve

Description

quadraticCurveTo(cx, xy, x, y) draws a quadratic Bezier curve to (x, y) with the control point (cx, cy).

Example


<!DOCTYPE HTML>
<html>
    <head>
        <script>
            window.onload = function(){<!--from  w  w w.  j av  a  2  s  .c o m-->
                var canvas = document.getElementById("myCanvas");
                var context = canvas.getContext("2d");
                
                context.lineWidth = 10;
                context.strokeStyle = "black"; // line color
                context.moveTo(100, canvas.height - 50);
                context.quadraticCurveTo(canvas.width / 2, 
                                         -50, 
                                         canvas.width - 100, 
                                         canvas.height - 50);
                context.stroke();
            };
        </script>
    </head>
    <body>
        <canvas id="myCanvas" width="600" height="250" style="border:1px solid black;">
        </canvas>
    </body>
</html>

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window