aboutsummaryrefslogtreecommitdiff
path: root/js/lib/geom/rectangle.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-04-06 12:13:59 -0700
committerPushkar Joshi2012-04-06 12:13:59 -0700
commit6cce5e9367676f5b452c28dd7d960aa46f4e464c (patch)
tree779125b7c1fc668c02e0dfbb661494a16242c329 /js/lib/geom/rectangle.js
parentf61545fd7054088efc88aafffd78e11df80d750d (diff)
parent7656b6eac7aec59697c6cddbe2a507fe9e4aa187 (diff)
downloadninja-6cce5e9367676f5b452c28dd7d960aa46f4e464c.tar.gz
Merge branch 'master' into pentool
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-xjs/lib/geom/rectangle.js118
1 files changed, 4 insertions, 114 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js
index e511d5f4..00c40eb9 100755
--- a/js/lib/geom/rectangle.js
+++ b/js/lib/geom/rectangle.js
@@ -187,65 +187,6 @@ var Rectangle = function GLRectangle() {
187 /////////////////////////////////////////////////////////////////////// 187 ///////////////////////////////////////////////////////////////////////
188 // Methods 188 // Methods
189 /////////////////////////////////////////////////////////////////////// 189 ///////////////////////////////////////////////////////////////////////
190 /*
191 this.export = function() {
192 var rtnStr = "type: " + this.geomType() + "\n";
193
194 /////////////////////////////////////////////////////////////////////////
195 //
196 // world, xOffset, yOffset, width, height, strokeSize, strokeColor, fillColor,
197 // tlRadius, trRadius, blRadius, brRadius, strokeMaterial, fillMaterial, strokeStyle
198 //
199 /////////////////////////////////////////////////////////////////////////////
200
201 rtnStr += "xoff: " + this._xOffset + "\n";
202 rtnStr += "yoff: " + this._yOffset + "\n";
203 rtnStr += "width: " + this._width + "\n";
204 rtnStr += "height: " + this._height + "\n";
205 rtnStr += "strokeWidth: " + this._strokeWidth + "\n";
206
207 if(this._strokeColor.gradientMode) {
208 rtnStr += "strokeGradientMode: " + this._strokeColor.gradientMode + "\n";
209 rtnStr += "strokeColor: " + this.gradientToString(this._strokeColor.color) + "\n";
210 } else {
211 rtnStr += "strokeColor: " + String(this._strokeColor) + "\n";
212 }
213
214 if(this._fillColor.gradientMode) {
215 rtnStr += "fillGradientMode: " + this._fillColor.gradientMode + "\n";
216 rtnStr += "fillColor: " + this.gradientToString(this._fillColor.color) + "\n";
217 } else {
218 rtnStr += "fillColor: " + String(this._fillColor) + "\n";
219 }
220 rtnStr += "tlRadius: " + this._tlRadius + "\n";
221 rtnStr += "trRadius: " + this._trRadius + "\n";
222 rtnStr += "blRadius: " + this._blRadius + "\n";
223 rtnStr += "brRadius: " + this._brRadius + "\n";
224 rtnStr += "innerRadius: " + this._innerRadius + "\n";
225 rtnStr += "strokeStyle: " + this._strokeStyle + "\n";
226
227 rtnStr += "strokeMat: ";
228 if (this._strokeMaterial) {
229 rtnStr += this._strokeMaterial.getName();
230 } else {
231 rtnStr += MaterialsModel.getDefaultMaterialName();
232 }
233 rtnStr += "\n";
234
235 rtnStr += "fillMat: ";
236 if (this._fillMaterial) {
237 rtnStr += this._fillMaterial.getName();
238 } else {
239 rtnStr += MaterialsModel.getDefaultMaterialName();
240 }
241 rtnStr += "\n";
242
243 rtnStr += this.exportMaterials();
244
245 return rtnStr;
246 };
247 */
248
249 // JSON export 190 // JSON export
250 this.exportJSON = function() 191 this.exportJSON = function()
251 { 192 {
@@ -293,57 +234,6 @@ var Rectangle = function GLRectangle() {
293 this.importMaterialsJSON( jObj.materials ); 234 this.importMaterialsJSON( jObj.materials );
294 }; 235 };
295 236
296 this.import = function( importStr ) {
297 this._xOffset = Number( this.getPropertyFromString( "xoff: ", importStr ) );
298 this._yOffset = Number( this.getPropertyFromString( "yoff: ", importStr ) );
299 this._width = Number( this.getPropertyFromString( "width: ", importStr ) );
300 this._height = Number( this.getPropertyFromString( "height: ", importStr ) );
301 this._strokeWidth = Number( this.getPropertyFromString( "strokeWidth: ", importStr ) );
302 this._innerRadius = Number( this.getPropertyFromString( "innerRadius: ", importStr ) );
303 this._strokeStyle = Number( this.getPropertyFromString( "strokeStyle: ", importStr ) );
304 var strokeMaterialName = this.getPropertyFromString( "strokeMat: ", importStr );
305 var fillMaterialName = this.getPropertyFromString( "fillMat: ", importStr );
306 this._strokeStyle = this.getPropertyFromString( "strokeStyle: ", importStr );
307
308 if(importStr.indexOf("fillGradientMode: ") < 0) {
309 this._fillColor = eval( "[" + this.getPropertyFromString( "fillColor: ", importStr ) + "]" );
310 } else {
311 this._fillColor = {};
312 this._fillColor.gradientMode = this.getPropertyFromString( "fillGradientMode: ", importStr );
313 this._fillColor.color = this.stringToGradient(this.getPropertyFromString( "fillColor: ", importStr ));
314 }
315
316 if(importStr.indexOf("strokeGradientMode: ") < 0)
317 {
318 this._strokeColor = eval( "[" + this.getPropertyFromString( "strokeColor: ", importStr ) + "]" );
319 } else {
320 this._strokeColor = {};
321 this._strokeColor.gradientMode = this.getPropertyFromString( "strokeGradientMode: ", importStr );
322 this._strokeColor.color = this.stringToGradient(this.getPropertyFromString( "strokeColor: ", importStr ));
323 }
324
325 this._tlRadius = Number( this.getPropertyFromString( "tlRadius: ", importStr ) );
326 this._trRadius = Number( this.getPropertyFromString( "trRadius: ", importStr ) );
327 this._blRadius = Number( this.getPropertyFromString( "blRadius: ", importStr ) );
328 this._brRadius = Number( this.getPropertyFromString( "brRadius: ", importStr ) );
329
330 var strokeMat = MaterialsModel.getMaterial( strokeMaterialName );
331 if (!strokeMat) {
332 console.log( "object material not found in library: " + strokeMaterialName );
333 strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
334 }
335 this._strokeMaterial = strokeMat;
336
337 var fillMat = MaterialsModel.getMaterial( fillMaterialName );
338 if (!fillMat) {
339 console.log( "object material not found in library: " + fillMaterialName );
340 fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() );
341 }
342 this._fillMaterial = fillMat;
343
344 this.importMaterials( importStr );
345 };
346
347 this.buildBuffers = function() { 237 this.buildBuffers = function() {
348 // get the world 238 // get the world
349 var world = this.getWorld(); 239 var world = this.getWorld();
@@ -352,7 +242,7 @@ var Rectangle = function GLRectangle() {
352 if (!world._useWebGL) return; 242 if (!world._useWebGL) return;
353 243
354 // make sure RDGE has the correct context 244 // make sure RDGE has the correct context
355 g_Engine.setContext( world.getCanvas().rdgeid ); 245 RDGE.globals.engine.setContext( world.getCanvas().rdgeid );
356 246
357 // create the gl buffer 247 // create the gl buffer
358 var gl = world.getGLContext(); 248 var gl = world.getGLContext();
@@ -952,7 +842,7 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad,
952// } 842// }
953 843
954 // create the RDGE primitive 844 // create the RDGE primitive
955 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); 845 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
956}; 846};
957 847
958RectangleFill.pushVertex = function( x, y, z ) { 848RectangleFill.pushVertex = function( x, y, z ) {
@@ -1184,7 +1074,7 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad,
1184// } 1074// }
1185 1075
1186 // create the RDGE primitive 1076 // create the RDGE primitive
1187 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); 1077 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
1188}; 1078};
1189 1079
1190RectangleStroke.getRoundedCorner = function( ctr, insidePt, outsidePt ) { 1080RectangleStroke.getRoundedCorner = function( ctr, insidePt, outsidePt ) {
@@ -1270,7 +1160,7 @@ RectangleGeometry.create = function( ctr, width, height, material ) {
1270// } 1160// }
1271 1161
1272 // create the RDGE primitive 1162 // create the RDGE primitive
1273 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); 1163 return ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, RDGE.globals.engine.getContext().renderer.TRIANGLES, nVertices);
1274}; 1164};
1275 1165
1276RectangleGeometry.pushVertex = RectangleFill.pushVertex; 1166RectangleGeometry.pushVertex = RectangleFill.pushVertex;