?

Log in

Previous Entry | Next Entry

We are thankful to www.questpond.com to provide these HTML 5 interview questions. They have awesome 500 videos ASP.NET and C# interview questions and answers which are awesome for interview preparation for .NET interviews.

What is SVG?

SVG stands for scalable vector graphics. It’s a text based graphic language which draws images using text, lines, dots etc. This makes it lightweight and renders faster.


Can we see a simple example of SVG using HTML 5?

Let’s say we want to display the below simple line using HTML 5 SVG.


                                        svg1

Below is how the code of HTML 5. You can see the SVG tag which encloses the polygon tag for displaying the star image.

c1

What is canvas in HTML 5?

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

So how can we draw a simple line on Canvas?


  • Define the Canvas area.

  • Get access to canvas context area.

  • Draw the graphic.

Define the canvas area

So to define canvas area you need to use the below HTML code. This defines the area on which you can draw.

c2

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.

c3

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.

c4

Below is the complete code.

c5

You should get the below output.

                                                  svg2


       

Copy right www.questpond.com

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

January 2017
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Tags

Powered by LiveJournal.com