|
The SVG language |
|
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="300px" height="100px"> <desc>Example InitialCoords - SVG's initial coordinate system</desc> <g style="fill:none; stroke:black; stroke-width:3">
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="400px" height="150px"> <desc>Example xform1Orig - Simple transformations: original picture</desc> <g style="fill:none; stroke:black; stroke-width:3"> <!-- Draw the axes of the original coordinate system --> <line x1="0" y1="1.5" x2="400" y2="1.5" /> <line x1="1.5" y1="0" x2="1.5" y2="150" /> </g> <g> <text x="30" y="30" style="font-size:20 font-family:Verdana"> ABC (orig coord system) </text> </g> </svg> |
![]() |
| ?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="400px" height="150px"> <desc>Example xform1NewCoordSys - New user coordinate system</desc> <g style="fill:none; stroke:black; stroke-width:3"> <!-- Draw the axes of the original coordinate system --> <line x1="0" y1="1.5" x2="400" y2="1.5" /> <line x1="1.5" y1="0" x2="1.5" y2="150" /> </g> <g> <text x="30" y="30" style="font-size:20 font-family:Verdana"> ABC (orig coord system) </text> </g> <!-- Establish a new coordinate system, which is shifted (i.e., translated) from the initial coordinate system by 50 user units along each axis. --> <g transform="translate(50,50)"> <g style="fill:none; stroke:red; stroke-width:3"> <!-- Draw lines of length 50 user units along the axes of the new coordinate system --> <line x1="0" y1="0" x2="50" y2="0" style="stroke:red"/> <line x1="0" y1="0" x2="0" y2="50" /> </g> <text x="30" y="30" style="font-size:20 font-family:Verdana"> ABC (translated coord system) </text> </g> </svg> |
![]() |
| ?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="400px" height="120px"> <desc>Example RotateScale - Rotate and scale transforms</desc> <g style="fill:none; stroke:black; stroke-width:3"> <!-- Draw the axes of the original coordinate system --> <line x1="0" y1="1.5" x2="400" y2="1.5" /> <line x1="1.5" y1="0" x2="1.5" y2="120" /> </g> <!-- Establish a new coordinate system whose origin is at (50,30) in the initial coord. system and which is rotated by 30 degrees. --> <g transform="translate(50,30)"> <g transform="rotate(30)"> <g style="fill:none; stroke:red; stroke-width:3"> <line x1="0" y1="0" x2="50" y2="0" /> <line x1="0" y1="0" x2="0" y2="50" /> </g> <text x="0" y="0" style="font-size:20; font-family:Verdana; fill:blue"> ABC (rotate) </text> </g> </g> <!-- Establish a new coordinate system whose origin is at (200,40) in the initial coord. system and which is scaled by 1.5. --> <g transform="translate(200,40)"> <g transform="scale(1.5)"> <g style="fill:none; stroke:red; stroke-width:3"> <line x1="0" y1="0" x2="50" y2="0" /> <line x1="0" y1="0" x2="0" y2="50" /> </g> <text x="0" y="0" style="font-size:20; font-family:Verdana; fill:blue"> ABC (scale) </text> </g> </g> </svg> |
![]() |
| ?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="400px" height="120px"> <desc>Example Skew - Show effects of skewX and skewY</desc> <g style="fill:none; stroke:black; stroke-width:3"> <!-- Draw the axes of the original coordinate system --> <line x1="0" y1="1.5" x2="400" y2="1.5" /> <line x1="1.5" y1="0" x2="1.5" y2="120" /> </g> <!-- Establish a new coordinate system whose origin is at (30,30) in the initial coord. system and which is skewed in X by 30 degrees. --> <g transform="translate(30,30)"> <g transform="skewX(30)"> <g style="fill:none; stroke:red; stroke-width:3"> <line x1="0" y1="0" x2="50" y2="0" /> <line x1="0" y1="0" x2="0" y2="50" /> </g> <text x="0" y="0" style="font-size:20; font-family:Verdana; fill:blue"> ABC (skewX) </text> </g> </g> <!-- Establish a new coordinate system whose origin is at (200,30) in the initial coord. system and which is skewed in Y by 30 degrees. --> <g transform="translate(200,30)"> <g transform="skewY(30)"> <g style="fill:none; stroke:red; stroke-width:3"> <line x1="0" y1="0" x2="50" y2="0" /> <line x1="0" y1="0" x2="0" y2="50" /> </g> <text x="0" y="0" style="font-size:20; font-family:Verdana; fill:blue"> ABC (skewY) </text> </g> </g> </svg> |
![]() |

where
tx
and ty are the translation distances along the x and y axes
where
sx
and sy are the scaling factors along the x and y axes
where
a
is the rotation angle
where
a
is the skewing angle towards y
where
a
is the skewing angle towards y

| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd" [ <!ENTITY Smile " <rect x='.5' y='.5' width='29' height='39' style='fill:yellow; stroke:red'/> <g transform='rotate(90)'> <text x='10' y='10' style='font-family:Verdana; font-weight:bold; font-size:14'>:)</text> </g>"> <!ENTITY Viewport1 "<rect x='.5' y='.5' width='49' height='29' style='fill:none; stroke:blue'/>"> <!ENTITY Viewport2 "<rect x='.5' y='.5' width='29' height='59' style='fill:none; stroke:blue'/>"> ]> <svg width="480px" height="270px" style="font-family:Verdana; font-size:8"> <desc>Example PreserveAspectRatio - demonstrate available options</desc> <text x="10" y="30">SVG to fit</text> <g transform="translate(20,40)">&Smile;</g> <text x="10" y="110">Viewport 1</text> <g transform="translate(10,120)">&Viewport1;</g> <text x="10" y="180">Viewport 2</text> <g transform="translate(20,190)">&Viewport2;</g> <text x="100" y="30">--------------- meet ---------------</text> <g transform="translate(100,60)"><text y="-10">xMin*</text>&Viewport1; <svg preserveAspectRatio="xMinYMin meet" viewBox="0 0 30 40" width="50" height="30">&Smile;</svg></g> <g transform="translate(170,60)"><text y="-10">xMid*</text>&Viewport1; <svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 30 40" width="50" height="30">&Smile;</svg></g> <g transform="translate(240,60)"><text y="-10">xMax*</text>&Viewport1; <svg preserveAspectRatio="xMaxYMax meet" viewBox="0 0 30 40" width="50" height="30">&Smile;</svg></g> <text x="330" y="30">---------- meet ----------</text> <g transform="translate(330,60)"><text y="-10">*YMin</text>&Viewport2; <svg preserveAspectRatio="xMinYMin meet" viewBox="0 0 30 40" width="30" height="60">&Smile;</svg></g> <g transform="translate(380,60)"><text y="-10">*YMid</text>&Viewport2; <svg preserveAspectRatio="xMidYMid meet" viewBox="0 0 30 40" width="30" height="60">&Smile;</svg></g> <g transform="translate(430,60)"><text y="-10">*YMax</text>&Viewport2; <svg preserveAspectRatio="xMaxYMax meet" viewBox="0 0 30 40" width="30" height="60">&Smile;</svg></g> <text x="100" y="160">---------- slice ----------</text> <g transform="translate(100,190)"><text y="-10">xMin*</text>&Viewport2; <svg preserveAspectRatio="xMinYMin slice" viewBox="0 0 30 40" width="30" height="60">&Smile;</svg></g> <g transform="translate(150,190)"><text y="-10">xMid*</text>&Viewport2; <svg preserveAspectRatio="xMidYMid slice" viewBox="0 0 30 40" width="30" height="60">&Smile;</svg></g> <g transform="translate(200,190)"><text y="-10">xMax*</text>&Viewport2; <svg preserveAspectRatio="xMaxYMax slice" viewBox="0 0 30 40" width="30" height="60">&Smile;</svg></g> <text x="270" y="160">--------------- slice ---------------</text> <g transform="translate(270,190)"><text y="-10">*YMin</text>&Viewport1; <svg preserveAspectRatio="xMinYMin slice" viewBox="0 0 30 40" width="50" height="30">&Smile;</svg></g> <g transform="translate(340,190)"><text y="-10">*YMid</text>&Viewport1; <svg preserveAspectRatio="xMidYMid slice" viewBox="0 0 30 40" width="50" height="30">&Smile;</svg></g> <g transform="translate(410,190)"><text y="-10">*YMax</text>&Viewport1; <svg preserveAspectRatio="xMaxYMax slice" viewBox="0 0 30 40" width="50" height="30">&Smile;</svg></g> </svg> |
![]() |
![]() |

| ?xml version="1.0" standalone="no"?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > <svg width="600px" height="200px">
|
![]() |
| <?xml version="1.0" standalone="no" ?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > <svg width="500" height="700" > <g style="text-rendering:optimizeLegibility;shape-rendering:default"> <text x="5" y="20" style="font-size:24">SVG Demo: More elliptical arcs</text> <g style="stroke-width:4 ; fill:none; stroke:blue"
>
<g style="font-size:8" >
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > <svg width="500" height="500" > <g style="text-rendering:optimizeLegibility;shape-rendering:default"> <text x="5" y="20" style="font-size:22">SVG Demo: Basic SVG shapes</text> <g style="stroke:black; fill:none; shape-rendering:default"
>
<g style="text-rendering:optimizeSpeed">
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > <svg width="680" height="500" >
<g style="stroke:blue; fill:red; shape-rendering:default;
stroke-width:10" >
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="10cm" height="3cm"> <desc>Example tspan01 - using tspan to change visual attributes</desc> <g style="font-family:Verdana; font-size:12pt">
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="10cm" height="3cm"> <desc>Example tspan02 - using tspan's dx and dy attributes for incremental positioning adjustments</desc> <g style="font-family:Verdana; font-size:12pt">
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="10cm" height="3cm"> <defs> <text id="ReferencedText"> Referenced character data </text> </defs> <desc>Example tspan04 - inline vs reference text content</desc> <text x="1cm" y="1cm" style="font-size:12pt; fill:blue">
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="10cm" height="3cm" viewBox="0 0 1000 300"> <defs> <path id="MyPath" d="M 100 200 C 200 100 300 0 400 100 C 500 200 600 300 700 200 C 800 100 900 100 900 100" /> </defs> <desc>Example toap01 - simple text on a path</desc> <use xlink:href="#MyPath" style="stroke:red" />
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > <svg width="500" height="500" >
<text x="5" y="20" style="font-size:22">SVG Demo: Stroke and fill opacity.</text> <rect x="10" y="100" width="400" height="100"
style="fill:yellow" />
<g style="stroke:blue;fill:cyan">
<text x="40" y="385">0.2</text>
</g>
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > <svg width="525" height="500" >
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > <svg width="500px" height="600px" >
<defs>
<text x="5" y="20" style="font-size:22">SVG Demo: Linear gradients</text> <path style="fill:url(#grad1)" d="M0 50 h200 v200 h-200 z"/> <circle style="fill:url(#grad1)" cx="320" cy="150" r="100" /> <polygon style="fill:url(#grad1)" points="0,400,200,400,100,280" /> <ellipse style="fill:url(#grad1)" cx="300" cy="350" rx="100" ry="75"/> <rect style="fill:url(#grad1)" x="0" y="450" width="400" height="100" /> </g>
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > < <svg width="500px" height="500px" > <g style="text-rendering:optimizeLegibility;shape-rendering:default"> <defs>
<text x="5" y="20" style="font-size:22">SVG Demo: Radial gradient</text> <rect style="fill:url(#grad1)" x="50" y="50" width="400" height="400" /> </g>
|
![]() |
| <?xml version="1.0"?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > <svg width="600px" height="500px" > <defs>
<g style="text-rendering:optimizeLegibility" >
<g style="stroke:none; shape-rendering:default" >
</svg>
|
![]() |
| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg SYSTEM "svg-19991203.dtd" > <svg width="500" height="500" > <defs>
<g style="text-rendering:optimizeLegibility;shape-rendering:default"
>
<ellipse cx="200" cy="220" rx="90" ry="130"
style="fill:#CE8A77" />
|
![]() |
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN"
"http://www.w3.org/Graphics/SVG/SVG-19991203.dtd">
<svg width="4in" height="3in">
<desc>Example of using a mask
</desc>
<g>
<defs>
<mask id="MyMask">
<image width="10" height="25" xlink:href="transp.png" />
</mask>
</defs>
<rect style="mask: url(#MyMask)" width="12.5" height="30" />
</g>
</svg>
or

| <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG December 1999//EN" "http://www.w3.org/Graphics/SVG/SVG-19991203.dtd"> <svg width="278px" height="118px"> <defs> <filter id="Shadow"> <feGaussianBlur in="SourceAlpha" stdDeviation="3" result="blurredAlpha" /> <feOffset in="blurredAlpha" dx="2" dy="1" result="offsetBlurredAlpha" /> <feDiffuseLighting in="blurredAlpha" diffuseConstant=".5" surfaceScale="5" resultScale="5" LightColor="white" result="bumpMapDiffuse" > <feDistantLight azimuth="135" elevation="60"/> </feDiffuseLighting> <feComposite in="bumpMapDiffuse" in2="SourceGraphic" operator="arithmetic" k1="1" result="litPaint" /> <feSpecularLighting in="blurredAlpha" surfaceScale="5" specularConstant=".5" specularExponent="10" lightColor="white" result="bumpMapSpecular" > <feDistantLight azimuth="135" elevation="60"/> </feSpecularLighting> <feComposite in="litPaint" in2="bumpMapSpecular" operator="arithmetic" k2="1" k3="1" result="litPaint" /> <feComposite in="litPaint" in2="SourceAlpha" operator="in" result="litPaint" /> <feMerge> <feMergeNode in="offsetBlurredAlpha" /> <feMergeNode in="litPaint" /> </feMerge> </filter> </defs> <desc>Example filters02 - text with shadowing effect</desc> <text style="font-size:36px; fill:red; filter:url(#Shadow)"
|
![]() |
<!-- The following illustrates the use of the 'animate'
element
to animate a rectangles x, y, and width attributes so that
the rectangle grows to ultimately fill the viewport. -->
<rect id="RectElement" x="300" y="100" width="300" height="100"
style="fill:rgb(255,255,0)" >
<animate attributeName="x" attributeType="XML"
begin="0s" dur="9s" fill="freeze"
from="300" to="0" />
<animate attributeName="y" attributeType="XML"
begin="0s" dur="9s" fill="freeze"
from="100" to="0" />
<animate attributeName="width" attributeType="XML"
begin="0s" dur="9s" fill="freeze" from="300" to="800"
/>
<animate attributeName="height" attributeType="XML"
begin="0s" dur="9s" fill="freeze" from="100" to="300" />
</rect>
<!-- Set up a new user coordinate system so that
the text string's origin is at (0,0), allowing
rotation and scale relative to the new origin -->
<g transform="translate(100,100)" >
<!-- The following illustrates the use of
the 'set', 'animateMotion',
'animateColor' and 'animateTransform' elements. The 'text' element
below starts off hidden (i.e., invisible). At 3 seconds,
it:
* becomes visible
* continuously moves diagonally across the viewport
* changes color from blue to dark red
* rotates from -30 to zero degrees
* scales by a factor of three. -->
<text id="TextElement" x="0" y="0"
style="font-family:Verdana; font-size:35.27; visibility:hidden"
>
It's alive!
<set attributeName="visibility" attributeType="CSS" to="visible"
begin="3s" dur="6s" fill="freeze" />
<animateMotion path="M 0 0 L 100 100"
begin="3s" dur="6s" fill="freeze" />
<animateColor attributeName="fill" attributeType="CSS"
from="rgb(0,0,255)" to="rgb(128,0,0)"
begin="3s" dur="6s" fill="freeze" />
<animateTransform attributeName="transform" attributeType="XML"
type="rotate" from="-30" to="0"
begin="3s" dur="6s" fill="freeze" /><animateTransform attributeName="transform" attributeType="XML"
![]() |
![]() |
![]() |
![]() |
<?xml version="1.0" standalone="yes"?>
<svg width="100%" height="100%"
xmlns = 'http://www.w3.org/Graphics/SVG/SVG-19991203.dtd'>
<defs>
<font id="MyFont" font-face-name="Super
Sans"
units-per-em="1000" cap-height="600" x-height="400"
ascent="700" descent="300" horiz-adv-x="1000"
text-bottom="-300" baseline="0" centerline="350"
mathline="350" ideographic="400" hanging="500"
topline="700" text-top="700">
<missing-glyph><path
d="M0,0h200v200h-200z"/></glyph>
<glyph unicode="33"><path
d="M0,0L200,200L400,0z"/></glyph>
<glyph unicode="34"><path
d="M0,0L200,200L400,0z"/></glyph>
<!-- more glyphs
-->
</font>
</defs>
</svg>