Render Graphics with SVG
With SVG, you can represent graphics as XML documents and render them in Internet Explorer with Adobe’s SVG Viewer, in Netscape with Corel’s SVG Viewer, in a branch of Mozilla that supports SVG, and in Batik’s Squiggle.
Scalable Vector Graphics or SVG (http://www.w3.org/Graphics/SVG/) is an XML vocabulary for describing two-dimensional graphics. Using XML instead of one of a variety of proprietary graphical formats, SVG has enormous potential as a method for storing and transporting graphics. It was developed by the W3C and is currently at Version 1.1 (http://www.w3.org/TR/SVG11/).
SVG is popular and the number of implementations is steadily increasing. Adobe provides a popular browser plug-in, SVG Viewer 3.0, which runs on Windows and the Mac. (There is a rumor floating about that it will soon run on Linux.) Mozilla.org has a version of its browser, a branch off the main trunk of code, that supports SVG rendering natively (i.e., without a plug-in). Apache’s Batik project offers an SVG browser written in Java.
Following is a simple example of an SVG document that renders some colored text, text.svg (Example 4-13):
Example 4-13. text.svg
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns="http://www.w3.org/2000/svg" width="600px" height="300px" font-size="150px"> <rect fill="none" stroke="black" stroke-width="3" x="170" y="65" width="235px" height="125px"/> <text ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access