Serializing RaphaelJS
J u n
1 2
2 0 1 0
I'm in love with Raphael JS (a javascript library for SVG graphics). For the things I need to do, this is far more exciting than just using canvas. And Dmitry Baranovskiy, the author of RaphaelJS has it working in IE by using VML.
I wanted to store my drawings and load them later as SVG instead of saving them as bitmaps. I started by monkey patching Raphael to keep an array of the objects I was interested in but it began to get hairy with paths and sets.
After reading an excellent post by Ben Barnett I changed my strategy to pull the nodes out of the Raphael object when I needed them.
The main trick is that (as of 1.4.3) Raphael stores a top and a bottom and, you guess it, a linked list of nodes.
Here's the gist.