Add Curve#getPrevious / Next.

This commit is contained in:
Jürg Lehni 2011-03-06 13:26:09 +00:00
parent de9a406dc0
commit 407b6d8d33

View file

@ -37,19 +37,6 @@ var Curve = this.Curve = Base.extend({
}
},
getPath: function() {
return this._path;
},
getIndex: function() {
return this._index1;
},
_setIndex: function(index) {
this._index1 = index;
this._updateSegments();
},
/**
* The first anchor point of the curve.
*/
@ -112,6 +99,32 @@ var Curve = this.Curve = Base.extend({
return this._segment2;
},
getPath: function() {
return this._path;
},
getIndex: function() {
return this._index1;
},
_setIndex: function(index) {
this._index1 = index;
this._updateSegments();
},
getNext: function() {
var curves = this._path && this._path._curves;
// TODO: Add cyclic looping when closed back to Scriptographer
return curves && (curves[this._index1 + 1]
|| this._path.closed && curves[0]) || null;
},
getPrevious: function() {
var curves = this._path && this._path._curves;
return curves && (curves[this._index1 - 1]
|| this._path.closed && curves[curves.length - 1]) || null;
},
// Calculates arclength of a cubic using adaptive simpson integration.
getLength: function(goal) {
var z0 = this._segment1._point,