Logo
  Sunday, May 20, 2012
Sign-In  |  Sign-Up  |  Contact Us  | Bookmark |  RSS Feed

HTML5 Tutorial FeedBurner

Drawing Curves in HTML5  
HTML5 allows you to draw curves on HTML5 canvas. They way to do it is with the help of paths. We use different functions to create curves with a quadratic curve being one of them.

Let us start with the example

<script>

    function drawingExample(context) {

        context.save();

        context.translate(-1,35);

        context.beginPath();

        context.moveTo(0,0);

        context.quadraticCurveTo(100,-20,200,-100); //Curve one

        context.quadraticCurveTo(200,-40,400,-50); //curve two

        context.strokeStyle="#442299";

        context.lineWidth=10;

        context.stroke();

        context.restore();

    }

</script>

There is a concept of the control point in HTML5 curves and we specify this point at first position on our canvas. This control point is the point around which our curve will bend. It is not part of the curve but is positioned right outside where line makes a curve. This control point allows you to adjust your curve one way or another and can be set or reset to your desired position.

See picture for visual representation of this control point below.

Drawing Curves

There are other commands for curves in HTML5: bezierCurveTo, arctTo and other arc functions. They are more complex in nature and take angels as attributes and parameters.

Print Drawing Curves in HTML5 Bookmark Drawing Curves in HTML5

Related Articles  
Using HTML5 Canvas
HTML5 canvas element creates rectangular area on your HTML5 webpage. It is defaulted at 350 by 150 pixels which can be ...
HTML5 canvas browser compatibility
HTML5 is not official and mandated version of HTML and not every browser vendor supports it. You need to be aware of ...
Working with underlying pixels in the HTML5 canvas
HTML5 developer can gain access to individual pixel in the canvas. The way it is accomplished is via a numerical array.
How to insert Images into a canvas in HTML5?
HTML5 allows adding and manipulating images inside a canvas. Images can be modified, stretched and stamped with the ...
Creating Shadow Effect with HTML5
HTML5 shadows are controlled by several operations available in HTML5 arsenal of operations. The shadow effect can be ...
HTML5 Fill Styles
HTML5 canvas allows you to fill paths and subpaths. The Fill Styles are used for this purpose and you can do it with ...
More