Raphaël.JSON
Convert Raphaël 2.0 elements on a paper to JSON and back.
This plugin can be used to save the state of a paper for later re-use. It was originally forked from Jonathan Spies's raphael.serialize and later rewritten from scratch to work with Raphaël 2.0.
Licensed under the MIT license.
Example
Callback
A callback function can be used to save and restore custom attributes.
var json = paper;
paper;
Preserving sets
var paper = ; // Create a setvar exampleSet = paper; var rect = paper ; exampleSet; // Store a unique identifier in each of the set's elementsfor i in exampleSet exampleSetisetName = 'exampleSet'; // Serialize the papervar json = paper; // Start overpaperclear; exampleSet = null; // Restore the paper to the previous state using serialized datapaper; // The set is restoredconsole;
Raphaël.JSON and Raphaël.FreeTransform
Raphaël.JSON can be used together with Raphaël.FreeTransform to save and load drawings.
// Savevar json = paper; // Start overpaperclear; // Loadpaper;