Phaser.Utils = { parseDimension: function (size, dimension){ var f = 0; var px = 0; if (typeof size === 'string') { if (size.substr(-1) === '%') { f = parseInt(size, 10) / 100; if (dimension === 0) { px = window.innerWidth * f; } else { px = window.innerHeight * f; } } else { px = parseInt(size, 10); } } else { px = size; } return px; } , shuffle: function (array){ for (var i = _AN_Read_length('length', array) - 1; i > 0; i-- ){ var j = Math.floor(Math.random() * (i + 1)); var temp = array[i]; array[i] = array[j]; array[j] = temp; } return array; } , pad: function (str, len, pad, dir){ if (typeof (len) == "undefined") { var len = 0; } if (typeof (pad) == "undefined") { var pad = ' '; } if (typeof (dir) == "undefined") { var dir = 3; } var padlen = 0; if (len + 1 >= _AN_Read_length("length", str)) { switch (dir){ case 1: str = Array(len + 1 - _AN_Read_length("length", str)).join(pad) + str; break ; case 3: var right = Math.ceil((padlen = len - _AN_Read_length("length", str)) / 2); var left = padlen - right; str = Array(left + 1).join(pad) + str + Array(right + 1).join(pad); break ; default : { str = str + Array(len + 1 - _AN_Read_length("length", str)).join(pad); break ; } } } return str; } , isPlainObject: function (obj){ if (typeof (obj) !== "object" || obj.nodeType || obj === obj.window) { return false ; } try { if (obj.constructor && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf")) { return false ; } } catch (e) { return false ; } return true ; } , extend: function (){ var options, name, src, copy, copyIsArray, clone, target = arguments[0] || { } , i = 1, length = _AN_Read_length("length", arguments), deep = false ; if (typeof target === "boolean") { deep = target; target = arguments[1] || { } ; i = 2; } if (length === i) { target = this; --i; } for (; i < length; i++ ){ if ((options = arguments[i]) != null ) { for (name in options){ src = target[name]; copy = options[name]; if (target === copy) { continue ; } if (deep && copy && (Phaser.Utils.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) { if (copyIsArray) { copyIsArray = false ; clone = src && Array.isArray(src)? src: [] ; } else { clone = src && Phaser.Utils.isPlainObject(src)? src: { } ; } target[name] = Phaser.Utils.extend(deep, clone, copy); } else if (copy !== undefined) { target[name] = copy; } } } } return target; } } ; PIXI.hex2rgb = function (hex){ return [(hex >> 16 & 255) / 255, (hex >> 8 & 255) / 255, (hex & 255) / 255] ; } ; PIXI.rgb2hex = function (rgb){ return ((rgb[0] * 255 << 16) + (rgb[1] * 255 << 8) + rgb[2] * 255); } ; PIXI.canUseNewCanvasBlendModes = function (){ var canvas = _AN_Call_createelement("createElement", document, 'canvas'); canvas.width = 1; canvas.height = 1; var context = canvas.getContext('2d'); context.fillStyle = '#000'; context.fillRect(0, 0, 1, 1); context.globalCompositeOperation = 'multiply'; context.fillStyle = '#fff'; context.fillRect(0, 0, 1, 1); return context.getImageData(0, 0, 1, 1).data[0] === 0; } ; PIXI.getNextPowerOfTwo = function (number){ if (number > 0 && (number & (number - 1)) === 0) return number; else { var result = 1; while (result < number)result <<= 1; return result; } } ; if (typeof Function.prototype.bind != 'function') { Function.prototype.bind = (function (){ var slice = Array.prototype.slice; return function (thisArg){ var target = this, boundArgs = slice.call(arguments, 1); if (typeof target != 'function') { throw new TypeError() } function bound(){ var args = boundArgs.concat(slice.call(arguments)); target.apply(this instanceof bound? this: thisArg, args); } bound.prototype = (function F(proto){ proto && (F.prototype = proto); if (!(this instanceof F)) { return new F(); } } )(target.prototype); return bound; } ; } )(); } if (!Array.isArray) { Array.isArray = function (arg){ return Object.prototype.toString.call(arg) == '[object Array]'; } ; }