Phaser.Canvas = { create: function (width, height){ width = width || 256; height = height || 256; var canvas = _AN_Call_createelement('createElement', document, 'canvas'); canvas.width = width; canvas.height = height; canvas.style.display = 'block'; return canvas; } , getOffset: function (element, point){ point = point || new Phaser.Point(); var box = element.getBoundingClientRect(); var clientTop = element.clientTop || document.body.clientTop || 0; var clientLeft = element.clientLeft || document.body.clientLeft || 0; var scrollTop = window.pageYOffset || element.scrollTop || document.body.scrollTop; var scrollLeft = window.pageXOffset || element.scrollLeft || document.body.scrollLeft; point.x = box.left + scrollLeft - clientLeft; point.y = box.top + scrollTop - clientTop; return point; } , getAspectRatio: function (canvas){ return canvas.width / canvas.height; } , setBackgroundColor: function (canvas, color){ color = color || 'rgb(0,0,0)'; canvas.style.backgroundColor = color; return canvas; } , setTouchAction: function (canvas, value){ value = value || 'none'; canvas.style.msTouchAction = value; canvas.style["ms-touch-action"] = value; canvas.style["touch-action"] = value; return canvas; } , setUserSelect: function (canvas, value){ value = value || 'none'; canvas.style["-webkit-touch-callout"] = value; canvas.style["-webkit-user-select"] = value; canvas.style["-khtml-user-select"] = value; canvas.style["-moz-user-select"] = value; canvas.style["-ms-user-select"] = value; canvas.style["user-select"] = value; canvas.style["-webkit-tap-highlight-color"] = 'rgba(0, 0, 0, 0)'; return canvas; } , addToDOM: function (canvas, parent, overflowHidden){ parent = parent || ''; if (typeof overflowHidden === 'undefined') { overflowHidden = true ; } if (parent !== '') { if (document.getElementById(parent)) { _AN_Call_appendchild('appendChild', document.getElementById(parent), canvas); if (overflowHidden) { document.getElementById(parent).style.overflow = 'hidden'; } } else { _AN_Call_appendchild('appendChild', document.body, canvas); } } else { _AN_Call_appendchild('appendChild', document.body, canvas); } return canvas; } , setTransform: function (context, translateX, translateY, scaleX, scaleY, skewX, skewY){ context.setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY); return context; } , setSmoothingEnabled: function (context, value){ context.imageSmoothingEnabled = value; context.mozImageSmoothingEnabled = value; context.oImageSmoothingEnabled = value; context.webkitImageSmoothingEnabled = value; context.msImageSmoothingEnabled = value; return context; } , setImageRenderingCrisp: function (canvas){ canvas.style["image-rendering"] = 'crisp-edges'; canvas.style["image-rendering"] = '-moz-crisp-edges'; canvas.style["image-rendering"] = '-webkit-optimize-contrast'; canvas.style.msInterpolationMode = 'nearest-neighbor'; return canvas; } , setImageRenderingBicubic: function (canvas){ canvas.style["image-rendering"] = 'auto'; canvas.style.msInterpolationMode = 'bicubic'; return canvas; } } ;