How to draw paths using Quadratic Curve & Bezier Curve in HTML5

where to order essays In this http://saharatravelservices.com/need-help-with-homework-personal-finance/ html5 canvas tutorial we will discuss about some shapes & also some additional features of canvas.
To draw quadratic curve, html5 has a function named quadraticCurveTo().
The implemetation looks like,

go to site <!DOCTYPE HTML> <html> <head> </head> <body> <canvas id="myCanvas" width="578" height="200"></canvas> <script> var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); context.beginPath(); context.moveTo(188, 150); context.quadraticCurveTo(258, 0, 388, 150); context.lineWidth = 10; // line color context.strokeStyle = 'black'; context.stroke(); </script> </body> </html>

http://arislesmana.com/?p=who-wants-to-do-my-homework-for-me Explanation:
The javascript portion is just like before. Only difference is, the presence of quadraticCurveTo()

http://zqgylm.com/?p=help-i-need-a-thesis-statement It takes 4 parameters as input.

http://akada.org/small-business-pension-plan/ small business pension plan context.quadraticCurveTo(258, 0, 388, 150);

business plan template word document The start point is set with context.moveTo(188, 150)

http://namaskarindiatour.com/?p=interior-design-essay The control point is set with 1st two parameters of context.quadraticCurveTo(258, 0, 388, 150);

http://fandiasydo.com/?p=first-day-in-college-essay The end point is set with last two parameters of context.quadraticCurveTo(258, 0, 388, 150);

follow url Output:

Best Law School Personal Statement Editing Service Drawing paths using Quadratic Curve & Bezier Curve in HTML51

how to write resume for high school students If we analyze the output,
Drawing paths using Quadratic Curve & Bezier Curve in HTML52
Bezier curve is advance form of quadratic curve, where we have two control points instead of one. Just like quadraticCurveTO(), html5 also have bezierCurveTo().

The implementation looks like,

<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<canvas id="myCanvas" width="578" height="200"></canvas>
<script>
    var canvas = document.getElementById('myCanvas');
    var context = canvas.getContext('2d');
    context.beginPath();
    context.moveTo(188, 150);
    context.bezierCurveTo(158, 0, 370, 0, 388, 150);
    context.lineWidth = 10;
    // line color
    context.strokeStyle = 'black';
    context.stroke();
</script>
</body>
</html>

Explanation:
Have a glance at the bezierCurveTo() function.

We have provided two control points as, one at ( 158, 0) & another at ( 370, 0).

The end point is at ( 388, 150 ).

Output:
Drawing paths using Quadratic Curve & Bezier Curve in HTML53
If we analize the output, apparently it is like,
Drawing paths using Quadratic Curve & Bezier Curve in HTML54
In addition, if we want to create our path, we cannot connect multiple subpaths. We can do it by using quadratic curve & bezier curve. Here is an example,


<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 1px;
padding: 20px;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="600" height="300"></canvas>
<script>
    var canvas = document.getElementById('myCanvas');
    var context = canvas.getContext('2d');

    context.beginPath();
    context.moveTo(100, 20);
    // quadratic curve
    context.quadraticCurveTo(230, 200, 250, 120);

    // bezier curve
    context.bezierCurveTo(290, -40, 300, 200, 400, 14);
    context.lineWidth = 5;
    context.stroke();

</script>
</body>
</html>

The output look like,
Drawing paths using Quadratic Curve & Bezier Curve in HTML55
Illustration looks like,
Drawing paths using Quadratic Curve & Bezier Curve in HTML56
In the above picture the 1st control point is for quadratic curve & the another two is for bezier curve.

If you find this article helpful, you can connect us in  http://newstylus.com/?p=dissertation-littraire-andromaque Google+ and dissertation studies  Twitter.

Want to get blog updates? Subscribe here

[newsletter_form]

Enter your email address:

Delivered by FeedBurner

Leave a Reply

Your email address will not be published. Required fields are marked *