mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Improve getWinding() reliability by clamping curve-time to tMin <= t <= tMax
This commit is contained in:
parent
31aa68b2d1
commit
1c7d19bba0
1 changed files with 4 additions and 2 deletions
|
@ -637,7 +637,9 @@ PathItem.inject(new function() {
|
|||
// the best quality.
|
||||
var offsets = [0.48, 0.1, 0.9],
|
||||
windingZero = { winding: 0, quality: 0 },
|
||||
winding = windingZero;
|
||||
winding = windingZero,
|
||||
tMin = /*#=*/Numerical.CURVETIME_EPSILON,
|
||||
tMax = 1 - tMin;
|
||||
for (var i = 0; i < offsets.length && winding.quality < 0.5; i++) {
|
||||
var length = totalLength * offsets[i];
|
||||
for (var j = 0, l = chain.length; j < l; j++) {
|
||||
|
@ -647,7 +649,7 @@ PathItem.inject(new function() {
|
|||
var curve = entry.curve,
|
||||
path = curve._path,
|
||||
parent = path._parent,
|
||||
t = curve.getTimeAt(length),
|
||||
t = Numerical.clamp(curve.getTimeAt(length), tMin, tMax),
|
||||
pt = curve.getPointAtTime(t),
|
||||
// Determine the direction in which to check the winding
|
||||
// from the point (horizontal or vertical), based on the
|
||||
|
|
Loading…
Reference in a new issue