CS474 M T: SVG - Animation Tutorial
CS474 M T: SVG - Animation Tutorial
MULTIMEDIA TECHNOLOGY
Pr. G. Tziritas, Spring 2018
Introduction – Definitions
SVG
Creating SVGs
SVG basics
Examples
Examples
References
INTRODUCTION - DEFINITIONS 1
Graphics
are visual images or designs on some surface (here:
webpage) to inform, illustrate, or entertain – a
pictorial representation of data.
Computer graphics
Two types:
raster graphics, where each pixel is separately
defined, and
vector graphics, where mathematical formulas
are used to draw lines and shapes, which are then
interpreted at the viewer's end to produce the
graphic.
INTRODUCTION - DEFINITIONS 2
Web graphics
Websites began to use the GIF format to display
small graphics (banners, advertisements,
navigation buttons) on web pages.
Modern web browsers can now also
display JPEG, PNG and SVG images.
Plugins expand the web browser functions to
display animated, interactive and 3-D graphics
contained within file formats such
as SWF and X3D.
INTRODUCTION - DEFINITIONS 3
Animation
A dynamic medium in which images or objects are
manipulated to appear as moving images.
Traditionally drawn/painted by hand.
Computer Generated Imagery (CGI): 2D/3D.
Other methods (paper cutouts, puppets, clay
figures): stop motion technique.
Commonly the effect of animation is achieved by a
rapid succession of sequential images that
minimally differ from each other.
INTRODUCTION – DEFINITIONS 4
XML (Extensible Markup Language)
a markup language that defines a set of rules for
encoding documents in a format that is both human-
and machine-readable. Emphasis: simplicity,
generality, and usability across the Internet. Focus
is on documents but the language is widely used for
the representation of arbitrary data structures such
as those used in web services.
VML (Vector Markup Language)
save as .svg
CREATING SVGS WITH CODE
You first need a text editor that you are
comfortable using Notepad++
Then you’ll need to know the syntax elements
& attributes (remember, it’s XML).
type
save as .svg
SVGS IN HTML WEBPAGE 1
Using the <img> tag
Simplest way to add SVG to a web page:
<img src=“drawing.svg" >
Advantages:
Very easy to do, markup that’s simple and often
used.
File can be cached for better performance.
Disadvantages:
Unable to manipulate the SVG with JavaScript
or CSS. For images like logos or icons that don’t
need manipulation, this option is a fine choice.
SVGS IN HTML WEBPAGE 2
Using the object element
Most flexible way to add SVG to a web page:
<object type="image/svg+xml“ data=“drawing.svg">
<img src=“drawing.png" />
</object>
Advantages:
Full access to the SVG internal elements you can
still manipulate the SVG with JavaScript and CSS
(must access via JavaScript!).
The object element is cacheable.
Disadvantages:
Implemented as-is, with a fallback image, the fallback
image will always be retrieved by the client even if it
is not needed!
SVGS IN HTML WEBPAGE 3
Plain old SVG XML
Right in the HTML document. One less asset for the
browser to retrieve from a remote location (everything
needed to render the image is right in the HTML):
<svg width="400" height="400">
<rect class="r1" x="0" y="0" width="400"
height="400" fill="#56A0D3" />
</svg>
Advantages:
Modify the SVG using CSS and JavaScript. Add a
class to a one of the elements and then style it
accordingly from your CSS.
Disadvantages:
Not cacheable. May seem like a small affair but for
high traffic sites this can be a big problem with scaling
and performance.
BASIC SVG ELEMENTS
svg
Main element inside of which shapes, paths, lines
etc. are nested.
Defines the viewport or canvas for SVG content.
Some attributes:
height, width : of the viewport
r : radius
BASIC SVG ELEMENTS
rect
Creates rectangles.
Attributes:
height, width : height & width of the shape
polygon
Create any shape with many sides (e.g. octagon)
using points (the only specific attribute for this
element).
BASIC SVG ELEMENTS
text
Set text in SVG.
Attributes:
textLength : exact value of the length of the
text (used for very specific layouts).
rotate : list of numbers that will determine the
rotation of the text.
x, y : (x,y) coordinate where the text begins
And many more which you can explore and try on W3C
and other sources.
Synfig Studio
SYNFIG STUDIO INTRODUCTION
Free & open source software for creating 2D
animations (Windows, Linux, Mac).
3 types of animation:
1. Cut-out
2. Morphing
3. Frame by frame
Useful tutorials to start with:
HTML5
HTML5 Tutorial
CSS Tutorial
SVG Tutorial
JavaScript Tutorial