YLBTECH-HTML5:HTML5 inline SVG |
1, HTML5inline SVG
HTML5 supports inline SVG.
What is SVG?
- SVG refers to a scalable vector graphic (Scalable vector graphics)
- SVG is used to define vector-based graphics for the network
- SVG defines graphics using XML format
- SVG images have no loss of graphics quality when zooming in or out of size
- SVG is the standard of the World Wide Web Consortium
SVG advantages
Compared to other image formats (such as JPEG and GIF), the advantage of using SVG is that:
- SVG images can be created and modified by a text editor
- SVG images can be searched, indexed, scripted, or compressed
- SVG is scalable
- SVG images can be printed with high quality at any resolution
- SVG can be amplified when the image quality is not degraded
Browser support
Internet Explorer + +, Firefox, Opera, Chrome, and Safari support inline SVG.
Embed SVG directly into an HTML page
In HTML5, you can embed SVG elements directly into an HTML page:
Instance
<!DOCTYPE HTML><HTML><Body> <svgxmlns= "Http://www.w3.org/2000/svg"version= "1.1"Height= " the"> <Polygonpoints= "100,10 40,180 190,60 10,60 160,180"style= "fill:lime;stroke:purple;stroke-width:5;fill-rule:evenodd;"></svg> </Body></HTML>
Try it?
Results:
Sorry, your browser does not support inline SVG.
To learn more about the SVG tutorial, please visit the SVG tutorial.
The difference between SVG and canvas
SVG is a language that uses XML to describe 2D graphics .
Canvas uses JavaScript to draw 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.
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 |
SVG |
- 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
|
2.
1, HTTP://WWW.RUNOOB.COM/HTML/HTML5-SVG.HTML2,
|
Ylbtech Source: http://ylbtech.cnblogs.com/ This article is copyright to the author and the blog Park, Welcome to reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to the original link, otherwise reserves the right to pursue legal responsibility. |
HTML5:HTML5 inline SVG