API Documentation
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 312 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 312 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 318 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 318 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 428 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 428 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 587 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 587 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 610 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 610 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 616 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
Warning: DOMDocument::loadHTMLFile() [domdocument.loadhtmlfile]: htmlParseEntityRef: no name in jsdoc/symbols/src/src_core_glge.js.html, line: 616 in /homepages/22/d163487924/htdocs/glge/wp-content/themes/glge/manual.php on line 29
1 /* 2 GLGE WebGL Graphics Engine 3 Copyright (c) 2010, Paul Brunt 4 All rights reserved. 5 6 Redistribution and use in source and binary forms, with or without 7 modification, are permitted provided that the following conditions are met: 8 * Redistributions of source code must retain the above copyright 9 notice, this list of conditions and the following disclaimer. 10 * Redistributions in binary form must reproduce the above copyright 11 notice, this list of conditions and the following disclaimer in the 12 documentation and/or other materials provided with the distribution. 13 * Neither the name of GLGE nor the 14 names of its contributors may be used to endorse or promote products 15 derived from this software without specific prior written permission. 16 17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 DISCLAIMED. IN NO EVENT SHALL PAUL BRUNT BE LIABLE FOR ANY 21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** 30 * @fileOverview 31 * @name glge.js 32 * @author me@paulbrunt.co.uk 33 */ 34 35 36 37 if(typeof(GLGE) == "undefined"){ 38 /** 39 * @namespace Holds the functionality of the library 40 */ 41 GLGE = {}; 42 } 43 44 (function(GLGE){ 45 46 //speed ups parsing a float that is already a float is expensive! 47 var parseFloat2=function(val){ 48 if(typeof val!="number") return parseFloat(val); 49 else return val; 50 } 51 52 53 /** 54 * Function to augment one object with another 55 * @param {object} obj1 Source Object 56 * @param {object} obj2 Destination Object 57 */ 58 GLGE.augment=function(obj1,obj2){ 59 obj2.prototype.baseclass = obj1; 60 for(var proto in obj1.prototype){ 61 if(!obj2.prototype[proto]) // do not overwrite functions of the derived objects 62 obj2.prototype[proto]=obj1.prototype[proto]; 63 else // Attach those to the baseclass instead. Use 'call(this)' to call baseclass methods 64 obj2.prototype.baseclass[proto]=obj1.prototype[proto]; 65 } 66 } 67 68 69 /** 70 * Moves all GLGE function to global 71 **/ 72 GLGE.makeGlobal=function(){ 73 for(var key in GLGE){ 74 window[key]=GLGE[key]; 75 } 76 } 77 78 GLGE.New=function(createclass){ 79 if(GLGE[createclass].prototype.className!=""){ 80 return new GLGE[createclass](); 81 }else{ 82 return false; 83 } 84 } 85 86 /** 87 * @constant 88 * @description Enumeration for TRUE 89 */ 90 GLGE.TRUE=1; 91 /** 92 * @constant 93 * @description Enumeration for FALSE 94 */ 95 GLGE.FALSE=0; 96 97 /** 98 * @constant 99 * @description Enumeration for global refrance frame 100 */ 101 GLGE.GLOBAL=0; 102 /** 103 * @constant 104 * @description Enumeration for local refrance frame 105 */ 106 GLGE.LOCAL=1; 107 108 109 /** 110 * @constant 111 * @description Enumeration for tri rendering 112 */ 113 GLGE.DRAW_TRIS=1; 114 /** 115 * @constant 116 * @description Enumeration for line rendering 117 */ 118 GLGE.DRAW_LINES=2; 119 120 /** 121 * @constant 122 * @description Enumeration for line loop rendering 123 */ 124 GLGE.DRAW_LINELOOPS=3; 125 /** 126 * @constant 127 * @description Enumeration for line loop rendering 128 */ 129 GLGE.DRAW_LINESTRIPS=4; 130 /** 131 * @constant 132 * @description Enumeration for point rendering 133 */ 134 GLGE.DRAW_POINTS=5; 135 136 /** 137 * @constant 138 * @description Enumeration for point rendering 139 */ 140 GLGE.DRAW_TRIANGLESTRIP=6; 141 142 143 144 145 /** 146 * @constant 147 * @description Enumeration for rendering using default shader 148 */ 149 GLGE.RENDER_DEFAULT=0; 150 151 /** 152 * @constant 153 * @description Enumeration for rendering using shadow shader 154 */ 155 GLGE.RENDER_SHADOW=1; 156 157 /** 158 * @constant 159 * @description Enumeration for rendering using pick shader 160 */ 161 GLGE.RENDER_PICK=2; 162 163 /** 164 * @constant 165 * @description Enumeration for rendering using normal shader 166 */ 167 GLGE.RENDER_NORMAL=3; 168 169 /** 170 * @constant 171 * @description Enumeration for emit rendering 172 */ 173 GLGE.RENDER_EMIT=4; 174 175 /** 176 * @constant 177 * @description Enumeration for depth rendering 178 */ 179 GLGE.RENDER_DEPTH=5; 180 181 /** 182 * @constant 183 * @description Enumeration for no rendering 184 */ 185 GLGE.RENDER_NULL=6; 186 187 /** 188 * @constant 189 * @description Enumeration for box bound text picking 190 */ 191 GLGE.TEXT_BOXPICK=1; 192 /** 193 * @constant 194 * @description Enumeration for text bound text picking 195 */ 196 GLGE.TEXT_TEXTPICK=2; 197 198 /** 199 * @constant 200 * @description Enumeration for euler rotaions mode 201 */ 202 GLGE.P_EULER=1; 203 204 /** 205 * @constant 206 * @description Enumeration for quaternions mode 207 */ 208 GLGE.P_QUAT=2; 209 210 /** 211 * @constant 212 * @description Enumeration for matrix rotation mode 213 */ 214 GLGE.P_MATRIX=3; 215 216 /** 217 * @constant 218 * @description Enumeration for no value 219 */ 220 GLGE.NONE=0; 221 222 /** 223 * @constant 224 * @description Enumeration for X-Axis 225 */ 226 GLGE.XAXIS=1; 227 /** 228 * @constant 229 * @description Enumeration for Y-Axis 230 */ 231 GLGE.YAXIS=2; 232 /** 233 * @constant 234 * @description Enumeration for Z-Axis 235 */ 236 GLGE.ZAXIS=3; 237 238 /** 239 * @constant 240 * @description Enumeration for +X-Axis 241 */ 242 GLGE.POS_XAXIS=1; 243 /** 244 * @constant 245 * @description Enumeration for -X-Axis 246 */ 247 GLGE.NEG_XAXIS=2; 248 /** 249 * @constant 250 * @description Enumeration for +Y-Axis 251 */ 252 GLGE.POS_YAXIS=3; 253 /** 254 * @constant 255 * @description Enumeration for -Y-Axis 256 */ 257 GLGE.NEG_YAXIS=4; 258 /** 259 * @constant 260 * @description Enumeration for +Z-Axis 261 */ 262 GLGE.POS_ZAXIS=5; 263 /** 264 * @constant 265 * @description Enumeration for -Z-Axis 266 */ 267 GLGE.NEG_ZAXIS=6; 268 269 270 GLGE.ZERO="ZERO"; 271 GLGE.ONE="ONE"; 272 GLGE.SRC_COLOR="SRC_COLOR"; 273 GLGE.ONE_MINUS_SRC_COLOR="ONE_MINUS_SRC_COLOR"; 274 GLGE.SRC_ALPHA="SRC_ALPHA"; 275 GLGE.ONE_MINUS_SRC_ALPHA="ONE_MINUS_SRC_ALPHA"; 276 GLGE.DST_ALPHA="DST_ALPHA"; 277 GLGE.ONE_MINUS_DST_ALPHA="ONE_MINUS_DST_ALPHA"; 278 279 280 /** 281 * @constant 282 * @description Linear blending function 283 */ 284 GLGE.LINEAR_BLEND=function(value){ 285 return value; 286 } 287 /** 288 * @constant 289 * @description Quadratic blending function 290 */ 291 GLGE.QUAD_BLEND=function(value){ 292 return value*value; 293 } 294 /** 295 * @constant 296 * @description Special blending function 297 */ 298 GLGE.SPECIAL_BLEND=function(value){ 299 value=value*(2-value); 300 return value*value; 301 } 302 303 304 GLGE.error=function(error){ 305 if (console&&console.log) 306 console.log("GLGE error: "+error); 307 //do not use a modal dialog to indicate this users can override GLGE.error if they desire 308 }; 309 310 GLGE.warning=function(warning){ 311 if (console&&console.log) 312 console.log("GLGE warning: "+warning); 313 //do not use a modal dialog to indicate this users can override GLGE.warning if they desire 314 }; 315 316 /** 317 * @namespace Holds the global asset store 318 */ 319 GLGE.Assets={}; 320 GLGE.Assets.assets={}; 321 //don't need to register assets unless we are using network or webworkers 322 GLGE.REGISTER_ASSETS=false; 323 324 GLGE.Assets.createUUID=function(){ 325 var data=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]; 326 var data2=["8","9","A","B"]; 327 uuid=""; 328 for(var i=0;i<38;i++){ 329 switch(i){ 330 case 8:uuid=uuid+"-";break; 331 case 13:uuid=uuid+"-";break; 332 case 18:uuid=uuid+"-";break; 333 case 14:uuid=uuid+"4";break; 334 case 19:uuid=uuid+data2[Math.round(Math.random()*3)];break; 335 default:uuid=uuid+data[Math.round(Math.random()*15)];break; 336 } 337 } 338 return uuid; 339 } 340 /** 341 * @function registers a new asset 342 */ 343 GLGE.Assets.registerAsset=function(obj,uid){ 344 if(typeof uid=="object"){ 345 if(obj._) obj._(uid); 346 uid=uid.uid; 347 } 348 if(!uid){ 349 uid=GLGE.Assets.createUUID(); 350 }; 351 obj.uid=uid; 352 if(GLGE.REGISTER_ASSETS){ 353 GLGE.Assets.assets[uid]=obj; 354 } 355 } 356 /** 357 * @function removes an asset 358 */ 359 GLGE.Assets.unregisterAsset=function(uid){ 360 delete GLGE.Assets.assets[uid]; 361 } 362 /** 363 * @function finds an asset by uid 364 */ 365 GLGE.Assets.get=function(uid){ 366 var value=GLGE.Assets.assets[uid]; 367 if(value){ 368 return value; 369 }else{ 370 return false; 371 } 372 } 373 374 /** 375 * @function hashing function 376 * @private 377 */ 378 GLGE.DJBHash=function(str){ 379 var hash = 5381; 380 381 for(var i = 0; i < str.length; i++){ 382 hash = ((hash << 5) + hash) + str.charCodeAt(i); 383 } 384 385 return hash; 386 } 387 388 /** 389 * @function check if shader is already created if not then create it 390 * @private 391 */ 392 GLGE.getGLShader=function(gl,type,str){ 393 var hash=GLGE.DJBHash(str); 394 if(!gl.shaderCache) gl.shaderCache={}; 395 if(!gl.shaderCache[hash]){ 396 var shader=gl.createShader(type); 397 gl.shaderSource(shader, str); 398 gl.compileShader(shader); 399 if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { 400 try { 401 GLGE.error(gl.getShaderInfoLog(shader)); 402 return; 403 } catch (e) { 404 /* Firefox hack: Assume no error if there was no shader log. */ 405 } 406 } 407 gl.shaderCache[hash]=shader; 408 } 409 return gl.shaderCache[hash]; 410 } 411 412 var progIdx=0; 413 /** 414 * @function tries to re use programs 415 * @private 416 */ 417 GLGE.getGLProgram=function(gl,vShader,fShader){ 418 if(!gl.programCache) gl.programCache=[]; 419 var programCache=gl.programCache; 420 for(var i=0; i<programCache.length;i++){ 421 if(programCache[i].fShader==fShader && programCache[i].vShader==vShader){ 422 return programCache[i].program; 423 } 424 } 425 var program=gl.createProgram(); 426 program.progIdx=progIdx++; 427 gl.attachShader(program, vShader); 428 gl.attachShader(program, fShader); 429 gl.linkProgram(program); 430 if (!gl.getProgramParameter(program, gl.LINK_STATUS)) { 431 GLGE.error("Couldn't link shader: " + gl.getProgramInfoLog(program)); 432 } 433 programCache.push({vShader:vShader,fShader:fShader,program:program}); 434 if(!program.uniformDetails){ 435 program.uniformDetails={}; 436 var uniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS); 437 for (var i=0;i<uniforms;++i) { 438 var info=gl.getActiveUniform(program, i); 439 program.uniformDetails[info.name]={loc:GLGE.getUniformLocation(gl,program,info.name),info:info}; 440 } 441 } 442 return program; 443 } 444 445 446 /** 447 * function to cache the uniform locations 448 * @param {glcontext} the gl context of the program 449 * @param {program} the shader program 450 * @param {string} the uniform name 451 * @private 452 */ 453 GLGE.getUniformLocation=function(gl,program, uniform){ 454 /*if(program.uniformDetails[uniform]){ 455 return program.uniformDetails[uniform].loc; 456 }else{ 457 return gl.getUniformLocation(program, uniform); 458 }*/ 459 if(!program.uniformCache) program.uniformCache={}; 460 if(!program.uniformChecked) program.uniformChecked={}; 461 if(!program.uniformChecked[uniform]){ 462 program.uniformCache[uniform]=gl.getUniformLocation(program, uniform); 463 program.uniformChecked[uniform]=true; 464 } 465 return program.uniformCache[uniform]; 466 }; 467 /** 468 * functions to set uniforms with location check. 469 */ 470 GLGE.setUniform=function(gl,type,location,value){ 471 if(typeof value=="string") value=+value; 472 if(location!=null) 473 gl["uniform"+type](location,value); 474 475 }; 476 477 GLGE.setUniform3=function(gl,type,location,value1,value2,value3){ 478 if(typeof value1=="string") value1=+value1; 479 if(typeof value2=="string") value2=+value2; 480 if(typeof value3=="string") value3=+value3; 481 if(location!=null) 482 gl["uniform"+type](location,value1,value2,value3); 483 484 }; 485 486 GLGE.setUniform2=function(gl,type,location,value1,value2){ 487 if(typeof value1=="string") value1=+value1; 488 if(typeof value2=="string") value2=+value2; 489 if(location!=null) 490 gl["uniform"+type](location,value1,value2); 491 492 }; 493 GLGE.setUniform4=function(gl,type,location,value1,value2,value3,value4){ 494 if(location!=null) 495 gl["uniform"+type](location,value1,value2,value3,value4); 496 497 }; 498 499 GLGE.setUniformMatrix=function(gl,type,location,transpose,value){ 500 if(location!=null) 501 gl["uniform"+type](location,transpose,value); 502 }; 503 504 /** 505 * function to cache the attribute locations 506 * @param {glcontext} the gl context of the program 507 * @param {program} the shader program 508 * @param {string} the attribe name 509 * @private 510 */ 511 GLGE.getAttribLocation=function(gl,program, attrib){ 512 if(!program.attribCache) program.attribCache={}; 513 if(program.attribCache[attrib]==undefined){ 514 program.attribCache[attrib]=gl.getAttribLocation(program, attrib); 515 } 516 return program.attribCache[attrib]; 517 } 518 519 520 521 522 /** 523 * function to parse a colour input into RGB eg #ff00ff, red, rgb(100,100,100) 524 * @param {string} color the color to parse 525 */ 526 GLGE.colorParse=function(color){ 527 var red,green,blue,alpha; 528 //defines the color names 529 var color_names = { 530 aliceblue: 'f0f8ff', antiquewhite: 'faebd7', aqua: '00ffff', 531 aquamarine: '7fffd4', azure: 'f0ffff', beige: 'f5f5dc', 532 bisque: 'ffe4c4', black: '000000', blanchedalmond: 'ffebcd', 533 blue: '0000ff', blueviolet: '8a2be2', brown: 'a52a2a', 534 burlywood: 'deb887', cadetblue: '5f9ea0', chartreuse: '7fff00', 535 chocolate: 'd2691e', coral: 'ff7f50', cornflowerblue: '6495ed', 536 cornsilk: 'fff8dc', crimson: 'dc143c', cyan: '00ffff', 537 darkblue: '00008b', darkcyan: '008b8b', darkgoldenrod: 'b8860b', 538 darkgray: 'a9a9a9', darkgreen: '006400', darkkhaki: 'bdb76b', 539 darkmagenta: '8b008b', darkolivegreen: '556b2f', darkorange: 'ff8c00', 540 darkorchid: '9932cc', darkred: '8b0000', darksalmon: 'e9967a', 541 darkseagreen: '8fbc8f', darkslateblue: '483d8b', darkslategray: '2f4f4f', 542 darkturquoise: '00ced1', darkviolet: '9400d3', deeppink: 'ff1493', 543 deepskyblue: '00bfff', dimgray: '696969', dodgerblue: '1e90ff', 544 feldspar: 'd19275', firebrick: 'b22222', floralwhite: 'fffaf0', 545 forestgreen: '228b22', fuchsia: 'ff00ff', gainsboro: 'dcdcdc', 546 ghostwhite: 'f8f8ff', gold: 'ffd700', goldenrod: 'daa520', 547 gray: '808080', green: '008000', greenyellow: 'adff2f', 548 honeydew: 'f0fff0', hotpink: 'ff69b4', indianred : 'cd5c5c', 549 indigo : '4b0082', ivory: 'fffff0', khaki: 'f0e68c', 550 lavender: 'e6e6fa', lavenderblush: 'fff0f5', lawngreen: '7cfc00', 551 lemonchiffon: 'fffacd', lightblue: 'add8e6', lightcoral: 'f08080', 552 lightcyan: 'e0ffff', lightgoldenrodyellow: 'fafad2', lightgrey: 'd3d3d3', 553 lightgreen: '90ee90', lightpink: 'ffb6c1', lightsalmon: 'ffa07a', 554 lightseagreen: '20b2aa', lightskyblue: '87cefa', lightslateblue: '8470ff', 555 lightslategray: '778899', lightsteelblue: 'b0c4de', lightyellow: 'ffffe0', 556 lime: '00ff00', limegreen: '32cd32', linen: 'faf0e6', 557 magenta: 'ff00ff', maroon: '800000', mediumaquamarine: '66cdaa', 558 mediumblue: '0000cd', mediumorchid: 'ba55d3', mediumpurple: '9370d8', 559 mediumseagreen: '3cb371', mediumslateblue: '7b68ee', mediumspringgreen: '00fa9a', 560 mediumturquoise: '48d1cc', mediumvioletred: 'c71585', midnightblue: '191970', 561 mintcream: 'f5fffa', mistyrose: 'ffe4e1', moccasin: 'ffe4b5', 562 navajowhite: 'ffdead', navy: '000080', oldlace: 'fdf5e6', 563 olive: '808000', olivedrab: '6b8e23', orange: 'ffa500', 564 orangered: 'ff4500', orchid: 'da70d6', palegoldenrod: 'eee8aa', 565 palegreen: '98fb98', paleturquoise: 'afeeee', palevioletred: 'd87093', 566 papayawhip: 'ffefd5', peachpuff: 'ffdab9', peru: 'cd853f', 567 pink: 'ffc0cb', plum: 'dda0dd', powderblue: 'b0e0e6', 568 purple: '800080', red: 'ff0000', rosybrown: 'bc8f8f', 569 royalblue: '4169e1', saddlebrown: '8b4513', salmon: 'fa8072', 570 sandybrown: 'f4a460', seagreen: '2e8b57', seashell: 'fff5ee', 571 sienna: 'a0522d', silver: 'c0c0c0', skyblue: '87ceeb', 572 slateblue: '6a5acd', slategray: '708090', snow: 'fffafa', 573 springgreen: '00ff7f', steelblue: '4682b4', tan: 'd2b48c', 574 teal: '008080', thistle: 'd8bfd8', tomato: 'ff6347', 575 turquoise: '40e0d0', violet: 'ee82ee', violetred: 'd02090', 576 wheat: 'f5deb3', white: 'ffffff', whitesmoke: 'f5f5f5', 577 yellow: 'ffff00', yellowgreen: '9acd32' 578 }; 579 if(color_names[color]) color="#"+color_names[color]; 580 if(color.substr && color.substr(0,1)=="#"){ 581 color=color.substr(1); 582 if(color.length==8){ 583 red=parseInt("0x"+color.substr(0,2))/255; 584 green=parseInt("0x"+color.substr(2,2))/255; 585 blue=parseInt("0x"+color.substr(4,2))/255; 586 alpha=parseInt("0x"+color.substr(6,2))/255; 587 }else if(color.length==4){ 588 red=parseInt("0x"+color.substr(0,1))/15; 589 green=parseInt("0x"+color.substr(1,1))/15; 590 blue=parseInt("0x"+color.substr(2,1))/15; 591 alpha=parseInt("0x"+color.substr(3,1))/15; 592 }else if(color.length==6){ 593 red=parseInt("0x"+color.substr(0,2))/255; 594 green=parseInt("0x"+color.substr(2,2))/255; 595 blue=parseInt("0x"+color.substr(4,2))/255; 596 alpha=1; 597 }else if(color.length==3){ 598 red=parseInt("0x"+color.substr(0,1))/15; 599 green=parseInt("0x"+color.substr(1,1))/15; 600 blue=parseInt("0x"+color.substr(2,1))/15; 601 alpha=1; 602 } 603 }else if(color.substr && color.substr(0,4)=="rgb("){ 604 var colors=color.substr(4).split(","); 605 red=parseInt(colors[0])/255; 606 green=parseInt(colors[1])/255; 607 blue=parseInt(colors[2])/255; 608 alpha=1; 609 }else if(color.substr && color.substr(0,5)=="rgba("){ 610 var colors=color.substr(4).split(","); 611 red=parseInt(colors[0])/255; 612 green=parseInt(colors[1])/255; 613 blue=parseInt(colors[2])/255; 614 alpha=parseInt(colors[3])/255; 615 }else{ 616 red=0; 617 green=0; 618 blue=0; 619 alpha=0; 620 } 621 return {r:red,g:green,b:blue,a:alpha}; 622 } 623 624 625 626 })(GLGE); 627 628 629