mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Implement #isFirst() / #isLast() tests on Segment and Curve.
This commit is contained in:
parent
db1ecdddd5
commit
20f950ac65
2 changed files with 44 additions and 3 deletions
|
@ -298,6 +298,26 @@ var Curve = Base.extend(/** @lends Curve# */{
|
|||
|| this._path._closed && curves[curves.length - 1]) || null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if the this is the first curve in the {@link Path#curves} array.
|
||||
*
|
||||
* @return {Boolean} {@true if this is the first curve}
|
||||
*/
|
||||
isFirst: function() {
|
||||
return this._segment1._index === 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if the this is the last curve in the {@link Path#curves} array.
|
||||
*
|
||||
* @return {Boolean} {@true if this is the last curve}
|
||||
*/
|
||||
isLast: function() {
|
||||
var path = this._path;
|
||||
return path && this._segment1._index === path._curves.length - 1
|
||||
|| false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Specifies whether the points and handles of the curve are selected.
|
||||
*
|
||||
|
@ -877,7 +897,7 @@ statics: {
|
|||
* @return {Boolean} {@true if the curve is parametrically linear}
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
* Checks if the the two curves describe straight lines that are
|
||||
* collinear, meaning they run in parallel.
|
||||
*
|
||||
|
@ -889,7 +909,7 @@ statics: {
|
|||
&& this.getVector().isCollinear(curve.getVector());
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Checks if the curve is a straight horizontal line.
|
||||
*
|
||||
* @return {Boolean} {@true if the line is horizontal}
|
||||
|
@ -899,7 +919,7 @@ statics: {
|
|||
< /*#=*/Numerical.GEOMETRIC_EPSILON;
|
||||
},
|
||||
|
||||
/**
|
||||
/**
|
||||
* Checks if the curve is a straight vertical line.
|
||||
*
|
||||
* @return {Boolean} {@true if the line is vertical}
|
||||
|
|
|
@ -392,6 +392,27 @@ var Segment = Base.extend(/** @lends Segment# */{
|
|||
|| this._path._closed && segments[segments.length - 1]) || null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if the this is the first segment in the {@link Path#segments}
|
||||
* array.
|
||||
*
|
||||
* @return {Boolean} {@true if this is the first segment}
|
||||
*/
|
||||
isFirst: function() {
|
||||
return this._index === 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks if the this is the last segment in the {@link Path#segments}
|
||||
* array.
|
||||
*
|
||||
* @return {Boolean} {@true if this is the last segment}
|
||||
*/
|
||||
isLast: function() {
|
||||
var path = this._path;
|
||||
return path && this._index === path._segments.length - 1 || false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Reverses the {@link #handleIn} and {@link #handleOut} vectors of this
|
||||
* segment. Note: the actual segment is modified, no copy is created.
|
||||
|
|
Loading…
Reference in a new issue