Wednesday, February 17, 2010

SVG format

SVG is a language for describing two-dimensional graphics in XML [XML10]. SVG allows for three types of graphic objects: vector graphic shapes (e.g., paths consisting of straight lines and curves), images and text. Graphical objects can be grouped, styled, transformed and composited into previously rendered objects. The feature set includes nested transformations, clipping paths, alpha masks, filter effects and template objects.[1]
File extension SVG is mostly used in describing two-dimensional vector graphics in XML format. SVG stands for Scalable Vector Graphics. Data can be stored on its own file or can be embedded in a web page. However, not all web browsers are capable of interpreting it. File of this extension can be static or animated images. Since this is in XML format, SVG files can be opened by using text editors. These are images written as text. Vector images use geometrical figures represented by mathematical equations as oppose to raster images that uses pixels represented with different colors to create an image.[2]
With SVG, it can be fill (i.e., paint the interior) or stroke (i.e., paint the outline) of shapes and text using one of the following[3]
• color (using or the 'solidColor' element)
• gradients (linear or radial)
• patterns (vector or image, possibly tiled)


Advantages of using SVG over other image formats (like JPEG and GIF) [4]
• SVG is an open standard
• SVG files are pure XML
• SVG files can be read and modified by a large range of tools (e.g. notepad)
• SVG files are smaller and more compressible than JPEG and GIF images
• SVG images are scalable
• SVG images can be printed with high quality at any resolution
• SVG images are zoomable (and the image can be zoomed without degradation)
• SVG works with Java technology

The biggest advantage SVG has over Flash is the compliance with other standards (e.g. XSL and the DOM). Flash relies on proprietary technology that is not open source.




Security considerations
SVG documents may be transmitted in compressed form using gzip compression. For systems which employ MIME-like mechanisms, such as HTTP, this is indicated by the Content-Transfer-Encoding header; for systems which do not, such as direct file system access, this is indicated by the filename extension and by the Macintosh File Type Codes. In addition, gzip compressed content is readily recognized by the initial byte sequence [5].
Compressed SVG files are typically 50 to 80 percent smaller than SVG files and are automatically decompressed by the Adobe SVG Viewer with no noticeable delay to the user [6].
SVG documents may reference external media such as images, audio, video, style sheets, and scripting languages. Scripting languages are executable content. In this case, the security considerations in the Media Type registrations for those formats shall apply. if the processor follows only the normative semantics of this specification, this content will be outside the SVG namespace and shall be ignored. Only in the case where the processor recognizes and processes the additional content, or where further processing of that content is dispatched to other processors, would security issues potentially arise. And in that case, they would fall outside the domain of this registration document [5].
Simple svg example for Text[7]




It was the best of times


It was the worst of times.



The text element is used to write text at a location. The location is given in absolute terms with the x and y attributes or a relative location with dx and dy attributes.


Simple svg example for Circle(shape)[8]






The SVG element is used to create a circle. The cx and cy attributes define the x and y coordinates of the center of the circle. If cx and cy are omitted, the circle's center is set to (0, 0). The r attribute defines the radius of the circle.
Manipulate SVG Document From XML[9]
To manipulate SVG documents from XML it is needed to Encoding the Parts Catalog into XML.The parts catalog document is an XML document having as its root a element. This element inherits the xlink:extended characteristics by including the xlink:type attribute set to "extended." The root element also contains another attribute, the xml:base, which defines the base document location for all the contained locators. The xml:base attribute value points to the SVG document that encodes the small motor illustration(as an example).
xlink:type="extended"
xml:base="figure.svg"
xlink:title="motor">
... Locators ...

Each part contained in the motor assembly is modeled as an xlink:locator element that refers to a numbered circle pointing to a part in the exploded view illustration. A contained part element (a locator) contains a part description, a link to a more detailed view and quantity. The element points to a more detailed external parts document if a part is composed of other parts (i.e., if it is an assembly itself). That external view is another XML document encoded the same way .


1
Cylinder head



[1]Scalable Vector Graphics (SVG) 1.1 Specification W3C Recommendation 14 January 2003
[2] http://svg.extensionfile.net/
[3] http://www.w3.org/TR/SVG11/pservers.html
[4] http://www.w3schools.com/svg/svg_intro.asp
[5] http://www.w3.org/TR/SVGMobile12/mimereg.html
[6] http://www.adobe.com/svg/illustrator/compressedsvg.html
[7] http://www.svgbasics.com/simple_text.html
[8] http://www.w3schools.com/svg/svg_example.asp
[9] http://www.xml.com/lpt/a/67

No comments:

Post a Comment