mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Minor tweaks in SvgImporter code.
This commit is contained in:
parent
f6c7143920
commit
05bf52b6af
1 changed files with 5 additions and 4 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue