Minor tweaks in SvgImporter code.

This commit is contained in:
Jürg Lehni 2012-11-05 18:27:13 -08:00
parent f6c7143920
commit 05bf52b6af

View file

@ -61,14 +61,14 @@ var SvgImporter = this.SvgImporter = new function() {
return group; return group;
} }
function importPoly(svg) { function importPoly(svg, type) {
var path = new Path(), var path = new Path(),
points = svg.points, points = svg.points,
start = points.getItem(0); start = points.getItem(0);
path.moveTo(start); path.moveTo(start);
for (var i = 1, l = points.numberOfItems; i < l; i++) for (var i = 1, l = points.numberOfItems; i < l; i++)
path.lineTo(points.getItem(i)); path.lineTo(points.getItem(i));
if (svg.nodeName.toLowerCase() == 'polygon') if (type === 'polygon')
path.closePath(); path.closePath();
return path; return path;
} }
@ -406,9 +406,10 @@ var SvgImporter = this.SvgImporter = new function() {
* @return {Item} the converted Paper.js item * @return {Item} the converted Paper.js item
*/ */
importSvg: function(svg) { importSvg: function(svg) {
var importer = importers[svg.nodeName.toLowerCase()]; var type = svg.nodeName.toLowerCase(),
importer = importers[type];
// TODO: importer == null: Not supported yet. // TODO: importer == null: Not supported yet.
var item = importer && importer(svg); var item = importer && importer(svg, type);
if (item) if (item)
applyAttributesAndStyles(svg, item); applyAttributesAndStyles(svg, item);
return item; return item;