Finish implementing Curve#isStraight and #isLinear()

Closes #652
This commit is contained in:
Jürg Lehni 2015-09-06 18:02:15 +02:00
parent 31d9e1cd6e
commit 98d7703b5c

View file

@ -821,6 +821,7 @@ statics: {
return h1.equals(third) && h2.negate().equals(third); return h1.equals(third) && h2.negate().equals(third);
} }
}, function(test, name) { }, function(test, name) {
// Produce the instance version that is called on curve object.
this[name] = function() { this[name] = function() {
var seg1 = this._segment1, var seg1 = this._segment1,
seg2 = this._segment2; seg2 = this._segment2;
@ -828,6 +829,7 @@ statics: {
seg1._handleOut, seg2._handleIn); seg1._handleOut, seg2._handleIn);
}; };
// Produce the static version that handles a curve values array.
this.statics[name] = function(v) { this.statics[name] = function(v) {
var p1x = v[0], p1y = v[1], var p1x = v[0], p1y = v[1],
p2x = v[6], p2y = v[7]; p2x = v[6], p2y = v[7];
@ -836,10 +838,10 @@ statics: {
new Point(v[4] - p2x, v[5] - p2y)); new Point(v[4] - p2x, v[5] - p2y));
}; };
}, /** @lends Curve# */{ }, /** @lends Curve# */{
statics: {}, // Filled in the loop above statics: {}, // Filled in the Base.each loop above.
/** /**
* {@grouptitle Tests} * {@grouptitle Curve Tests}
* *
* Checks if this curve has any curve handles set. * Checks if this curve has any curve handles set.
* *
@ -866,9 +868,9 @@ statics: {
*/ */
/** /**
* Checks if this curve is parametrically linear, meaning that its * Checks if this curve is parametrically linear, meaning that it is
* handles are positioned at 1/3 and 2/3 of the total length of the * straight and its handles are positioned at 1/3 and 2/3 of the total
* straight curve. * length of the curve.
* *
* @name Curve#isLinear * @name Curve#isLinear
* @function * @function