mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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));
|
||||
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);
|
||||
// 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.
|
||||
|
@ -238,7 +238,7 @@ var SvgExporter = this.SvgExporter = new function() {
|
|||
case 'polyline':
|
||||
case 'polygon':
|
||||
var parts = [];
|
||||
for(i = 0; i < segments.length; i++)
|
||||
for(i = 0, l = segments.length; i < l; i++)
|
||||
parts.push(formatPoint(segments[i]._point));
|
||||
attrs = {
|
||||
points: parts.join(' ')
|
||||
|
|
|
@ -68,9 +68,8 @@ var SvgImporter = this.SvgImporter = new function() {
|
|||
|
||||
function importPoly(svg, type) {
|
||||
var path = new Path(),
|
||||
points = svg.points,
|
||||
start = points.getItem(0);
|
||||
path.moveTo(start);
|
||||
points = svg.points;
|
||||
path.moveTo(points.getItem(0));
|
||||
for (var i = 1, l = points.numberOfItems; i < l; i++)
|
||||
path.lineTo(points.getItem(i));
|
||||
if (type === 'polygon')
|
||||
|
|
Loading…
Reference in a new issue