aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/rectangle.js
diff options
context:
space:
mode:
authorJohn Mayhew2012-07-24 15:46:16 -0700
committerJohn Mayhew2012-07-24 15:46:16 -0700
commit9f240b8b9b1f5fb0f145c343ca5e533e25e81374 (patch)
tree407564eaa6466e8d4cf2eeee0c56dc623243586f /js/lib/geom/rectangle.js
parentd25359c75089215ee48838db081fd3d51cbbd85f (diff)
parent21d74af1e9fc57cc25cea8aa7408beabf79ff2f3 (diff)
downloadninja-9f240b8b9b1f5fb0f145c343ca5e533e25e81374.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-xjs/lib/geom/rectangle.js57
1 files changed, 19 insertions, 38 deletions
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 this._fillMaterial.setProperty( "color", this._fillColor );
123 } else if (this._fillMaterial && (this._fillMaterial.gradientType === this._fillColor.gradientMode)) {
124 this._fillMaterial.setGradientData(this._fillColor.color);
125 }
126 }
127 } 109 }
128 }, 110 },
129 111
@@ -303,8 +285,8 @@ exports.Rectangle = Object.create(GeomObj, {
303 'brRadius' : this._brRadius, 285 'brRadius' : this._brRadius,
304 'innerRadius' : this._innerRadius, 286 'innerRadius' : this._innerRadius,
305 'strokeStyle' : this._strokeStyle, 287 'strokeStyle' : this._strokeStyle,
306 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : MaterialsModel.getDefaultMaterialName(), 288 'strokeMat' : this._strokeMaterial ? this._strokeMaterial.getName() : null,
307 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : MaterialsModel.getDefaultMaterialName(), 289 'fillMat' : this._fillMaterial ? this._fillMaterial.getName() : null,
308 'materials' : this.exportMaterialsJSON() 290 'materials' : this.exportMaterialsJSON()
309 }; 291 };
310 292
@@ -327,27 +309,26 @@ exports.Rectangle = Object.create(GeomObj, {
327 this._brRadius = jObj.brRadius; 309 this._brRadius = jObj.brRadius;
328 this._innerRadius = jObj.innerRadius; 310 this._innerRadius = jObj.innerRadius;
329 this._strokeStyle = jObj.strokeStyle; 311 this._strokeStyle = jObj.strokeStyle;
330 var strokeMaterialName = jObj.strokeMat;
331 var fillMaterialName = jObj.fillMat;
332 312
333 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); 313 if(jObj.strokeMat) {
334 if (!strokeMat) { 314 var strokeMat = MaterialsModel.getMaterial(jObj.strokeMat).dup();
335 console.log( "object material not found in library: " + strokeMaterialName ); 315 if (!strokeMat) {
336 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); 316 console.log("object material not found in library: " + jObj.strokeMat);
317 } else {
318 this._strokeMaterial = strokeMat;
319 }
337 } 320 }
338 this._strokeMaterial = strokeMat; 321
339 if (this._strokeMaterial.hasProperty( 'color' )) 322 if(jObj.fillMat) {
340 this._strokeMaterial.setProperty( 'color', this._strokeColor ); 323 var fillMat = MaterialsModel.getMaterial(jObj.fillMat).dup();
341 324 if (!fillMat) {
342 var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); 325 console.log("object material not found in library: " + jObj.fillMat);
343 if (!fillMat) { 326 } else {
344 console.log( "object material not found in library: " + fillMaterialName ); 327 this._fillMaterial = fillMat;
345 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); 328 }
346 } 329 }
347 this._fillMaterial = fillMat;
348 if (this._fillMaterial.hasProperty( 'color' ))
349 this._fillMaterial.setProperty( 'color', this._fillColor );
350 330
331 this.initColors();
351 this.importMaterialsJSON( jObj.materials ); 332 this.importMaterialsJSON( jObj.materials );
352 } 333 }
353 }, 334 },