summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/engine/shapes/polyline.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-08-18 20:05:56 -0400
committerJules Laplace <jules@okfoc.us>2015-08-18 20:05:56 -0400
commit40fa450839a171cbfa1d9c8470d25eeeba337a27 (patch)
tree0aded62c6ac2af50cf62f071f42ee34dfc88edc8 /public/assets/javascripts/rectangles/engine/shapes/polyline.js
parentbbd62d9c7f3838d07e42e46c244c317a5dbdb5ae (diff)
serialize/deserialize polyline
Diffstat (limited to 'public/assets/javascripts/rectangles/engine/shapes/polyline.js')
-rw-r--r--public/assets/javascripts/rectangles/engine/shapes/polyline.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/public/assets/javascripts/rectangles/engine/shapes/polyline.js b/public/assets/javascripts/rectangles/engine/shapes/polyline.js
index 7e3c04c..e853592 100644
--- a/public/assets/javascripts/rectangles/engine/shapes/polyline.js
+++ b/public/assets/javascripts/rectangles/engine/shapes/polyline.js
@@ -1,9 +1,12 @@
var Polyline = Fiber.extend(function(base){
var exports = {}
- exports.init = function(){
- this.points = []
+ exports.init = function(points){
+ this.points = points
this.mx_points = []
this.closed = false
+ if (points) {
+ this.build()
+ }
}
exports.add = function(p){
this.points.push( p )
@@ -134,6 +137,9 @@ var Polyline = Fiber.extend(function(base){
exports.rebuild = function(){
this.mx.rebuild()
}
+ exports.serialize = function(){
+ return this.points
+ }
exports.reset = function(){
this.mx_points.forEach(function(mx){ scene.remove(mx) })
this.mx_points.length = 0