Convert from 4 spaces to tabs

Oops. Paper.js uses tabs…
This commit is contained in:
Justin Ridgewell 2012-09-15 23:58:39 -04:00
parent bbef9a9594
commit 7879b4b61b

View file

@ -6,140 +6,140 @@
var ImportSVG = this.ImportSVG = Base.extend({ var ImportSVG = this.ImportSVG = Base.extend({
{ {
//initialize //initialize
initialize: function() initialize: function()
{ {
}, },
/** /**
* *
* Takes the svg dom obj and parses the data * Takes the svg dom obj and parses the data
* to create a layer with groups (if needed) with * to create a layer with groups (if needed) with
* items inside. Should support nested groups. * items inside. Should support nested groups.
* *
* takes in a svg object (xml dom) * takes in a svg object (xml dom)
* returns Paper.js Layer * returns Paper.js Layer
*/ */
importSVG: function(svg) importSVG: function(svg)
{ {
//TODO: return layer; //TODO: return layer;
}, },
/** /**
* Creates a Paper.js Group by parsing * Creates a Paper.js Group by parsing
* a specific svg g node * a specific svg g node
* *
* takes in a svg object (xml dom) * takes in a svg object (xml dom)
* returns Paper.js Group * returns Paper.js Group
*/ */
importGroup: function(svg) importGroup: function(svg)
{ {
//TODO: return group; //TODO: return group;
}, },
/** /**
* Creates a Paper.js Path by parsing * Creates a Paper.js Path by parsing
* a specific svg node (rect, path, circle, polygon, etc) * a specific svg node (rect, path, circle, polygon, etc)
* and creating the right path object based on the svg type. * and creating the right path object based on the svg type.
* *
* takes in a svg object (xml dom) * takes in a svg object (xml dom)
* returns Paper.js Group * returns Paper.js Group
*/ */
importPath: function(svg) importPath: function(svg)
{ {
//TODO: return path; //TODO: return path;
}, },
/** /**
* Creates a Path.Circle Paper.js item * Creates a Path.Circle Paper.js item
* *
* takes a svg circle node (xml dom) * takes a svg circle node (xml dom)
* returns Paper.js Path.Circle item * returns Paper.js Path.Circle item
*/ */
createCircle: function(svgCircle) createCircle: function(svgCircle)
{ {
var cx = svgCircle.cx.baseVal.value || 0; var cx = svgCircle.cx.baseVal.value || 0;
var cy = svgCircle.cy.baseVal.value || 0; var cy = svgCircle.cy.baseVal.value || 0;
var r = svgCircle.r.baseVal.value || 0; var r = svgCircle.r.baseVal.value || 0;
var center = new Point(cx, cy); var center = new Point(cx, cy);
var circle = new Path.Circle(center, r); var circle = new Path.Circle(center, r);
return circle; return circle;
}, },
/** /**
* Creates a Path.Oval Paper.js item * Creates a Path.Oval Paper.js item
* *
* takes a svg ellipse node (xml dom) * takes a svg ellipse node (xml dom)
* returns Paper.js Path.Oval item * returns Paper.js Path.Oval item
*/ */
createOval: function(svgOval) createOval: function(svgOval)
{ {
var cx = svgOval.cx.baseVal.value || 0; var cx = svgOval.cx.baseVal.value || 0;
var cy = svgOval.cy.baseVal.value || 0; var cy = svgOval.cy.baseVal.value || 0;
var rx = svgOval.rx.baseVal.value || 0; var rx = svgOval.rx.baseVal.value || 0;
var ry = svgOval.ry.baseVal.value || 0; var ry = svgOval.ry.baseVal.value || 0;
var center = new Point(cx, cy); var center = new Point(cx, cy);
var offset = new Point(rx, ry); var offset = new Point(rx, ry);
var topLeft = center.subtract(offset); var topLeft = center.subtract(offset);
var bottomRight = center.add(offset); var bottomRight = center.add(offset);
var rect = new Rectangle(topLeft, bottomRight); var rect = new Rectangle(topLeft, bottomRight);
var oval = new Path.Oval(rect); var oval = new Path.Oval(rect);
return oval; return oval;
}, },
/** /**
* Creates a "rectangle" Paper.js item * Creates a "rectangle" Paper.js item
* *
* takes a svg rect node (xml dom) * takes a svg rect node (xml dom)
* returns either a * returns either a
* - Path.Rectangle item * - Path.Rectangle item
* - Path.RoundRectangle item (if the rectangle has rounded corners) * - Path.RoundRectangle item (if the rectangle has rounded corners)
*/ */
createRectangle: function(svgRectangle) createRectangle: function(svgRectangle)
{ {
var x = svgRectangle.x.baseVal.value || 0; var x = svgRectangle.x.baseVal.value || 0;
var y = svgRectangle.y.baseVal.value || 0; var y = svgRectangle.y.baseVal.value || 0;
var rx = svgRectangle.rx.baseVal.value || 0; var rx = svgRectangle.rx.baseVal.value || 0;
var ry = svgRectangle.ry.baseVal.value || 0; var ry = svgRectangle.ry.baseVal.value || 0;
var width = svgRectangle.width.baseVal.value || 0; var width = svgRectangle.width.baseVal.value || 0;
var height = svgRectangle.height.baseVal.value || 0; var height = svgRectangle.height.baseVal.value || 0;
var topLeft = new Point(x, y); var topLeft = new Point(x, y);
var size = new Size(width, height); var size = new Size(width, height);
var rectangle = new Rectangle(topLeft, size); var rectangle = new Rectangle(topLeft, size);
if (rx > 0 || ry > 0) { if (rx > 0 || ry > 0) {
var cornerSize = new Size(rx, ry); var cornerSize = new Size(rx, ry);
rectangle = new Path.RoundRectangle(rectangle, cornerSize); rectangle = new Path.RoundRectangle(rectangle, cornerSize);
} else { } else {
rectangle = new Path.Rectangle(rectangle); rectangle = new Path.Rectangle(rectangle);
} }
return rectangle; return rectangle;
}, },
/** /**
* Creates a Path.Line Paper.js item * Creates a Path.Line Paper.js item
* *
* takes a svg line node (xml dom) * takes a svg line node (xml dom)
* returns a Path.Line item * returns a Path.Line item
*/ */
createLine: function(svgLine) createLine: function(svgLine)
{ {
var x1 = svgLine.x1.baseVal.value || 0; var x1 = svgLine.x1.baseVal.value || 0;
var y1 = svgLine.y1.baseVal.value || 0; var y1 = svgLine.y1.baseVal.value || 0;
var x2 = svgLine.x2.baseVal.value || 0; var x2 = svgLine.x2.baseVal.value || 0;
var y2 = svgLine.y2.baseVal.value || 0; var y2 = svgLine.y2.baseVal.value || 0;
var from = new Point(x1, y1); var from = new Point(x1, y1);
var to = new Point(x2, y2); var to = new Point(x2, y2);
var line = new Path.Line(from, to); var line = new Path.Line(from, to);
return line; return line;
} }
}); });