Skip to content

Commit 05d251a

Browse files
committed
You cannot now overshoot the curve length in getUtoTmapping
1 parent cf4b97c commit 05d251a

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

v3/src/paths/curves/Curve.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var Curve = new Class({
1919

2020
function Curve ()
2121
{
22-
this.arcLengthDivisions = 200;
22+
this.arcLengthDivisions = 100;
2323

2424
this.cacheArcLengths = [];
2525

@@ -122,6 +122,12 @@ var Curve = new Class({
122122
this.getLengths();
123123
},
124124

125+
// Given a distance in pixels, get a t to find p.
126+
getTFromDistance: function (distance, divisions)
127+
{
128+
return this.getUtoTmapping(0, distance, divisions);
129+
},
130+
125131
// Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
126132

127133
getUtoTmapping: function (u, distance, divisions)
@@ -135,7 +141,8 @@ var Curve = new Class({
135141

136142
if (distance)
137143
{
138-
targetArcLength = distance;
144+
// Cannot overshoot the curve
145+
targetArcLength = Math.min(distance, arcLengths[il - 1]);
139146
}
140147
else
141148
{

0 commit comments

Comments
 (0)