Rendering with SVG, Flash, Canvas, and DIVs
Lately, I’ve been playing around with a sort of generalized drawing API based on SVG’s path commands. The idea is that a high-level renderer parses SVG path data and invokes corresponding methods for each path command type. This SVG path data renderer then uses a lower level renderer to display the image client-side. I’ve managed to hook up four different renderers all plotting using the same drawing commands. You can see the first of this work here:
http://www.kevlindev.com/projects/jsdrawing/index.htm
Note that you will only be able to view all renderings with Firefox 1.5. However, that’s a good demonstration of the potential utility of a library like this. Each low-level renderer (referred to as a bridge in the code) includes a method to determine if that renderer type is supported in the current user agent. A developer could use this information to create a prioritized list of renderers and then walk through that list until they find the first highest-quality renderer available to them. Again, the drawing code won’t change; only the target renderer.