HTML 5 canvas vs SVG

(*-*)浩
Release: 2019-10-26 16:04:04
Original
2158 people have browsed it

Canvas and SVG both allow you to create graphics in the browser, but they are fundamentally different.

HTML 5 canvas vs SVG

SVG (Recommended learning: html tutorial)

SVG is a method that uses XML A language for describing 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 uses JavaScript to draw 2D graphics.

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

Resolution dependent

No event handler support

Weak text rendering capabilities

Ability to save the resulting image in .png or .jpg format

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

SVG

Not dependent on resolution

Supports event handlers

Best 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 detailed content of HTML 5 canvas vs SVG. For more information, please follow other related articles on the PHP Chinese website!

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