Skip to main content
Engineering LibreTexts

12.3: Scalable Vector Graphics Examples

  • Page ID
  • Section 2.7 discusses SVG, a scene description language for 2D vector graphics. Several examples were discussed in that section. These examples can be opened in a web browser to see the images they produce. View the source code for the web page to see the program that produces the image. You can also open the files in a text editor to read the source. Some of the examples produce animated images. Old browsers can’t show SVG images, but any browser that works with the rest of this textbook should be able to view them. (Note that Internet Explorer, at least through version 11, will not show SVG animation; it will show a static image instead.) These examples can be found in the svg folder inside the source folder.

    • first-svg-example.svg is a very short first example that just draws a few basic shapes.
    • svg-starter.svg shows the basic document structure for an SVG image, includes examples of most of the basic shapes, and has a lot of comments to explain what is going on.
    • svg-face.svg is a very simple first example of grouping.
    • svg-hierarchy.svg is an example of hierarchical modeling that makes a model of a wheel and a model of a cart that uses two wheels as components. The image shows a wheel and four copies of the cart. The wheel and cart models are also used in the cart-and-windmill animation at the end of this list.
    • first-svg-animation.svg contains examples of simple animation, keyframe animation, and transform animation.
    • hierarchical-animation.svg shows a simple animated hierarchical model.
    • cart-and-windmill.svg is a more complex example of hierarchical modeling in SVG. The scene is an animation that shows a “cart” moving down a road as windmills turn in the background. The animation is the same as the one implemented in the Java example java2d/ and in the JavaScript demo c2/cart-and-windmills.html.