mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Allow better code compression by reducing property lookup.
This commit is contained in:
parent
72a27d9732
commit
af84bb9988
1 changed files with 7 additions and 7 deletions
|
@ -120,18 +120,17 @@ PathItem.inject({
|
||||||
segment;
|
segment;
|
||||||
ixs.sort(sortIx);
|
ixs.sort(sortIx);
|
||||||
for (var i = 0, l = ixs.length; i < l; i++) {
|
for (var i = 0, l = ixs.length; i < l; i++) {
|
||||||
var ix = ixs[i];
|
var ix = ixs[i],
|
||||||
|
t = ix.parameter;
|
||||||
if (!vals)
|
if (!vals)
|
||||||
vals = crv.getValues();
|
vals = crv.getValues();
|
||||||
if (ix.parameter === 0 || ix.parameter === 1) {
|
if (t === 0 || t === 1) {
|
||||||
// Intersection is on an existing node: No need to
|
// Intersection is on an existing node: No need to
|
||||||
// create a new segment, we just link the
|
// create a new segment, we just link the
|
||||||
// corresponding intersections together
|
// corresponding intersections together
|
||||||
segment = ix.parameter === 0
|
segment = t === 0 ? crv.segment1 : crv.segment2;
|
||||||
? crv.segment1
|
|
||||||
: crv.segment2;
|
|
||||||
} else {
|
} else {
|
||||||
var parts = Curve.subdivide(vals, ix.parameter),
|
var parts = Curve.subdivide(vals, t),
|
||||||
left = parts[0],
|
left = parts[0],
|
||||||
right = parts[1],
|
right = parts[1],
|
||||||
segment = new Segment(
|
segment = new Segment(
|
||||||
|
@ -156,8 +155,9 @@ PathItem.inject({
|
||||||
}
|
}
|
||||||
segment._ixPair = ix.pair;
|
segment._ixPair = ix.pair;
|
||||||
segment._ixPair._segment = segment;
|
segment._ixPair._segment = segment;
|
||||||
|
// Readjust parameters after splitting
|
||||||
for (var j = i + 1; j < l; j++)
|
for (var j = i + 1; j < l; j++)
|
||||||
ixs[j].parameter = ixs[j].parameter / ix.parameter;
|
ixs[j].parameter /= t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue