HTML5 Canvas vs SVG/VML? [closed]
Asked Answered
D

1

0

Please tell me what do you think about HTML5 Canvas vs SVG/VML? Give me pros and cons within comparison.

Thank you!!!

Distance answered 2/12, 2010 at 19:36 Comment(1)
This 'question' is "Bad Subjective", and should be closed.Showcase
E
6

HTML5 Canvas is simply a drawing surface for a bit map. You set up a draw (Say with a color and line thickness) , draw that thing, and then the Canvas has no knowledge of that thing: It doesn't know where it is or what it is, it's just pixels. If you want to draw rectangles and have them move around or be selectable then you have to code all of that from scratch, including the code to remember that you drew them.

On the other hand, every SVG/VML element you create is a real element in the DOM. By default this allows you to keep much better track of the elements you create and makes dealing with things like mouse events easier by default.

Canvas would be better for faster things and heavy bitmap manipulation (like animation), but will take more code if you want lots of interactivity.

Eloquence answered 2/12, 2010 at 20:7 Comment(1)
There is a useful library called Easel.js which lets you get mouse events from objects you add in canvas, check it out.Braithwaite

© 2022 - 2024 — McMap. All rights reserved.