File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments