HTML 5 Canvas vs. SVG
- HTML5 SVG
- HTML5 Geo-positioning
Canvas and SVG allow you to create graphics in the browser, but they are fundamentally different.
Svg
SVG is a language that uses XML to describe 2D graphics.
SVG is based on XML, which means that every element in the SVG DOM is available. You can attach a JavaScript event handler to an element.
In SVG, each drawn shape is treated as an object. If the properties of the SVG object change, the browser can automatically reproduce the graphic.
Canvas
Canvas uses JavaScript to draw 2D graphics.
The Canvas is rendered per pixel.
In the canvas, once the drawing is drawn, it will not continue to get the attention of the browser. If its position changes, the entire scene also needs to be redrawn, including any objects that might have been overwritten by the graphic.
Comparison of Canvas and SVG
The following table lists some of the differences between canvas and SVG.
Canvas
- Dependent resolution
- Event handlers are not supported
- Weak text rendering capabilities
- Ability to save result images in. png or. jpg format
- Best for image-intensive games where many of the objects are redrawn frequently
- Not dependent on resolution
- Support for event handlers
- Best for applications with large rendering areas (e.g. Google Maps)
- High complexity slows rendering speed (any applications that overuse the DOM are unpleasant)
- Not suitable for gaming applications
Svg
H5 Canvas vs. SVG