croczilla.com 
 home   zap   svg   xtf   jssh   bits&pieces   blog   personal   
  home > svg > samples

All SVG Samples


screenshot

Arcs 1

Ellipses built using <path>s, generated by script.

Now works in ASV as well.

File(s):

arcs1.svg [Open |  View as text]

screenshot

Butterfly

This is a slightly modified version of a sample that shipped with Jasc WebDraw.

File(s):

butterfly.svg [Open |  View as text]

screenshot

Chem 1

A structural diagram 'stolen' with permission from Henry S. Rzepa's and Peter Murray-Rust's Chemical Examples of SVG and CML (Chemical Markup Language)

Now works in ASV as well.

File(s):

chem1.svg [Open |  View as text]

screenshot

Chem 2

chem1.xml zoomed in by a factor of eight.

File(s):

chem2.xml [Open |  View as text]

screenshot

Circles 1

This sample uses the CSS dynamic pseudo-class :hover to change the fill-opacity of three overlapping circles when the cursor is moved over them.

File(s):

circles1.svg [Open |  View as text]

screenshot

Circles 2

Essentially the same as circles1.xml, but with a background image (using <foreignObject>).

File(s):

circles2.xml [Open |  View as text]

screenshot

Diazepam

This sample is a CML (chemical markup language) file, made to render using XBL and SVG. The original file is from www.xml-cml.org.

File(s):

diazepam.xml [Open |  View as text]
cml.css [Open |  View as text]
cml-bindings.xml [Open |  View as text]

screenshot

DOM 1

Simple script-based animation of a triangle by direct manipulation of SVG DOM properties (as opposed to attributes).

This example is a compound document (rather than a pure SVG document). HTML is used to implement a button and the <script> tag.

File(s):

dom1.xml [Open |  View as text]

screenshot

DOM 2

Illustrates script-based interaction with the SVGTransformList and SVGTransform SVG DOM interfaces.

Note that the SVGTransformList::Consolidate() function is not yet implemented, hence clicking the Consolidate button will have no effect.

This example is a compound document (rather than a pure SVG document). HTML is used to implement user interface buttons and the <script> tag.

File(s):

dom2.xml [Open |  View as text]

screenshot

Ellipse 1

Examples of <ellipse> elements.

File(s):

ellipse1.xml [Open |  View as text]

screenshot

Events 1

Demonstrates simple mousedown event handlers on svg elements.

File(s):

events1.xml [Open |  View as text]

screenshot

Events 2

Drag an SVG circle around on the screen.

File(s):

events2.xml [Open |  View as text]

screenshot

Foreign 1

HTML and XUL mixed with SVG using <foreignObject>.

File(s):

foreign1.xml [Open |  View as text]

screenshot

Gradients 1

Simple example of a rectangle filled with a linear white to black gradient.

File(s):

gradients1.svg [Open |  View as text]

screenshot

Gradients 2

Simple example of a rectangle filled with a radial white to black gradient.

File(s):

gradients2.svg [Open |  View as text]

screenshot

Line 1

Examples of <line> elements with different stroke-linecap styles and stroke-widths.

File(s):

line1.xml [Open |  View as text]

screenshot

Linestroke

Illustration of the different stroking styles for lines. Sample by Andrea Salmasso.

File(s):

linestroke.xml [Open |  View as text]

screenshot

Lion

* No description available *

File(s):

lion.svg [Open |  View as text]

screenshot

Opacity 1

Dynamically constructed polygons with script animation and CSS-determined opacity (:hover).

File(s):

opacity1.xml [Open |  View as text]

screenshot

Opacity 2

Two overlapping polygons with dynamic CSS-determined opacity and stroke.

File(s):

opacity2.svg [Open |  View as text]

screenshot

Paths 1

Examples of s with l, L, h, H, v and V commands.

File(s):

paths1.xml [Open |  View as text]

screenshot

Paths 2

Examples of s with c, C, s and S commands.

File(s):

paths2.xml [Open |  View as text]

screenshot

Paths 3

Examples of s with elliptical arc segments (a, A commands). Adapted from a W3 sample.

File(s):

paths3.svg [Open |  View as text]

screenshot

Polygons 1

  • Simple stroked and filled regular polygons.
  • Slightly modified version of a sample from the W3 SVG specs.

File(s):

polygons1.svg [Open |  View as text]

screenshot

Polygons 2

Illustrates polygons, transforms, dynamic CSS style (:hover) and mixing of html/svg in a compound document.

If they are mouseovered their transparency changes.

This example is a compound document with an internal CSS style sheet wrapped in a <html:style> element. The compound document follows the structure of a html document (with outer <html> element, <head> and <body> sections) but that is not necessary in general.

File(s):

polygons2.xml [Open |  View as text]

screenshot

Polygons 3

Illustrates polygons, simple nested transforms, dynamic CSS style (:hover), attribute-selectors and mixing of html/svg in a compound document.

Two of the shapes have an attribute selectable="1". If they are mouseovered their transparency changes.

This example is a compound document with an internal CSS style sheet wrapped in a <html:style> element. The compound document follows the structure of a html document (with outer <html> element, <head> and <body> sections) but that is not necessary in general.

File(s):

polygons3.xml [Open |  View as text]

screenshot

Quadbezier 1

Examples of the quadratic bezier path commands. (Modified w3c sample by Daniele Nicolodi.)

File(s):

quadbezier1.svg [Open |  View as text]

screenshot

Rectanges 1

Example of <rect> elements.

File(s):

rect1.svg [Open |  View as text]

screenshot

Rectanges 2

* No description available *

File(s):

rect2.svg [Open |  View as text]

screenshot

Skew 1

Examples of skew transformations.

File(s):

skew1.xml [Open |  View as text]

screenshot

Style 1

Illustrates simple script-based manipulation of attributes.

This example is a compound document (rather than a pure SVG document). HTML is used to implement user interface buttons and the <script> tag.

File(s):

style1.xml [Open |  View as text]

screenshot

SVG Tetris

Yes, that game. In SVG. You know you want it :-)

Not quite finished yet, but playable.

Also works in ASV.

Now with score keeping and accelerating clock, courtesy of Tuna-Fish.

File(s):

svgtetris.svg [Open |  View as text]

screenshot

Tiger

The famous cubic spline tiger.

File(s):

tiger.svg [Open |  View as text]

screenshot

XBL Shapes 1

Moveable/Resizeable XBL/SVG triangles and cubic splines.

This sample now calls forceRedraw() for each mousemove to enhance responsiveness for recent builds that include the async painting patch of bug 261974. In older (< 4. October 2004) builds, performance on Linux will be sluggish.

File(s):

xbl-shapes.xml [Open |  View as text]
xbl-shape-bindings.css [Open |  View as text]
xbl-shape-bindings.xml [Open |  View as text]

screenshot

XBL Shapes 2

Interactive shapes, same as xbl-shapes, but with different 'stroke-dasharray' styles applied.

File(s):

xbl-shapes2.xml [Open |  View as text]
xbl-shape-bindings.css [Open |  View as text]
xbl-shape-bindings.xml [Open |  View as text]

screenshot

XBL 1

Interactively moveable transparent XBL/SVG triangles.

File(s):

xbl1.xml [Open |  View as text]
xbl1-bindings.css [Open |  View as text]
xbl1-bindings.xml [Open |  View as text]

screenshot

XBL 2

Same as xbl1.xml but with a background image.

File(s):

xbl2.xml [Open |  View as text]
xbl1-bindings.css [Open |  View as text]
xbl1-bindings.xml [Open |  View as text]

screenshot

XUL + SVG 1

This sample shows how XUL templates can be used to create SVG content from RDF datasources.

Note:

Until recently (Feb '04) SVG didn't work in conjunction with XUL templates, because SVG didn't allow attributes to assume arbitrary values. XUL templates, however, require that <action>s contain elements such as <svg:polygon points="?points"/>, where "?points" is actually disallowed as a value for the SVG points attribute (it requires a list of points). Previously, the points attribute as given above would just have been ignored and the default value ("") retained.

SVG behaviour has now been changed so that attributes can assume arbitrary values (either from source or via script with setAttribute).

This leads to some subtle issues with the SVG DOM which maps some members onto attributes:

  • If a syntactically incorrect value is supplied for an attribute, subsequent invocations of getAttribute() will return that value, but it won't (can't) be mapped onto the corresponding DOM member, which will retain its previous value. Example: Setting circle.setAttribute("r", "foo") will not affect circle.r.baseVal.value or circle.r.baseVal.valueAsString, but circle.getAttribute("r") will now return "foo".
  • If a value is changed via the SVG DOM, the value gets mapped back onto the attribute regardless of the value of the attribute. Continuing the above example: After setting circle.r.baseVal.value=1, invocations of circle.getAttribute("r") will now return 1.
  • The SVG DOM can't be used to set an attribute to an invalid value. Example: circle.r.baseVal.valueAsString="foo" will neither set the value of circle.r nor the corresponding attribute "r".

File(s):

xulsvg1.xul [Open |  View as text]
xulsvg1.rdf [Open |  View as text]