diff options
author | Valerio Virgillito | 2012-07-20 15:44:57 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-20 15:44:57 -0700 |
commit | d0526d124f2bbc1c28912d2d3de925d175f5e2d5 (patch) | |
tree | 9010ff97310f209fe35fef06899056cab8169282 /js/lib/geom | |
parent | c6965b0329672daeffbb3f76746821ab72ad03c8 (diff) | |
parent | d7f5d6ffb39d55f2d4f4f366421571826df1e8bb (diff) | |
download | ninja-d0526d124f2bbc1c28912d2d3de925d175f5e2d5.tar.gz |
Merge branch 'Fixes_071' of https://github.com/mqg734/ninja into v0.7.1
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-x | js/lib/geom/circle.js | 57 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 20 | ||||
-rwxr-xr-x | js/lib/geom/line.js | 26 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 57 |
4 files changed, 68 insertions, 92 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index ba47603b..4995c2cb 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js | |||
@@ -83,31 +83,13 @@ exports.Circle = Object.create(GeomObj, { | |||
83 | 83 | ||
84 | if(strokeMaterial) { | 84 | if(strokeMaterial) { |
85 | this._strokeMaterial = strokeMaterial.dup(); | 85 | this._strokeMaterial = strokeMaterial.dup(); |
86 | } else { | ||
87 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | ||
88 | } | ||
89 | |||
90 | if(strokeColor) { | ||
91 | if(this._strokeMaterial.hasProperty("color")) { | ||
92 | this._strokeMaterial.setProperty( "color", this._strokeColor ); | ||
93 | } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { | ||
94 | this._strokeMaterial.setGradientData(this._strokeColor.color); | ||
95 | } | ||
96 | } | 86 | } |
97 | 87 | ||
98 | if(fillMaterial) { | 88 | if(fillMaterial) { |
99 | this._fillMaterial = fillMaterial.dup(); | 89 | this._fillMaterial = fillMaterial.dup(); |
100 | } else { | ||
101 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | ||
102 | } | 90 | } |
103 | 91 | ||
104 | if(fillColor) { | 92 | this.initColors(); |
105 | if(this._fillMaterial.hasProperty("color")) { | ||
106 | this._fillMaterial.setProperty( "color", this._fillColor ); | ||
107 | } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { | ||
108 | this._fillMaterial.setGradientData(this._fillColor.color); | ||
109 | } | ||
110 | } | ||
111 | } | 93 | } |
112 | }, | 94 | }, |
113 | 95 | ||
@@ -770,8 +752,8 @@ exports.Circle = Object.create(GeomObj, { | |||
770 | 'fillColor' : this._fillColor, | 752 | 'fillColor' : this._fillColor, |
771 | 'innerRadius' : this._innerRadius, | 753 | 'innerRadius' : this._innerRadius, |
772 | 'strokeStyle' : this._strokeStyle, | 754 | 'strokeStyle' : this._strokeStyle, |
773 | 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), | 755 | 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, |
774 | 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(), | 756 | 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : null, |
775 | 'materials' : this.exportMaterialsJSON() | 757 | 'materials' : this.exportMaterialsJSON() |
776 | }; | 758 | }; |
777 | 759 | ||
@@ -790,27 +772,26 @@ exports.Circle = Object.create(GeomObj, { | |||
790 | this._fillColor = jObj.fillColor; | 772 | this._fillColor = jObj.fillColor; |
791 | this._innerRadius = jObj.innerRadius; | 773 | this._innerRadius = jObj.innerRadius; |
792 | this._strokeStyle = jObj.strokeStyle; | 774 | this._strokeStyle = jObj.strokeStyle; |
793 | var strokeMaterialName = jObj.strokeMat; | ||
794 | var fillMaterialName = jObj.fillMat; | ||
795 | 775 | ||
796 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); | 776 | if(jObj.strokeMat) { |
797 | if (!strokeMat) { | 777 | var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup(); |
798 | console.log( "object material not found in library: " + strokeMaterialName ); | 778 | if (!strokeMat) { |
799 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 779 | console.log("object material not found in library: " + jObj.strokeMat); |
780 | } else { | ||
781 | this._strokeMaterial = strokeMat; | ||
782 | } | ||
800 | } | 783 | } |
801 | this._strokeMaterial = strokeMat; | 784 | |
802 | if (this._strokeMaterial.hasProperty( 'color' )) | 785 | if(jObj.fillMat) { |
803 | this._strokeMaterial.setProperty( 'color', this._strokeColor ); | 786 | var fillMat = MaterialsModel.getMaterial(jObj.fillMat).dup(); |
804 | 787 | if (!fillMat) { | |
805 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); | 788 | console.log("object material not found in library: " + jObj.fillMat); |
806 | if (!fillMat) { | 789 | } else { |
807 | console.log( "object material not found in library: " + fillMaterialName ); | 790 | this._fillMaterial = fillMat; |
808 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | 791 | } |
809 | } | 792 | } |
810 | this._fillMaterial = fillMat; | ||
811 | if (this._fillMaterial.hasProperty( 'color' )) | ||
812 | this._fillMaterial.setProperty( 'color', this._fillColor ); | ||
813 | 793 | ||
794 | this.initColors(); | ||
814 | this.importMaterialsJSON( jObj.materials ); | 795 | this.importMaterialsJSON( jObj.materials ); |
815 | } | 796 | } |
816 | }, | 797 | }, |
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index e0ed51fb..7b4e49fa 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -205,6 +205,26 @@ exports.GeomObj = Object.create(Object.prototype, { | |||
205 | /////////////////////////////////////////////////////////////////////// | 205 | /////////////////////////////////////////////////////////////////////// |
206 | // Methods | 206 | // Methods |
207 | /////////////////////////////////////////////////////////////////////// | 207 | /////////////////////////////////////////////////////////////////////// |
208 | initColors: { | ||
209 | value: function() { | ||
210 | if(this._strokeColor && this._strokeMaterial) { | ||
211 | if(this._strokeMaterial.hasProperty("color")) { | ||
212 | this._strokeMaterial.setProperty( "color", this._strokeColor ); | ||
213 | } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { | ||
214 | this._strokeMaterial.setGradientData(this._strokeColor.color); | ||
215 | } | ||
216 | } | ||
217 | |||
218 | if(this._fillColor && this._fillMaterial) { | ||
219 | if(this._fillMaterial.hasProperty("color")) { | ||
220 | this._fillMaterial.setProperty( "color", this._fillColor ); | ||
221 | } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) { | ||
222 | this._fillMaterial.setGradientData(this._fillColor.color); | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | }, | ||
227 | |||
208 | setMaterialColor: { | 228 | setMaterialColor: { |
209 | value: function(c, type) { | 229 | value: function(c, type) { |
210 | var i = 0, | 230 | var i = 0, |
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index c0322f46..eec4f6d9 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js | |||
@@ -89,17 +89,9 @@ exports.Line = Object.create(GeomObj, { | |||
89 | 89 | ||
90 | if(strokeMaterial) { | 90 | if(strokeMaterial) { |
91 | this._strokeMaterial = strokeMaterial.dup(); | 91 | this._strokeMaterial = strokeMaterial.dup(); |
92 | } else { | ||
93 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | ||
94 | } | 92 | } |
95 | 93 | ||
96 | if(strokeColor) { | 94 | this.initColors(); |
97 | if(this._strokeMaterial.hasProperty("color")) { | ||
98 | this._strokeMaterial.setProperty( "color", this._strokeColor ); | ||
99 | } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { | ||
100 | this._strokeMaterial.setGradientData(this._strokeColor.color); | ||
101 | } | ||
102 | } | ||
103 | } | 95 | } |
104 | }, | 96 | }, |
105 | 97 | ||
@@ -245,7 +237,7 @@ exports.Line = Object.create(GeomObj, { | |||
245 | 'strokeWidth' : this._strokeWidth, | 237 | 'strokeWidth' : this._strokeWidth, |
246 | 'strokeColor' : this._strokeColor, | 238 | 'strokeColor' : this._strokeColor, |
247 | 'strokeStyle' : this._strokeStyle, | 239 | 'strokeStyle' : this._strokeStyle, |
248 | 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), | 240 | 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null, |
249 | 'materials' : this.exportMaterialsJSON() | 241 | 'materials' : this.exportMaterialsJSON() |
250 | }; | 242 | }; |
251 | 243 | ||
@@ -265,15 +257,17 @@ exports.Line = Object.create(GeomObj, { | |||
265 | this._slope = jObj.slope; | 257 | this._slope = jObj.slope; |
266 | this._strokeStyle = jObj.strokeStyle; | 258 | this._strokeStyle = jObj.strokeStyle; |
267 | this._strokeColor = jObj.strokeColor; | 259 | this._strokeColor = jObj.strokeColor; |
268 | var strokeMaterialName = jObj.strokeMat; | ||
269 | 260 | ||
270 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | 261 | if(jObj.strokeMat) { |
271 | if (!strokeMat) { | 262 | var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup(); |
272 | console.log( "object material not found in library: " + strokeMaterialName ); | 263 | if (!strokeMat) { |
273 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 264 | console.log("object material not found in library: " + jObj.strokeMat); |
265 | } else { | ||
266 | this._strokeMaterial = strokeMat; | ||
267 | } | ||
274 | } | 268 | } |
275 | this._strokeMaterial = strokeMat; | ||
276 | 269 | ||
270 | this.initColors(); | ||
277 | this.importMaterialsJSON( jObj.materials ); | 271 | this.importMaterialsJSON( jObj.materials ); |
278 | } | 272 | } |
279 | }, | 273 | }, |
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index f1da4918..f3db92af 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js | |||
@@ -99,31 +99,13 @@ exports.Rectangle = Object.create(GeomObj, { | |||
99 | 99 | ||
100 | if(strokeMaterial) { | 100 | if(strokeMaterial) { |
101 | this._strokeMaterial = strokeMaterial.dup(); | 101 | this._strokeMaterial = strokeMaterial.dup(); |
102 | } else { | ||
103 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | ||
104 | } | ||
105 | |||
106 | if(strokeColor) { | ||
107 | if(this._strokeMaterial.hasProperty("color")) { | ||
108 | this._strokeMaterial.setProperty( "color", this._strokeColor ); | ||
109 | } else if (this._strokeMaterial && (this._strokeMaterial.gradientType === this._strokeColor.gradientMode)) { | ||
110 | this._strokeMaterial.setGradientData(this._strokeColor.color); | ||
111 | } | ||
112 | } | 102 | } |
113 | 103 | ||
114 | if(fillMaterial) { | 104 | if(fillMaterial) { |
115 | this._fillMaterial = fillMaterial.dup(); | 105 | this._fillMaterial = fillMaterial.dup(); |
116 | } else { | ||
117 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); | ||
118 | } | 106 | } |
119 | 107 | ||
120 | if(fillColor) { | 108 | this.initColors(); |
121 | if(this._fillMaterial.hasProperty("color")) { | ||
122 |