diff --git a/src/path/Path.js b/src/path/Path.js index 8d6845eb..e8e2f0b1 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -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) { diff --git a/src/path/Segment.js b/src/path/Segment.js index 3ff67109..f0096b14 100644 --- a/src/path/Segment.js +++ b/src/path/Segment.js @@ -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)