HTML 5 Canvas vs. SVG

黄舟
Release: 2016-12-27 14:52:50
Original
1282 people have browsed it

Canvas and SVG both 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 every element in the SVG DOM is available. You can attach a JavaScript event handler to an element.

In SVG, each drawn graphic is considered an object. If the properties of an SVG object change, the browser can automatically reproduce the graphic.

Canvas

Canvas draws 2D graphics through JavaScript.

Canvas is rendered pixel by pixel.

In canvas, once a graphic is drawn, it will no longer receive the browser's attention. If its position changes, the entire scene needs to be redrawn, including any objects that may have been covered by graphics.

Comparison of Canvas and SVG

The following table lists some of the differences between canvas and SVG.

Canvas

Depends on resolution

Does not support event handlers

Weak text rendering capabilities

Able to render as .png or . Save the resulting image in jpg format

Best for graphics-intensive games where many objects will be redrawn frequently

SVG

Does not depend on resolution

Support Event Handlers

Best suited for applications with large rendering areas (such as Google Maps)

High complexity will slow down rendering (any application that overuses the DOM is not fast)

Not suitable for game applications

The above is the content of HTML 5 Canvas vs. SVG. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!