mirror of
https://github.com/wassname/phaser.git
synced 2026-08-05 13:21:00 +08:00
Adding docs.
This commit is contained in:
+29
-31
@@ -1,28 +1,26 @@
|
||||
/**
|
||||
* @author Richard Davey <rich@photonstorm.com>
|
||||
* @copyright 2013 Photon Storm Ltd.
|
||||
* @license https://github.com/photonstorm/phaser/blob/master/license.txt MIT License
|
||||
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
||||
* @module Phaser.Canvas
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio
|
||||
* The Canvas class handles everything related to the <canvas> tag as a DOM Element, like styles, offset, aspect ratio
|
||||
*
|
||||
* @class Canvas
|
||||
* @static
|
||||
*/
|
||||
|
||||
Phaser.Canvas = {
|
||||
/**
|
||||
* Creates the <canvas> tag
|
||||
* Creates the <canvas> tag
|
||||
*
|
||||
* @method create
|
||||
* @param {number} width The desired width
|
||||
* @param {number} height The desired height
|
||||
* @return {HTMLCanvasElement} the newly created <canvas> tag
|
||||
* @param {number} width - The desired width.
|
||||
* @param {number} height - The desired height.
|
||||
* @return {HTMLCanvasElement} The newly created <canvas> tag.
|
||||
*/
|
||||
create: function (width, height) {
|
||||
|
||||
width = width || 256;
|
||||
height = height || 256;
|
||||
|
||||
@@ -38,9 +36,9 @@ Phaser.Canvas = {
|
||||
/**
|
||||
* Get the DOM offset values of any given element
|
||||
* @method getOffset
|
||||
* @param {HTMLElement} element The targeted element that we want to retrieve the offset
|
||||
* @param {Phaser.Point} [point] The point we want to take the x/y values of the offset
|
||||
* @return point {Phaser.Point} A point objet with the offsetX and Y as its properties
|
||||
* @param {HTMLElement} element - The targeted element that we want to retrieve the offset.
|
||||
* @param {Phaser.Point} [point] - The point we want to take the x/y values of the offset.
|
||||
* @return {Phaser.Point} - A point objet with the offsetX and Y as its properties.
|
||||
*/
|
||||
getOffset: function (element, point) {
|
||||
|
||||
@@ -63,8 +61,8 @@ Phaser.Canvas = {
|
||||
* Returns the aspect ratio of the given canvas.
|
||||
*
|
||||
* @method getAspectRatio
|
||||
* @param {HTMLCanvasElement} canvas The canvas to get the aspect ratio from.
|
||||
* @return {Number} Returns true on success
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to get the aspect ratio from.
|
||||
* @return {number} The ratio between canvas' width and height.
|
||||
*/
|
||||
getAspectRatio: function (canvas) {
|
||||
return canvas.width / canvas.height;
|
||||
@@ -74,8 +72,8 @@ Phaser.Canvas = {
|
||||
* Sets the background color behind the canvas. This changes the canvas style property.
|
||||
*
|
||||
* @method setBackgroundColor
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set the background color on.
|
||||
* @param {String} color The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color.
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the background color on.
|
||||
* @param {string} [color] - The color to set. Can be in the format 'rgb(r,g,b)', or '#RRGGBB' or any valid CSS color.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
setBackgroundColor: function (canvas, color) {
|
||||
@@ -92,9 +90,9 @@ Phaser.Canvas = {
|
||||
* Sets the touch-action property on the canvas style. Can be used to disable default browser touch actions.
|
||||
*
|
||||
* @method setTouchAction
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set the touch action on.
|
||||
* @param {String} value The touch action to set. Defaults to 'none'.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
||||
* @param {String} [value] - The touch action to set. Defaults to 'none'.
|
||||
* @return {HTMLCanvasElement} The source canvas.
|
||||
*/
|
||||
setTouchAction: function (canvas, value) {
|
||||
|
||||
@@ -127,9 +125,9 @@ Phaser.Canvas = {
|
||||
* If no parent is given it will be added as a child of the document.body.
|
||||
*
|
||||
* @method addToDOM
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set the touch action on.
|
||||
* @param {String} parent The DOM element to add the canvas to. Defaults to ''.
|
||||
* @param {bool} overflowHidden If set to true it will add the overflow='hidden' style to the parent DOM element.
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set the touch action on.
|
||||
* @param {string} parent - The DOM element to add the canvas to. Defaults to ''.
|
||||
* @param {bool} overflowHidden - If set to true it will add the overflow='hidden' style to the parent DOM element.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
addToDOM: function (canvas, parent, overflowHidden) {
|
||||
@@ -167,13 +165,13 @@ Phaser.Canvas = {
|
||||
* Sets the transform of the given canvas to the matrix values provided.
|
||||
*
|
||||
* @method setTransform
|
||||
* @param {CanvasRenderingContext2D} context The context to set the transform on.
|
||||
* @param {Number} translateX The value to translate horizontally by.
|
||||
* @param {Number} translateY The value to translate vertically by.
|
||||
* @param {Number} scaleX The value to scale horizontally by.
|
||||
* @param {Number} scaleY The value to scale vertically by.
|
||||
* @param {Number} skewX The value to skew horizontaly by.
|
||||
* @param {Number} skewY The value to skew vertically by.
|
||||
* @param {CanvasRenderingContext2D} context - The context to set the transform on.
|
||||
* @param {number} translateX - The value to translate horizontally by.
|
||||
* @param {number} translateY - The value to translate vertically by.
|
||||
* @param {number} scaleX - The value to scale horizontally by.
|
||||
* @param {number} scaleY - The value to scale vertically by.
|
||||
* @param {number} skewX - The value to skew horizontaly by.
|
||||
* @param {number} skewY - The value to skew vertically by.
|
||||
* @return {CanvasRenderingContext2D} Returns the source context.
|
||||
*/
|
||||
setTransform: function (context, translateX, translateY, scaleX, scaleY, skewX, skewY) {
|
||||
@@ -192,8 +190,8 @@ Phaser.Canvas = {
|
||||
* patchy on earlier browsers, especially on mobile.
|
||||
*
|
||||
* @method setSmoothingEnabled
|
||||
* @param {CanvasRenderingContext2D} context The context to enable or disable the image smoothing on.
|
||||
* @param {bool} value If set to true it will enable image smoothing, false will disable it.
|
||||
* @param {CanvasRenderingContext2D} context - The context to enable or disable the image smoothing on.
|
||||
* @param {bool} value - If set to true it will enable image smoothing, false will disable it.
|
||||
* @return {CanvasRenderingContext2D} Returns the source context.
|
||||
*/
|
||||
setSmoothingEnabled: function (context, value) {
|
||||
@@ -213,7 +211,7 @@ Phaser.Canvas = {
|
||||
* Note that if this doesn't given the desired result then see the setSmoothingEnabled.
|
||||
*
|
||||
* @method setImageRenderingCrisp
|
||||
* @param {HTMLCanvasElement} canvas The canvas to set image-rendering crisp on.
|
||||
* @param {HTMLCanvasElement} canvas - The canvas to set image-rendering crisp on.
|
||||
* @return {HTMLCanvasElement} Returns the source canvas.
|
||||
*/
|
||||
setImageRenderingCrisp: function (canvas) {
|
||||
|
||||
Reference in New Issue
Block a user