aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/geom/brush-stroke.js50
1 files changed, 47 insertions, 3 deletions
diff --git a/js/lib/geom/brush-stroke.js b/js/lib/geom/brush-stroke.js
index 02a39ccd..ec2521ab 100755
--- a/js/lib/geom/brush-stroke.js
+++ b/js/lib/geom/brush-stroke.js
@@ -388,7 +388,8 @@ var BrushStroke = function GLBrushStroke() {
388 this._BBoxMax[d]+= bboxPadding; 388 this._BBoxMax[d]+= bboxPadding;
389 }//for every dimension d from 0 to 2 389 }//for every dimension d from 0 to 2
390 } 390 }
391 } 391
392 } //if this was dirty
392 this._dirty = false; 393 this._dirty = false;
393 }; 394 };
394 395
@@ -512,12 +513,55 @@ var BrushStroke = function GLBrushStroke() {
512 }; //render() 513 }; //render()
513 514
514 515
516 this.exportJSON = function(){
517 var retObject= new Object();
518 retObject.geomType = this.geomType();
519 retObject.points = this._Points;
520 retObject.planeCenter = this._planeCenter;
521 retObject.planeMat = this._planeMat;
522 retObject.planeMatInv = this._planeMatInv;
523 retObject.strokeWidth = this._strokeWidth;
524 retObject.strokeColor = this._strokeColor;
525 retObject.secondStrokeColor = this._secondStrokeColor;
526 retObject.strokeHardness = this._strokeHardness;
527 retObject.strokeDoSmoothing = this._strokeDoSmoothing;
528 retObject.strokeUseCalligraphic = this._strokeUseCalligraphic;
529 retObject.strokeAngle = this._strokeAngle;
530 retObject.strokeAmountSmoothing = this._strokeAmountSmoothing;
531 return retObject;
532 };
533
534 this.importJSON = function(jo){
535 if (this.geomType()!== jo.geomType){
536 return;
537 }
538 this._Points = jo.points.splice(0); //todo is this splice necessary?
539 this._planeCenter = jo.planeCenter;
540 this._planeMat = jo.planeMat;
541 this._planeMatInv = jo.planeMatInv ;
542 this._strokeWidth = jo.strokeWidth;
543 this._strokeColor = jo.strokeColor;
544 this._secondStrokeColor = jo.secondStrokeColor;
545 this._strokeHardness = jo.strokeHardness;
546 this._strokeDoSmoothing = jo.strokeDoSmoothing;
547 this._strokeUseCalligraphic = jo.strokeUseCalligraphic;
548 this._strokeAngle = jo.strokeAngle;
549 this._strokeAmountSmoothing = jo.strokeAmountSmoothing;
550
551 //force a re-computation of meta-geometry before rendering
552 this._isDirty = true;
553 };
554
555
515 this.export = function() { 556 this.export = function() {
516 return "type: " + this.geomType() + "\n"; 557 var jsonObject = this.exportJSON();
558 var stringified = JSON.stringify(jsonObject);
559 return "type: " + this.geomType() + "\n" + stringified;
517 }; 560 };
518 561
519 this.import = function( importStr ) { 562 this.import = function( importStr ) {
520 563 var jsonObject = JSON.parse(importStr);
564 this.importJSON(jsonObject);
521 } 565 }
522 566
523 this.collidesWithPoint = function (x, y, z) { 567 this.collidesWithPoint = function (x, y, z) {