diff options
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/shapes/polyline.js')
| -rw-r--r-- | public/assets/javascripts/rectangles/engine/shapes/polyline.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/public/assets/javascripts/rectangles/engine/shapes/polyline.js b/public/assets/javascripts/rectangles/engine/shapes/polyline.js index 3c4e9c3..99c8fda 100644 --- a/public/assets/javascripts/rectangles/engine/shapes/polyline.js +++ b/public/assets/javascripts/rectangles/engine/shapes/polyline.js @@ -134,6 +134,16 @@ var Polyline = Fiber.extend(function(base){ exports.rebuild = function(){ this.mx.rebuild() } + exports.getSegments = function(){ + if (this.points.length == 1) { + return [] + } + var segments = [] + for (var i = 1; i < this.points.length; i++) { + segments.push( [ this.points[i-1], this.points[i] ] ) + } + return segments + } exports.serialize = function(){ return this.points.map(function(point){ return [point.a, point.b] }) } |
