Home >Web Front-end >JS Tutorial >SVG-based web page graphics drawing API introduction and programming demonstration_javascript skills
SVG-based web page graphics drawing API introduction and programming demonstration_javascript skills
WBOYOriginal
2016-05-16 17:30:551068browse
1: What is SVG SVG is a 2D graphics description language released by W3C in 1999. It is a markup language purely based on XML format. The full name of SVG is scalable vector graphics and traditional Raster There is a big difference in the format of graphics (JPG, PNG, GIF, etc.). SVG is a 2D graphics development platform, including two parts, one is data description based on XML language, and the other part is a programmable API. Its key features support graphics, text, gradient fill, brush style, graphics Special effect filters such as Gaussian blur will be demonstrated in the code later. It also supports various mouse events and DOM part API. Almost all mainstream browsers support the rendering and rendering of SVG graphics format. IE9 and above also begin to support SVG. In lower versions of IE, plug-in support is required. To learn more about SVG, visit here: http://www.w3.org/Graphics/SVG/About.html
Two: SVG API programming demonstration in JavaScript Create and obtain SVG object
window.onload = function() { // get DIV var container = document.getElementById("svgContainer"); // create svg object var mySvg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); mySvg.setAttribute("version", "1.2");// IE9 support SVG 1.1 version mySvg.setAttribute("baseProfile", "tiny"); container.appendChild(mySvg);
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