Thursday , November 7 2024

What is canvas in HTML 5?

Canvas is an HTML area on which you can draw graphics.

<canvas height=""500"" id=""mycanvas"" solid=""style=""border:1px" width=""600""></canvas>

Get access to canvas area

To draw on the canvas area we need to first get reference of the context section. Below is the code for canvas section.

var c=document.getElementById("mycanvas"); var ctx=c.getContext("2d"); 

Draw the graphic

Now once you have access to the context object we can start drawing on the context. So first call the “move” method and start from a point , use line method and draw the line and then apply stroke over it.

<a name="WhatisthedifferencebetweenCanvasandSVGgraphics">What is the difference between Canvas and SVG graphics? </a>

About admin

Leave a Reply