Fairly ugly; lots of manual input, little or no prompting for what might be valid and what's not
Travelocity: Prettier
Form entry has gotten really fancy, but it's still form entry
Gmail: AJAX! Lots of text being passed around, high information density.
User not aware of "pages"; it feels like an "app"
flickr: Soemone's starting to do things with graphics.
Very simple; just imgs. Any "complex" stuff (the simple animation viewer) get shoved into Flash.
The tools for doing gfx on the web has been pretty scarce.
From almost nothing...
Mozilla's performance graphs.
Server-generated image; requires round-trip if any parameters are changed.
Even if the client should in theory already have the data!
Requires CGI scripting on the server.
From almost nothing...
Walter Zorn's JavaScript graphics library.
Simple vector graphics using straight HTML elements.
Uses divs. Uses LOTS of divs. But can create graphics.
From almost nothing...
Flash
VML
IE only
Flash
Last resort, but you get to last resort point quickly
Ubiquitous; easiest way to accomplish all sorts of stuff
It doesn't really play nice with the web; there are scripting bridges
VML
Microsoft's VML. IE only, 2D markup language. Precursor to SVG; what VRML is to X3D.
... to lots of options
SVG
<canvas>
Both SVG and Canvas started gaining traction last year
Mozilla shipped implementations with Firefox 1.5
Early adopters are experimenting with both
Quick comparison first, then look at SVG and canvas more closely
Which one do I use?
SVG
canvas
Has scene DOM (SVG DOM, though)
Single HTML element, rendering script-driven
Deals in shapes
Deals in pixels
Somewhat hard to mix with HTML (not XHTML)
Behaves like an image in both
Event handling easy
Event handling hard
Big bifference: DOM
SVG has one, canvas doesn't
Retained mode vs. Immediate mode (scaling, scrolling, etc.)
All canvas rendering is script-driven
Shapes vs. Pixels
SVG is retained mode, canvas is immediate mode
canvas has no knowledge of what's drawn; they're just pixels; SVG retains the full scene layout information
An SVG document can be scaled/rotated etc. without any loss of resolution; a canvas requires a redraw, or it's just an image transform.
Integration with HTML
Canvas is really just a fancy type of img element, whose contents are dynamic
SVG can integrate well with XHTML, but it's hard to add it to straight HTML -- you end up having to use an object tag, or to create a namespaced SVG element dynamically
(Not so bad: if you have pre-made svg content, an object tag is ok, and if you don't, you're going to generate stuff anyway)
Event handling
Because of its DOM presence, you can attach DOM/XML event handlers directly to shape elements
Easy to do mouseovers, handle clicks in complex shapes, etc.
Hard with canvas; as it has no knowledge of actual shapes, everything's just pixels. Have to track the mouse and do your own hit tests (but this can be made easier through using imagemap-like things)
SVG
W3C Standard
Expressive DOM
Lots of existing documentation
http://developer.mozilla.org/en/docs/SVG
http://en.wikipedia.org/wiki/SVG
http://svg.startpagina.nl/
http://www.adobe.com/svg/
W3C Standard; 1.1 now, 1.2 is in progress
Expressive DOM
Lots of existing documentation; won't spend too much time on SVG
drawWindow, Mozilla extension currently not available to content
working on getting it standardized
draws page contents to a canvas, with transforms
used by many firefox extensions for page preview
toDataURL for saving thumbnails
<canvas> Limitations
No direct text rendering support
Can use positioned divs
Font textures (OpenGL-style)
drawWindow
Spec being worked on: textStyle, drawText, measureText
No DOM presence
Must redraw scene to make a change
But can draw quickly, without DOM manipulation
Can optimize by using multiple buffers
+
=
Text rendering
divs
font textures
drawWindow allows for drawing a DOM window to a canvas, with transforms (can draw CSS laid-out text); privileged content only for now, spec in progress
Spec in progress for simple text rendering direct to canvas
Scene redrawing
Need to redraw whatever part changes
Can draw infrequently changing pieces into offscreen canvas, composite together
SVG vs. <canvas> Code
SVG
var rect = document.createElementNS(SVG_NS, "rect");
rect.setAttribute("x", "5");
rect.setAttribute("y", "5");
rect.setAttribute("width", "20");
rect.setAttribute("height", "20");
rect.setAttribute("fill", "red");
parent.appendChild(rect);