shapes in a 2d plane A W3C spec started in 2001 Provides “image-free” pictures to use in web pages - thus making the web more device independent Monday, January 2, 2012
to style an SVG Note the style attributes are different than “normal” css <svg> <rect x=0 y=0 width=50 height=50 /> </svg> rect { fill: red; } Monday, January 2, 2012
It is highly recommended to start painting from the origin Use translations to move your shapes on the canvas <svg> <g transform="translate (50,50)"> <rect x=0 y=0 width=50 height=50 /> </g> </svg> rect { fill: red; } g rect { fill: purple; } Monday, January 2, 2012
stroke paths A list of comma/space separated lengths of the dashes used to stroke the shape Remember this won’t do anything if stroke is not set Demo Monday, January 2, 2012
hex or color name Standard colors: blue, green, magenta, orange, pink, red, yellow, lightgray, darkgray, gray, black, white Can use colors for fill and stroke Monday, January 2, 2012
It has support for line or radial gradients Can use inkscape to build your gradients, or code them by hand Each gradient has start color, color stops and end color. A gradient is defined before use in the def section Monday, January 2, 2012
“how” to draw each point Imagine moving a pencil on the canvas M means “move to” point means “line to” <svg> <path d="M0,0 150,0 150,50 0,50" /> </svg> Monday, January 2, 2012
element to draw an arc A for absolute, a for relative An arc takes: (rx ry x-rot, large,sweep, x,y) x,y is the destination point large: 0 for minor, 1 for major sweep: 0 for counterclockwise, 1 for clockwise Monday, January 2, 2012
use fill to select a color use fonts as normal Line breaks are removed <svg> <g transform="translate (0, 100)"> <text fill=blue font- size="1.5em"> Hello SVG </text> </g> </svg> Monday, January 2, 2012
the viewBox attribute of svg Everything within the viewBox will be displayed If the viewBox is larger than the canvas, the image will be scaled to fit the canvas Demo Monday, January 2, 2012
ends (not just for colors): If fill=”freeze” state is left as in the last frame if fill=”remove” state is left as before the animation Demo: http://jsfiddle.net/ynonp/dWJ3n/ Monday, January 2, 2012
to take strings, type=”rotate” In rotation, the string is a triplet of numbers separated by spaces which mean: <degrees> <x> <y> Demo: http://jsfiddle.net/ah3vr/ Monday, January 2, 2012
to rotate around. Sometimes we want another point on the canvas to perform as the center The solution: Use translate transformation Demo: svg/animations1/animated_text.html Monday, January 2, 2012
manipulate and create it from JavaScript Use: document.createElementNS to create the element Caution: Don’t use jQuery to manipulate SVG Important to use namespace: http://www.w3.org/2000/svg Monday, January 2, 2012