Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Dynamic SVG features for browsers

Build on SVG basics to create attractive, dynamic effects in your Web projects

Uche Ogbuji (uche@ogbuji.net), Principal Consultant, Fourthought Inc.
Photo of Uche Ogbuji
Uche Ogbuji is a consultant and cofounder of Fourthought Inc., a software vendor and consultancy specializing in XML solutions for enterprise knowledge management. Fourthought develops 4Suite, an open source platform for XML, RDF, and knowledge-management applications. Mr. Ogbuji is also a lead developer of the Versa RDF query language. He is a computer engineer and writer born in Nigeria, living and working in Boulder, CO. You can find more about Mr. Ogbuji at his Weblog Copia, or contact him at uche@ogbuji.net.

Summary:  Learn how to use dynamic features of Scalable Vector Graphics (SVG) to provide useful and attractive effects in your Web applications. SVG 1.1, an XML language for describing two-dimensional vector graphics, provides a practical and flexible graphics format in XML. Many SVG features provide for dynamic effects, including features for integration into a Web browser. Build on basic SVG techniques introduced in a previous tutorial.

Date:  15 Aug 2006
Level:  Intermediate PDF:  A4 and Letter (278 KB | 34 pages)Get Adobe® Reader®

Activity:  12844 views
Comments:  

Before you start

About this tutorial

SVG is a technology positioned for many uses in the Web space. You can use it to present simple graphics (as with JPEG) or complex applications (as with Macromedia Flash). An earlier tutorial from June 2006 introduced the basic features of the format (see Resources). This tutorial continues to focus on SVG for Web development, as it demonstrates dynamic effects that open up new means of enhancing Web pages. The lessons are built around examples that you can view and experiment with in your favorite browser.

Developed by the W3C, SVG has the remarkable ambition of providing a practical and flexible graphics format in XML, despite the notorious verbosity of XML. It can be developed, processed, and deployed in many different environments -- from mobile systems such as phones and PDAs to print environments. SVG's feature set includes nested transformations, clipping paths, alpha masks, raster filter effects, template objects, and, of course, extensibility. SVG also supports animation, zooming and panning views, a wide variety of graphic primitives, grouping, scripting, hyperlinks, structured metadata, CSS, a specialized DOM superset, and easy embedding in other XML documents. Many of these features allow for dynamic effects in images. Overall, SVG is one of the most widely and warmly embraced XML applications.

Dynamic SVG is a hot topic, and several tutorials and articles are available that include fairly complicated examples of dynamic SVG techniques. This tutorial is different because it focuses on a breadth of very simple examples. You will be able to put together the many techniques you learn in this tutorial to create effects of whatever sophistication you like, but each example in this tutorial is simple, clear, and reasonably self-contained. The tutorial rarely deals with any SVG objects more complex than the circle shape, and it keeps embellishments in scripting and XML to a minimum. The combination of simple, step-by-step development and a focus on real-world browser environment makes this tutorial unique.


Who should use this tutorial?

SVG is an important weapon in every Web developer's and designer's arsenal. Programmers should use this tutorial if they deal with any Web applications. Web designers should use this tutorial to learn how to deploy efficient vector graphics on the Web.


Objectives

In this tutorial you learn about scripting, CSS, and basic animation features of SVG to use dynamic effects with vector graphics on the Web. You gain a variety of basic techniques that you can use to put together attractive and sophisticated Web environments using SVG.


Prerequisites

This tutorial assumes knowledge of XML, XML namespaces, CSS, XHTML, basic SVG and basic ECMAScript (which you may be familiar with under the name, JavaScript), and Document Object Model (DOM). The links in Resources direct you to helpful information if you aren't familiar with SVG basics, including prerequisites such as XML, XML namespaces, and CSS, or if you need to learn about ECMAScript and DOM.


System requirements

The examples in this tutorial require only a Web browser that supports SVG, with ECMAScript enabled. Firefox 1.5, or more recent, has such support built in, as does Opera 9. Safari has announced support for SVG in coming versions, but for now the support is only available in nightly development snapshots with no guaranteed stability. Mac OS X users might want to try the Camino Web browser for SVG support. Internet Explorer users require a plug-in such as the Adobe SVG Viewer. Firefox 1.5.0.4 on Ubuntu Linux is the browser that appears in browser output screenshots in this tutorial. Firefox is a popular Web browser available on Windows, Mac OS X, Linux, and other platforms. It is based on Mozilla's rendering engine.


About the examples in this tutorial

In this tutorial, you will find many examples of SVG files, either stand-alone or embedded in XHTML. All the files used in this tutorial are in a zip file called tutorial-files.zip (see Downloads). In this package, all files start with a prefix that indicates the section that covers them and the order of examples within the section. For example, the names of files from the first example in the third section start with "eg_3_1".

Files that end with .svg are stand-alone SVG. Those ending with .xhtml are XHTML. A few files use other extensions such as .css for stand-alone CSS and .xsl for XSLT transform files.

I further list the example files in each panel and explain how each relates to the other. If you follow along with the tutorial, you should be able to locate and experiment with the examples.

1 of 8 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Web development
ArticleID=152613
TutorialTitle=Dynamic SVG features for browsers
publish-date=08152006
author1-email=uche@ogbuji.net
author1-email-cc=dwxed@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.