mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Optimise loops.
This commit is contained in:
parent
16de863aa5
commit
e26197cf1f
2 changed files with 4 additions and 5 deletions
|
@ -106,7 +106,7 @@ var SvgExporter = this.SvgExporter = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
parts.push('M' + formatPoint(segments[0]._point));
|
parts.push('M' + formatPoint(segments[0]._point));
|
||||||
for (i = 0; i < segments.length - 1; i++)
|
for (i = 0, l = segments.length - 1; i < l; i++)
|
||||||
addCurve(segments[i], segments[i + 1], false);
|
addCurve(segments[i], segments[i + 1], false);
|
||||||
// We only need to draw the connecting curve if it is not a line, and if
|
// We only need to draw the connecting curve if it is not a line, and if
|
||||||
// the path is cosed and has a stroke color, or if it is filled.
|
// the path is cosed and has a stroke color, or if it is filled.
|
||||||
|
@ -238,7 +238,7 @@ var SvgExporter = this.SvgExporter = new function() {
|
||||||
case 'polyline':
|
case 'polyline':
|
||||||
case 'polygon':
|
case 'polygon':
|
||||||
var parts = [];
|
var parts = [];
|
||||||
for(i = 0; i < segments.length; i++)
|
for(i = 0, l = segments.length; i < l; i++)
|
||||||
parts.push(formatPoint(segments[i]._point));
|
parts.push(formatPoint(segments[i]._point));
|
||||||
attrs = {
|
attrs = {
|
||||||
points: parts.join(' ')
|
points: parts.join(' ')
|
||||||
|
|
|
@ -68,9 +68,8 @@ var SvgImporter = this.SvgImporter = new function() {
|
||||||
|
|
||||||
function importPoly(svg, type) {
|
function importPoly(svg, type) {
|
||||||
var path = new Path(),
|
var path = new Path(),
|
||||||
points = svg.points,
|
points = svg.points;
|
||||||
start = points.getItem(0);
|
path.moveTo(points.getItem(0));
|
||||||
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 (type === 'polygon')
|
if (type === 'polygon')
|
||||||
|
|
Loading…
Reference in a new issue