H5 Canvas vs. SVG

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.