From d9ecfddd7ba63d3cf94b29053476d1d11118d38e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 18 Aug 2015 21:25:28 -0400 Subject: saving blueprints --- .../assets/javascripts/rectangles/engine/shapes/polyline.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'public/assets/javascripts/rectangles/engine/shapes/polyline.js') 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) }) -- cgit v1.2.3-70-g09d2