mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Use consistent boundary policy when dealing with curve-time.
This commit is contained in:
parent
e3c6245979
commit
4f9d23da81
4 changed files with 11 additions and 11 deletions
|
@ -890,7 +890,7 @@ statics: /** @lends Curve */{
|
||||||
var t = roots[i],
|
var t = roots[i],
|
||||||
u = 1 - t;
|
u = 1 - t;
|
||||||
// Test for good roots and only add to bounds if good.
|
// Test for good roots and only add to bounds if good.
|
||||||
if (tMin < t && t < tMax)
|
if (tMin <= t && t <= tMax)
|
||||||
// Calculate bezier polynomial at t.
|
// Calculate bezier polynomial at t.
|
||||||
add(u * u * u * v0
|
add(u * u * u * v0
|
||||||
+ 3 * u * u * t * v1
|
+ 3 * u * u * t * v1
|
||||||
|
@ -1725,7 +1725,7 @@ new function() { // Scope for bezier intersection using fat-line clipping
|
||||||
t1 = Curve.getTimeOf(v1, p1);
|
t1 = Curve.getTimeOf(v1, p1);
|
||||||
// Check t1 and t2 against correct bounds, based on excludeStart/End:
|
// Check t1 and t2 against correct bounds, based on excludeStart/End:
|
||||||
// - excludeStart means the start of c1 connects to the end of c2
|
// - excludeStart means the start of c1 connects to the end of c2
|
||||||
// - endConneted means the end of c1 connects to the start of c2
|
// - excludeEnd means the end of c1 connects to the start of c2
|
||||||
// - If either c1 or c2 are at the end of the path, exclude their end,
|
// - If either c1 or c2 are at the end of the path, exclude their end,
|
||||||
// which connects back to the beginning, but only if it's not part of
|
// which connects back to the beginning, but only if it's not part of
|
||||||
// a found overlap. The normal intersection will already be found at
|
// a found overlap. The normal intersection will already be found at
|
||||||
|
|
|
@ -41,7 +41,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
initialize: function CurveLocation(curve, time, point, _overlap, _distance) {
|
initialize: function CurveLocation(curve, time, point, _overlap, _distance) {
|
||||||
// Merge intersections very close to the end of a curve with the
|
// Merge intersections very close to the end of a curve with the
|
||||||
// beginning of the next curve.
|
// beginning of the next curve.
|
||||||
if (time > /*#=*/(1 - Numerical.CURVETIME_EPSILON)) {
|
if (time >= /*#=*/(1 - Numerical.CURVETIME_EPSILON)) {
|
||||||
var next = curve.getNext();
|
var next = curve.getNext();
|
||||||
if (next) {
|
if (next) {
|
||||||
time = 0;
|
time = 0;
|
||||||
|
@ -402,8 +402,8 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
tMin = /*#=*/Numerical.CURVETIME_EPSILON,
|
tMin = /*#=*/Numerical.CURVETIME_EPSILON,
|
||||||
tMax = 1 - tMin,
|
tMax = 1 - tMin,
|
||||||
// t*Inside specifies if the found intersection is inside the curve.
|
// t*Inside specifies if the found intersection is inside the curve.
|
||||||
t1Inside = t1 > tMin && t1 < tMax,
|
t1Inside = t1 >= tMin && t1 <= tMax,
|
||||||
t2Inside = t2 > tMin && t2 < tMax;
|
t2Inside = t2 >= tMin && t2 <= tMax;
|
||||||
// If the intersection is in the middle of both paths, it is either a
|
// If the intersection is in the middle of both paths, it is either a
|
||||||
// tangent or a crossing, no need for the detailed corner check below:
|
// tangent or a crossing, no need for the detailed corner check below:
|
||||||
if (t1Inside && t2Inside)
|
if (t1Inside && t2Inside)
|
||||||
|
@ -416,13 +416,13 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{
|
||||||
// both values point to the same curve, and the curve-time is to be
|
// both values point to the same curve, and the curve-time is to be
|
||||||
// handled accordingly further down.
|
// handled accordingly further down.
|
||||||
var c2 = this.getCurve(),
|
var c2 = this.getCurve(),
|
||||||
c1 = t1 <= tMin ? c2.getPrevious() : c2,
|
c1 = t1 < tMin ? c2.getPrevious() : c2,
|
||||||
c4 = inter.getCurve(),
|
c4 = inter.getCurve(),
|
||||||
c3 = t2 <= tMin ? c4.getPrevious() : c4;
|
c3 = t2 < tMin ? c4.getPrevious() : c4;
|
||||||
// If t1 / t2 are at the end, then step to the next curve.
|
// If t1 / t2 are at the end, then step to the next curve.
|
||||||
if (t1 >= tMax)
|
if (t1 > tMax)
|
||||||
c2 = c2.getNext();
|
c2 = c2.getNext();
|
||||||
if (t2 >= tMax)
|
if (t2 > tMax)
|
||||||
c4 = c4.getNext();
|
c4 = c4.getNext();
|
||||||
if (!c1 || !c2 || !c3 || !c4)
|
if (!c1 || !c2 || !c3 || !c4)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1043,7 +1043,7 @@ var Path = PathItem.extend(/** @lends Path# */{
|
||||||
time = loc && loc.time,
|
time = loc && loc.time,
|
||||||
tMin = /*#=*/Numerical.CURVETIME_EPSILON,
|
tMin = /*#=*/Numerical.CURVETIME_EPSILON,
|
||||||
tMax = 1 - tMin;
|
tMax = 1 - tMin;
|
||||||
if (time >= tMax) {
|
if (time > tMax) {
|
||||||
// time == 1 is the same location as time == 0 and index++
|
// time == 1 is the same location as time == 0 and index++
|
||||||
index++;
|
index++;
|
||||||
time = 0;
|
time = 0;
|
||||||
|
|
|
@ -371,7 +371,7 @@ PathItem.inject(new function() {
|
||||||
// renormalization within the curve.
|
// renormalization within the curve.
|
||||||
renormalizeLocs = [];
|
renormalizeLocs = [];
|
||||||
prevTime = null;
|
prevTime = null;
|
||||||
} else if (prevTime > tMin) {
|
} else if (prevTime >= tMin) {
|
||||||
// Rescale curve-time when we are splitting the same curve
|
// Rescale curve-time when we are splitting the same curve
|
||||||
// multiple times, if splitting was done previously.
|
// multiple times, if splitting was done previously.
|
||||||
loc._time /= prevTime;
|
loc._time /= prevTime;
|
||||||
|
|
Loading…
Reference in a new issue