diff options
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/shapes/polyline.js')
| -rw-r--r-- | public/assets/javascripts/rectangles/engine/shapes/polyline.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/public/assets/javascripts/rectangles/engine/shapes/polyline.js b/public/assets/javascripts/rectangles/engine/shapes/polyline.js index e853592..3c4e9c3 100644 --- a/public/assets/javascripts/rectangles/engine/shapes/polyline.js +++ b/public/assets/javascripts/rectangles/engine/shapes/polyline.js @@ -1,12 +1,9 @@ var Polyline = Fiber.extend(function(base){ var exports = {} - exports.init = function(points){ - this.points = points + exports.init = function(){ + this.points = [] this.mx_points = [] this.closed = false - if (points) { - this.build() - } } exports.add = function(p){ this.points.push( p ) @@ -138,7 +135,10 @@ var Polyline = Fiber.extend(function(base){ this.mx.rebuild() } exports.serialize = function(){ - return this.points + return this.points.map(function(point){ return [point.a, point.b] }) + } + exports.deserialize = function(points){ + this.points = points.map(function(point){ return new vec2(point[0], point[1]) }) } exports.reset = function(){ this.mx_points.forEach(function(mx){ scene.remove(mx) }) |
