mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Implement Segment#isLinear() and Path#isPolygon().
This commit is contained in:
parent
5577e7e1ee
commit
1050e3314e
2 changed files with 19 additions and 1 deletions
|
@ -231,7 +231,15 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{
|
|||
},
|
||||
|
||||
isEmpty: function() {
|
||||
return this._segments.length == 0;
|
||||
return this._segments.length === 0;
|
||||
},
|
||||
|
||||
isPolygon: function() {
|
||||
for (var i = 0, l = this._segments.length; i < l; i++) {
|
||||
if (!this._segments[i].isLinear())
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
_apply: function(matrix) {
|
||||
|
|
|
@ -162,6 +162,16 @@ var Segment = this.Segment = Base.extend(/** @lends Segment# */{
|
|||
// this.corner = !this._handleIn.isColinear(this._handleOut);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks whether the segment has no handles defined, meaning it connects
|
||||
* two straight lines.
|
||||
*
|
||||
* @return {Boolean} {@true the segment is linear}
|
||||
*/
|
||||
isLinear: function() {
|
||||
return this._handleIn.isZero() && this._handleOut.isZero();
|
||||
},
|
||||
|
||||
_isSelected: function(point) {
|
||||
var state = this._selectionState;
|
||||
return point == this._point ? !!(state & SelectionState.POINT)
|
||||
|
|
Loading…
Reference in a new issue