aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/circle.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-03-27 09:32:53 -0700
committerNivesh Rajbhandari2012-03-27 09:32:53 -0700
commit406bbfc63f8ed42d7da105dbd068a49ff8fb5f09 (patch)
tree3a8b45f4802f002269ff1bcf596f94cee4679a07 /js/lib/geom/circle.js
parentbda9f8f5829c943486f8850e68c991e83f8fb8c8 (diff)
parent309dde5a8c4599cef6a1052c1ff9ee1ad8ec5858 (diff)
downloadninja-406bbfc63f8ed42d7da105dbd068a49ff8fb5f09.tar.gz
Merge branch 'refs/heads/ninja-internal' into WebGLMaterials
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
Diffstat (limited to 'js/lib/geom/circle.js')
-rwxr-xr-xjs/lib/geom/circle.js54
1 files changed, 47 insertions, 7 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js
index 4b155b4c..d48bf98b 100755
--- a/js/lib/geom/circle.js
+++ b/js/lib/geom/circle.js
@@ -53,13 +53,13 @@ var Circle = function GLCircle() {
53 if(strokeMaterial){ 53 if(strokeMaterial){
54 this._strokeMaterial = strokeMaterial; 54 this._strokeMaterial = strokeMaterial;
55 } else { 55 } else {
56 this._strokeMaterial = MaterialsModel.exportFlatMaterial(); 56 this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
57 } 57 }
58 58
59 if(fillMaterial) { 59 if(fillMaterial) {
60 this._fillMaterial = fillMaterial; 60 this._fillMaterial = fillMaterial;
61 } else { 61 } else {
62 this._fillMaterial = MaterialsModel.exportFlatMaterial(); 62 this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
63 } 63 }
64 64
65 this.exportMaterials(); 65 this.exportMaterials();
@@ -598,7 +598,47 @@ var Circle = function GLCircle() {
598 } 598 }
599 }; 599 };
600 600
601 this.export = function() { 601 this.exportJSON = function()
602 {
603 var jObj =
604 {
605 'type' : this.geomType(),
606 'xoff' : this._xOffset,
607 'yoff' : this._yOffset,
608 'width' : this._width,
609 'height' : this._height,
610 'strokeWidth' : this._strokeWidth,
611 'strokeColor' : this._strokeColor,
612 'fillColor' : this._fillColor,
613 'innerRadius' : this._innerRadius,
614 'strokeStyle' : this._strokeStyle,
615 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(),
616 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(),
617 'materials' : this.exportMaterialsJSON()
618 };
619
620 return jObj;
621 };
622
623 this.importJSON = function( jObj )
624 {
625 this._xOffset = jObj.xoff;
626 this._yOffset = jObj.yoff;
627 this._width = jObj.width;
628 this._height = jObj.height;
629 this._strokeWidth = jObj.strokeWidth;
630 this._strokeColor = jObj.strokeColor;
631 this._fillColor = jObj.fillColor;
632 this._innerRadius = jObj.innerRadius;
633 this._strokeStyle = jObj.strokeStyle;
634 var strokeMaterialName = jObj.strokeMat;
635 var fillMaterialName = jObj.fillMat;
636 this.importMaterialsJSON( jObj.materials );
637 };
638
639
640 this.export = function()
641 {
602 var rtnStr = "type: " + this.geomType() + "\n"; 642 var rtnStr = "type: " + this.geomType() + "\n";
603 643
604 rtnStr += "xoff: " + this._xOffset + "\n"; 644 rtnStr += "xoff: " + this._xOffset + "\n";
@@ -627,7 +667,7 @@ var Circle = function GLCircle() {
627 if (this._strokeMaterial) { 667 if (this._strokeMaterial) {
628 rtnStr += this._strokeMaterial.getName(); 668 rtnStr += this._strokeMaterial.getName();
629 } else { 669 } else {
630 rtnStr += "flatMaterial"; 670 rtnStr += MaterialsModel.getDefaultMaterialName();
631 } 671 }
632 672
633 rtnStr += "\n"; 673 rtnStr += "\n";
@@ -636,7 +676,7 @@ var Circle = function GLCircle() {
636 if (this._fillMaterial) { 676 if (this._fillMaterial) {
637 rtnStr += this._fillMaterial.getName(); 677 rtnStr += this._fillMaterial.getName();
638 } else { 678 } else {
639 rtnStr += "flatMaterial"; 679 rtnStr += MaterialsModel.getDefaultMaterialName();
640 } 680 }
641 rtnStr += "\n"; 681 rtnStr += "\n";
642 682
@@ -675,7 +715,7 @@ var Circle = function GLCircle() {
675 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); 715 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
676 if (!strokeMat) { 716 if (!strokeMat) {
677 console.log( "object material not found in library: " + strokeMaterialName ); 717 console.log( "object material not found in library: " + strokeMaterialName );
678 strokeMat = MaterialsModel.exportFlatMaterial(); 718 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
679 } 719 }
680 720
681 this._strokeMaterial = strokeMat; 721 this._strokeMaterial = strokeMat;
@@ -683,7 +723,7 @@ var Circle = function GLCircle() {
683 var fillMat = MaterialsModel.getMaterial( fillMaterialName ); 723 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
684 if (!fillMat) { 724 if (!fillMat) {
685 console.log( "object material not found in library: " + fillMaterialName ); 725 console.log( "object material not found in library: " + fillMaterialName );
686 fillMat = MaterialsModel.exportFlatMaterial(); 726 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
687 } 727 }
688 this._fillMaterial = fillMat; 728 this._fillMaterial = fillMat;
689 729