From 1ccd5199b5d7c00f5dec7bdf3a753edeff5fb805 Mon Sep 17 00:00:00 2001 From: Jt Whissel Date: Thu, 13 Sep 2012 20:45:27 -0400 Subject: [PATCH] Added the new classes to work with, that also have the method stubs inside. --- src/paper.js | 3 ++ src/svg/ExportSVG.js | 90 ++++++++++++++++++++++++++++++++++++++++++++ src/svg/ImportSVG.js | 55 +++++++++++++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 src/svg/ExportSVG.js create mode 100644 src/svg/ImportSVG.js diff --git a/src/paper.js b/src/paper.js index 3052ee61..757274f8 100644 --- a/src/paper.js +++ b/src/paper.js @@ -93,6 +93,9 @@ var paper = new function() { /*#*/ include('text/TextItem.js'); /*#*/ include('text/PointText.js'); +/*#*/ include('svg/ExportSVG.js'); +/*#*/ include('svg/ImportSVG.js'); + /*#*/ include('style/Style.js'); /*#*/ include('style/PathStyle.js'); /*#*/ include('style/ParagraphStyle.js'); diff --git a/src/svg/ExportSVG.js b/src/svg/ExportSVG.js new file mode 100644 index 00000000..79d88b78 --- /dev/null +++ b/src/svg/ExportSVG.js @@ -0,0 +1,90 @@ +/** + * Exports items, layers or whole projects as a svg + * Stetson Alpha - Paper.js + * + * var NS="http://www.w3.org/2000/svg"; + * var svg=document.createElementNS(NS,"svg"); + */ + + +var ExportSVG = function() +{ + var svgObj = null; // xml dom object (svg typed) + + //initialize the svgObj and what ever else. + function initialize() + { + + }; + + /** + * + * Takes the whole project and parses + * all the layers to be put into svg groups and + * groups into svg groups making all the projects + * items into one svg. + * + * takes in a Paper.js Project + * returns svg object (xml dom) + */ + this.exportProject = function(project) + { + return svgObj; + }; + + + /** + * + * Takes the layer and then parses all groups + * and items into one svg + * + * takes in a Paper.js Layer + * returns svg object (xml dom) + */ + this.exportLayer = function(layer) + { + return svgObj; + }; + + + /** + * + * Takes the group and puts it's items + * in a svg file. + * + * takes in a Paper.js Group + * returns svg object (xml dom) + */ + this.exportGroup = function(group) + { + return svgObj; + }; + + /** + * + * Takes the item and puts it in + * a svg file. + * + * takes in a Paper.js Item + * returns svg object (xml dom) + */ + this.exportItem = function(item) + { + return svgObj; + }; + + /** + * + * Takes the path and puts it in + * a svg file. + * + * takes in a Paper.js Path + * returns svg object (xml dom) + */ + this.exportPath = function(path) + { + return svgObj; + }; + + initialize(); // calls the init function after class is loaded +}; \ No newline at end of file diff --git a/src/svg/ImportSVG.js b/src/svg/ImportSVG.js new file mode 100644 index 00000000..08f6f557 --- /dev/null +++ b/src/svg/ImportSVG.js @@ -0,0 +1,55 @@ +/** + * Imports svg into items with groups + * Stetson Alpha - Paper.js + * + */ + +var ImportSVG = function() +{ + //initialize + function initialize() + { + + }; + + /** + * + * Takes the svg dom obj and parses the data + * to create a layer with groups (if needed) with + * items inside. Should support nested groups. + * + * takes in a svg object (xml dom) + * returns Paper.js Layer + */ + this.importSVG = function(svg) + { + return layer; + }; + + /** + * Creates a Paper.js Group by parsing + * a specific svg g node + * + * takes in a svg object (xml dom) + * returns Paper.js Group + */ + function importGroup(svg) + { + return group; + }; + + /** + * Creates a Paper.js Path by parsing + * a specific svg node (rect, path, circle, polygon, etc) + * and creating the right path object based on the svg type. + * + * takes in a svg object (xml dom) + * returns Paper.js Group + */ + function importPath(svg) + { + return path; + }; + + initialize(); // calls the init function after class is loaded +}; \ No newline at end of file