diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 6778133..7ef7b99 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -235,7 +235,7 @@ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) { // TODO is this needed... - //this.blendModeManager.setBlendMode(CONST.blendModes.NORMAL); + //this.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL); this.setRenderTarget(renderTarget); // start the filter manager @@ -314,17 +314,17 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); if (texture.mipmap && texture.isPowerOfTwo) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); } else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); } if (!texture.isPowerOfTwo) @@ -436,22 +436,22 @@ { this.blendModes = {}; - this.blendModes[CONST.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - this.blendModes[CONST.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - this.blendModes[CONST.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } }; diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 6778133..7ef7b99 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -235,7 +235,7 @@ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) { // TODO is this needed... - //this.blendModeManager.setBlendMode(CONST.blendModes.NORMAL); + //this.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL); this.setRenderTarget(renderTarget); // start the filter manager @@ -314,17 +314,17 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); if (texture.mipmap && texture.isPowerOfTwo) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); } else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); } if (!texture.isPowerOfTwo) @@ -436,22 +436,22 @@ { this.blendModes = {}; - this.blendModes[CONST.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - this.blendModes[CONST.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - this.blendModes[CONST.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index cc613b2..83e427f 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -456,8 +456,8 @@ { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 6778133..7ef7b99 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -235,7 +235,7 @@ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) { // TODO is this needed... - //this.blendModeManager.setBlendMode(CONST.blendModes.NORMAL); + //this.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL); this.setRenderTarget(renderTarget); // start the filter manager @@ -314,17 +314,17 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); if (texture.mipmap && texture.isPowerOfTwo) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); } else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); } if (!texture.isPowerOfTwo) @@ -436,22 +436,22 @@ { this.blendModes = {}; - this.blendModes[CONST.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - this.blendModes[CONST.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - this.blendModes[CONST.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index cc613b2..83e427f 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -456,8 +456,8 @@ { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index e36764e..deda715 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -68,7 +68,7 @@ * @property scaleMode * @type Number */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; this.root = root; @@ -87,8 +87,8 @@ gl.bindTexture(gl.TEXTURE_2D, this.texture); // set the scale properties of the texture.. - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); // check to see if the texture is a power of two! var isPowerOfTwo = utils.isPowerOfTwo(width, height); diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 6778133..7ef7b99 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -235,7 +235,7 @@ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) { // TODO is this needed... - //this.blendModeManager.setBlendMode(CONST.blendModes.NORMAL); + //this.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL); this.setRenderTarget(renderTarget); // start the filter manager @@ -314,17 +314,17 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); if (texture.mipmap && texture.isPowerOfTwo) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); } else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); } if (!texture.isPowerOfTwo) @@ -436,22 +436,22 @@ { this.blendModes = {}; - this.blendModes[CONST.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - this.blendModes[CONST.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - this.blendModes[CONST.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index cc613b2..83e427f 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -456,8 +456,8 @@ { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index e36764e..deda715 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -68,7 +68,7 @@ * @property scaleMode * @type Number */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; this.root = root; @@ -87,8 +87,8 @@ gl.bindTexture(gl.TEXTURE_2D, this.texture); // set the scale properties of the texture.. - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); // check to see if the texture is a power of two! var isPowerOfTwo = utils.isPowerOfTwo(width, height); diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 3e86965..ffa12c8 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -66,12 +66,12 @@ this.tint = 0xFFFFFF; /** - * The blend mode to be applied to the sprite. Set to CONST.blendModes.NORMAL to remove any blend mode. + * The blend mode to be applied to the sprite. Set to CONST.BLEND_MODES.NORMAL to remove any blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * The shader that will be used to render the sprite. Set to null to remove a current shader. @@ -339,7 +339,7 @@ if (renderer.smoothProperty && renderer.currentScaleMode !== this.texture.baseTexture.scaleMode) { renderer.currentScaleMode = this.texture.baseTexture.scaleMode; - renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.scaleModes.LINEAR); + renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.SCALE_MODES.LINEAR); } // If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 6778133..7ef7b99 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -235,7 +235,7 @@ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) { // TODO is this needed... - //this.blendModeManager.setBlendMode(CONST.blendModes.NORMAL); + //this.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL); this.setRenderTarget(renderTarget); // start the filter manager @@ -314,17 +314,17 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); if (texture.mipmap && texture.isPowerOfTwo) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); } else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); } if (!texture.isPowerOfTwo) @@ -436,22 +436,22 @@ { this.blendModes = {}; - this.blendModes[CONST.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - this.blendModes[CONST.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - this.blendModes[CONST.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index cc613b2..83e427f 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -456,8 +456,8 @@ { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index e36764e..deda715 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -68,7 +68,7 @@ * @property scaleMode * @type Number */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; this.root = root; @@ -87,8 +87,8 @@ gl.bindTexture(gl.TEXTURE_2D, this.texture); // set the scale properties of the texture.. - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); // check to see if the texture is a power of two! var isPowerOfTwo = utils.isPowerOfTwo(width, height); diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 3e86965..ffa12c8 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -66,12 +66,12 @@ this.tint = 0xFFFFFF; /** - * The blend mode to be applied to the sprite. Set to CONST.blendModes.NORMAL to remove any blend mode. + * The blend mode to be applied to the sprite. Set to CONST.BLEND_MODES.NORMAL to remove any blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * The shader that will be used to render the sprite. Set to null to remove a current shader. @@ -339,7 +339,7 @@ if (renderer.smoothProperty && renderer.currentScaleMode !== this.texture.baseTexture.scaleMode) { renderer.currentScaleMode = this.texture.baseTexture.scaleMode; - renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.scaleModes.LINEAR); + renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.SCALE_MODES.LINEAR); } // If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 6f711a7..017790b 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -8,7 +8,7 @@ * @mixes eventTarget * @namespace PIXI * @param source {Image|Canvas} the source object of the texture. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values */ function BaseTexture(source, scaleMode) { @@ -43,7 +43,7 @@ * @member {{number}} * @default scaleModes.LINEAR */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; /** * Set to true once the base texture has successfully loaded. @@ -341,7 +341,7 @@ * @static * @param imageUrl {string} The image url of the texture * @param [crossorigin=(auto)] {boolean} Should use anonymouse CORS? Defaults to true if the URL is not a data-URI. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values * @return BaseTexture */ BaseTexture.fromImage = function (imageUrl, crossorigin, scaleMode) diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 6778133..7ef7b99 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -235,7 +235,7 @@ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) { // TODO is this needed... - //this.blendModeManager.setBlendMode(CONST.blendModes.NORMAL); + //this.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL); this.setRenderTarget(renderTarget); // start the filter manager @@ -314,17 +314,17 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); if (texture.mipmap && texture.isPowerOfTwo) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); } else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); } if (!texture.isPowerOfTwo) @@ -436,22 +436,22 @@ { this.blendModes = {}; - this.blendModes[CONST.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - this.blendModes[CONST.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - this.blendModes[CONST.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index cc613b2..83e427f 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -456,8 +456,8 @@ { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index e36764e..deda715 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -68,7 +68,7 @@ * @property scaleMode * @type Number */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; this.root = root; @@ -87,8 +87,8 @@ gl.bindTexture(gl.TEXTURE_2D, this.texture); // set the scale properties of the texture.. - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); // check to see if the texture is a power of two! var isPowerOfTwo = utils.isPowerOfTwo(width, height); diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 3e86965..ffa12c8 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -66,12 +66,12 @@ this.tint = 0xFFFFFF; /** - * The blend mode to be applied to the sprite. Set to CONST.blendModes.NORMAL to remove any blend mode. + * The blend mode to be applied to the sprite. Set to CONST.BLEND_MODES.NORMAL to remove any blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * The shader that will be used to render the sprite. Set to null to remove a current shader. @@ -339,7 +339,7 @@ if (renderer.smoothProperty && renderer.currentScaleMode !== this.texture.baseTexture.scaleMode) { renderer.currentScaleMode = this.texture.baseTexture.scaleMode; - renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.scaleModes.LINEAR); + renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.SCALE_MODES.LINEAR); } // If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 6f711a7..017790b 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -8,7 +8,7 @@ * @mixes eventTarget * @namespace PIXI * @param source {Image|Canvas} the source object of the texture. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values */ function BaseTexture(source, scaleMode) { @@ -43,7 +43,7 @@ * @member {{number}} * @default scaleModes.LINEAR */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; /** * Set to true once the base texture has successfully loaded. @@ -341,7 +341,7 @@ * @static * @param imageUrl {string} The image url of the texture * @param [crossorigin=(auto)] {boolean} Should use anonymouse CORS? Defaults to true if the URL is not a data-URI. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values * @return BaseTexture */ BaseTexture.fromImage = function (imageUrl, crossorigin, scaleMode) diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index a8db4a6..1a62ba9 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -43,7 +43,7 @@ * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used for this RenderTexture * @param [width=100] {number} The width of the render texture * @param [height=100] {number} The height of the render texture - * @param [scaleMode] {number} See {@link scaleModes} for possible values + * @param [scaleMode] {number} See {@link SCALE_MODES} for possible values * @param [resolution=1] {number} The resolution of the texture being generated */ function RenderTexture(renderer, width, height, scaleMode, resolution) @@ -66,7 +66,7 @@ baseTexture.width = width * resolution; baseTexture.height = height * resolution; baseTexture.resolution = resolution; - baseTexture.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + baseTexture.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; baseTexture.hasLoaded = true; diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 6778133..7ef7b99 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -235,7 +235,7 @@ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) { // TODO is this needed... - //this.blendModeManager.setBlendMode(CONST.blendModes.NORMAL); + //this.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL); this.setRenderTarget(renderTarget); // start the filter manager @@ -314,17 +314,17 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); if (texture.mipmap && texture.isPowerOfTwo) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); } else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); } if (!texture.isPowerOfTwo) @@ -436,22 +436,22 @@ { this.blendModes = {}; - this.blendModes[CONST.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - this.blendModes[CONST.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - this.blendModes[CONST.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index cc613b2..83e427f 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -456,8 +456,8 @@ { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index e36764e..deda715 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -68,7 +68,7 @@ * @property scaleMode * @type Number */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; this.root = root; @@ -87,8 +87,8 @@ gl.bindTexture(gl.TEXTURE_2D, this.texture); // set the scale properties of the texture.. - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); // check to see if the texture is a power of two! var isPowerOfTwo = utils.isPowerOfTwo(width, height); diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 3e86965..ffa12c8 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -66,12 +66,12 @@ this.tint = 0xFFFFFF; /** - * The blend mode to be applied to the sprite. Set to CONST.blendModes.NORMAL to remove any blend mode. + * The blend mode to be applied to the sprite. Set to CONST.BLEND_MODES.NORMAL to remove any blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * The shader that will be used to render the sprite. Set to null to remove a current shader. @@ -339,7 +339,7 @@ if (renderer.smoothProperty && renderer.currentScaleMode !== this.texture.baseTexture.scaleMode) { renderer.currentScaleMode = this.texture.baseTexture.scaleMode; - renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.scaleModes.LINEAR); + renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.SCALE_MODES.LINEAR); } // If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 6f711a7..017790b 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -8,7 +8,7 @@ * @mixes eventTarget * @namespace PIXI * @param source {Image|Canvas} the source object of the texture. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values */ function BaseTexture(source, scaleMode) { @@ -43,7 +43,7 @@ * @member {{number}} * @default scaleModes.LINEAR */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; /** * Set to true once the base texture has successfully loaded. @@ -341,7 +341,7 @@ * @static * @param imageUrl {string} The image url of the texture * @param [crossorigin=(auto)] {boolean} Should use anonymouse CORS? Defaults to true if the URL is not a data-URI. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values * @return BaseTexture */ BaseTexture.fromImage = function (imageUrl, crossorigin, scaleMode) diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index a8db4a6..1a62ba9 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -43,7 +43,7 @@ * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used for this RenderTexture * @param [width=100] {number} The width of the render texture * @param [height=100] {number} The height of the render texture - * @param [scaleMode] {number} See {@link scaleModes} for possible values + * @param [scaleMode] {number} See {@link SCALE_MODES} for possible values * @param [resolution=1] {number} The resolution of the texture being generated */ function RenderTexture(renderer, width, height, scaleMode, resolution) @@ -66,7 +66,7 @@ baseTexture.width = width * resolution; baseTexture.height = height * resolution; baseTexture.resolution = resolution; - baseTexture.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + baseTexture.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; baseTexture.hasLoaded = true; diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 74f3889..f6b72c7 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -10,7 +10,7 @@ * @extends BaseTexture * @namespace PIXI * @param source {HTMLVideoElement} - * @param [scaleMode] {number} See {@link scaleModes} for possible values + * @param [scaleMode] {number} See {@link SCALE_MODES} for possible values */ function VideoBaseTexture(source, scaleMode) { @@ -116,7 +116,7 @@ * * @static * @param video {HTMLVideoElement} - * @param scaleMode {number} See {@link scaleModes} for possible values + * @param scaleMode {number} See {@link SCALE_MODES} for possible values * @return {VideoBaseTexture} */ VideoBaseTexture.fromVideo = function (video, scaleMode) @@ -161,7 +161,7 @@ * @param [videoSrc.src] {string} One of the source urls for the video * @param [videoSrc.mime] {string} The mimetype of the video (e.g. 'video/mp4'). If not specified * the url's extension will be used as the second part of the mime type. - * @param scaleMode {number} See {@link scaleModes} for possible values + * @param scaleMode {number} See {@link SCALE_MODES} for possible values * @return {VideoBaseTexture} */ VideoBaseTexture.fromUrl = function (videoSrc, scaleMode) diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 6778133..7ef7b99 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -235,7 +235,7 @@ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) { // TODO is this needed... - //this.blendModeManager.setBlendMode(CONST.blendModes.NORMAL); + //this.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL); this.setRenderTarget(renderTarget); // start the filter manager @@ -314,17 +314,17 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); if (texture.mipmap && texture.isPowerOfTwo) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); } else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); } if (!texture.isPowerOfTwo) @@ -436,22 +436,22 @@ { this.blendModes = {}; - this.blendModes[CONST.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - this.blendModes[CONST.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - this.blendModes[CONST.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index cc613b2..83e427f 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -456,8 +456,8 @@ { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index e36764e..deda715 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -68,7 +68,7 @@ * @property scaleMode * @type Number */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; this.root = root; @@ -87,8 +87,8 @@ gl.bindTexture(gl.TEXTURE_2D, this.texture); // set the scale properties of the texture.. - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); // check to see if the texture is a power of two! var isPowerOfTwo = utils.isPowerOfTwo(width, height); diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 3e86965..ffa12c8 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -66,12 +66,12 @@ this.tint = 0xFFFFFF; /** - * The blend mode to be applied to the sprite. Set to CONST.blendModes.NORMAL to remove any blend mode. + * The blend mode to be applied to the sprite. Set to CONST.BLEND_MODES.NORMAL to remove any blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * The shader that will be used to render the sprite. Set to null to remove a current shader. @@ -339,7 +339,7 @@ if (renderer.smoothProperty && renderer.currentScaleMode !== this.texture.baseTexture.scaleMode) { renderer.currentScaleMode = this.texture.baseTexture.scaleMode; - renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.scaleModes.LINEAR); + renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.SCALE_MODES.LINEAR); } // If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 6f711a7..017790b 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -8,7 +8,7 @@ * @mixes eventTarget * @namespace PIXI * @param source {Image|Canvas} the source object of the texture. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values */ function BaseTexture(source, scaleMode) { @@ -43,7 +43,7 @@ * @member {{number}} * @default scaleModes.LINEAR */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; /** * Set to true once the base texture has successfully loaded. @@ -341,7 +341,7 @@ * @static * @param imageUrl {string} The image url of the texture * @param [crossorigin=(auto)] {boolean} Should use anonymouse CORS? Defaults to true if the URL is not a data-URI. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values * @return BaseTexture */ BaseTexture.fromImage = function (imageUrl, crossorigin, scaleMode) diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index a8db4a6..1a62ba9 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -43,7 +43,7 @@ * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used for this RenderTexture * @param [width=100] {number} The width of the render texture * @param [height=100] {number} The height of the render texture - * @param [scaleMode] {number} See {@link scaleModes} for possible values + * @param [scaleMode] {number} See {@link SCALE_MODES} for possible values * @param [resolution=1] {number} The resolution of the texture being generated */ function RenderTexture(renderer, width, height, scaleMode, resolution) @@ -66,7 +66,7 @@ baseTexture.width = width * resolution; baseTexture.height = height * resolution; baseTexture.resolution = resolution; - baseTexture.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + baseTexture.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; baseTexture.hasLoaded = true; diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 74f3889..f6b72c7 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -10,7 +10,7 @@ * @extends BaseTexture * @namespace PIXI * @param source {HTMLVideoElement} - * @param [scaleMode] {number} See {@link scaleModes} for possible values + * @param [scaleMode] {number} See {@link SCALE_MODES} for possible values */ function VideoBaseTexture(source, scaleMode) { @@ -116,7 +116,7 @@ * * @static * @param video {HTMLVideoElement} - * @param scaleMode {number} See {@link scaleModes} for possible values + * @param scaleMode {number} See {@link SCALE_MODES} for possible values * @return {VideoBaseTexture} */ VideoBaseTexture.fromVideo = function (video, scaleMode) @@ -161,7 +161,7 @@ * @param [videoSrc.src] {string} One of the source urls for the video * @param [videoSrc.mime] {string} The mimetype of the video (e.g. 'video/mp4'). If not specified * the url's extension will be used as the second part of the mime type. - * @param scaleMode {number} See {@link scaleModes} for possible values + * @param scaleMode {number} See {@link SCALE_MODES} for possible values * @return {VideoBaseTexture} */ VideoBaseTexture.fromUrl = function (videoSrc, scaleMode) diff --git a/src/extras/Strip.js b/src/extras/Strip.js index 7bbe85b..a6fa179 100644 --- a/src/extras/Strip.js +++ b/src/extras/Strip.js @@ -47,9 +47,9 @@ * The blend mode to be applied to the sprite. Set to blendModes.NORMAL to remove any blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = core.CONST.blendModes.NORMAL; + this.blendMode = core.CONST.BLEND_MODES.NORMAL; /** * Triangles in canvas mode are automatically antialiased, use this value to force triangles to overlap a bit with each other. diff --git a/src/core/const.js b/src/core/const.js index f10a252..dfb714c 100644 --- a/src/core/const.js +++ b/src/core/const.js @@ -36,26 +36,26 @@ * * @static * @constant - * @property {object} blendModes - * @property {number} blendModes.NORMAL - * @property {number} blendModes.ADD - * @property {number} blendModes.MULTIPLY - * @property {number} blendModes.SCREEN - * @property {number} blendModes.OVERLAY - * @property {number} blendModes.DARKEN - * @property {number} blendModes.LIGHTEN - * @property {number} blendModes.COLOR_DODGE - * @property {number} blendModes.COLOR_BURN - * @property {number} blendModes.HARD_LIGHT - * @property {number} blendModes.SOFT_LIGHT - * @property {number} blendModes.DIFFERENCE - * @property {number} blendModes.EXCLUSION - * @property {number} blendModes.HUE - * @property {number} blendModes.SATURATION - * @property {number} blendModes.COLOR - * @property {number} blendModes.LUMINOSITY + * @property {object} BLEND_MODES + * @property {number} BLEND_MODES.NORMAL + * @property {number} BLEND_MODES.ADD + * @property {number} BLEND_MODES.MULTIPLY + * @property {number} BLEND_MODES.SCREEN + * @property {number} BLEND_MODES.OVERLAY + * @property {number} BLEND_MODES.DARKEN + * @property {number} BLEND_MODES.LIGHTEN + * @property {number} BLEND_MODES.COLOR_DODGE + * @property {number} BLEND_MODES.COLOR_BURN + * @property {number} BLEND_MODES.HARD_LIGHT + * @property {number} BLEND_MODES.SOFT_LIGHT + * @property {number} BLEND_MODES.DIFFERENCE + * @property {number} BLEND_MODES.EXCLUSION + * @property {number} BLEND_MODES.HUE + * @property {number} BLEND_MODES.SATURATION + * @property {number} BLEND_MODES.COLOR + * @property {number} BLEND_MODES.LUMINOSITY */ - blendModes: { + BLEND_MODES: { NORMAL: 0, ADD: 1, MULTIPLY: 2, @@ -83,12 +83,12 @@ * * @static * @constant - * @property {object} scaleModes - * @property {number} scaleModes.DEFAULT=LINEAR - * @property {number} scaleModes.LINEAR Smooth scaling - * @property {number} scaleModes.NEAREST Pixelating scaling + * @property {object} SCALE_MODES + * @property {number} SCALE_MODES.DEFAULT=LINEAR + * @property {number} SCALE_MODES.LINEAR Smooth scaling + * @property {number} SCALE_MODES.NEAREST Pixelating scaling */ - scaleModes: { + SCALE_MODES: { DEFAULT: 0, LINEAR: 0, NEAREST: 1 @@ -109,17 +109,17 @@ * * @static * @constant - * @property {object} defaultRenderOptions - * @property {HTMLCanvasElement} defaultRenderOptions.view=null - * @property {boolean} defaultRenderOptions.transparent=false - * @property {boolean} defaultRenderOptions.antialias=false - * @property {boolean} defaultRenderOptions.preserveDrawingBuffer=false - * @property {number} defaultRenderOptions.resolution=1 - * @property {number} defaultRenderOptions.backgroundColor=0x000000 - * @property {boolean} defaultRenderOptions.clearBeforeRender=true - * @property {boolean} defaultRenderOptions.autoResize=false + * @property {object} DEFAULT_RENDER_OPTIONS + * @property {HTMLCanvasElement} DEFAULT_RENDER_OPTIONS.view=null + * @property {boolean} DEFAULT_RENDER_OPTIONS.transparent=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.antialias=false + * @property {boolean} DEFAULT_RENDER_OPTIONS.preserveDrawingBuffer=false + * @property {number} DEFAULT_RENDER_OPTIONS.resolution=1 + * @property {number} DEFAULT_RENDER_OPTIONS.backgroundColor=0x000000 + * @property {boolean} DEFAULT_RENDER_OPTIONS.clearBeforeRender=true + * @property {boolean} DEFAULT_RENDER_OPTIONS.autoResize=false */ - defaultRenderOptions: { + DEFAULT_RENDER_OPTIONS: { view: null, resolution: 1, antialias: false, diff --git a/src/core/display/Container.js b/src/core/display/Container.js index 0b5a967..02eebb9 100644 --- a/src/core/display/Container.js +++ b/src/core/display/Container.js @@ -284,7 +284,7 @@ * This can be quite useful if your displayObject is static / complicated and needs to be reused multiple times. * * @param resolution {Number} The resolution of the texture being generated - * @param scaleMode {Number} See {{#crossLink "PIXI/scaleModes:property"}}PIXI.scaleModes{{/crossLink}} for possible values + * @param scaleMode {Number} See {@link SCALE_MODES} for possible values * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used to generate the texture. * @return {Texture} a texture of the graphics object */ diff --git a/src/core/graphics/Graphics.js b/src/core/graphics/Graphics.js index 97ddda1..d590729 100644 --- a/src/core/graphics/Graphics.js +++ b/src/core/graphics/Graphics.js @@ -64,9 +64,9 @@ * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * Current path diff --git a/src/core/renderers/SystemRenderer.js b/src/core/renderers/SystemRenderer.js index 7013641..5b1ec63 100644 --- a/src/core/renderers/SystemRenderer.js +++ b/src/core/renderers/SystemRenderer.js @@ -27,17 +27,17 @@ // prepare options if (options) { - for (var i in CONST.defaultRenderOptions) + for (var i in CONST.DEFAULT_RENDER_OPTIONS) { if (typeof options[i] === 'undefined') { - options[i] = CONST.defaultRenderOptions[i]; + options[i] = CONST.DEFAULT_RENDER_OPTIONS[i]; } } } else { - options = CONST.defaultRenderOptions; + options = CONST.DEFAULT_RENDER_OPTIONS; } /** diff --git a/src/core/renderers/canvas/CanvasRenderer.js b/src/core/renderers/canvas/CanvasRenderer.js index 2fea16b..4458ad5 100644 --- a/src/core/renderers/canvas/CanvasRenderer.js +++ b/src/core/renderers/canvas/CanvasRenderer.js @@ -61,14 +61,14 @@ * * @member {CONST.SCALE_MODE} */ - this.currentScaleMode = CONST.scaleModes.DEFAULT; + this.currentScaleMode = CONST.SCALE_MODES.DEFAULT; /** * Tracks the active blend mode for this renderer. * * @member {CONST.SCALE_MODE} */ - this.currentBlendMode = CONST.blendModes.NORMAL; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; /** * The canvas property used to set the canvas smoothing property. @@ -137,8 +137,8 @@ this.context.globalAlpha = 1; - this.currentBlendMode = CONST.blendModes.NORMAL; - this.context.globalCompositeOperation = this.blendModes[CONST.blendModes.NORMAL]; + this.currentBlendMode = CONST.BLEND_MODES.NORMAL; + this.context.globalCompositeOperation = this.blendModes[CONST.BLEND_MODES.NORMAL]; if (navigator.isCocoonJS && this.view.screencanvas) { @@ -215,44 +215,44 @@ if (utils.canUseNewCanvasBlendModes()) { - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'multiply'; - this.blendModes[CONST.blendModes.SCREEN] = 'screen'; - this.blendModes[CONST.blendModes.OVERLAY] = 'overlay'; - this.blendModes[CONST.blendModes.DARKEN] = 'darken'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'lighten'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'color-dodge'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'color-burn'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'hard-light'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'soft-light'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'difference'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'exclusion'; - this.blendModes[CONST.blendModes.HUE] = 'hue'; - this.blendModes[CONST.blendModes.SATURATION] = 'saturation'; - this.blendModes[CONST.blendModes.COLOR] = 'color'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'luminosity'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'multiply'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'screen'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'overlay'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'darken'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'lighten'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'color-dodge'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'color-burn'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'hard-light'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'soft-light'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'difference'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'exclusion'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'hue'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'saturation'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'color'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'luminosity'; } else { // this means that the browser does not support the cool new blend modes in canvas 'cough' ie 'cough' - this.blendModes[CONST.blendModes.NORMAL] = 'source-over'; - this.blendModes[CONST.blendModes.ADD] = 'lighter'; //IS THIS OK??? - this.blendModes[CONST.blendModes.MULTIPLY] = 'source-over'; - this.blendModes[CONST.blendModes.SCREEN] = 'source-over'; - this.blendModes[CONST.blendModes.OVERLAY] = 'source-over'; - this.blendModes[CONST.blendModes.DARKEN] = 'source-over'; - this.blendModes[CONST.blendModes.LIGHTEN] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_DODGE] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR_BURN] = 'source-over'; - this.blendModes[CONST.blendModes.HARD_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = 'source-over'; - this.blendModes[CONST.blendModes.DIFFERENCE] = 'source-over'; - this.blendModes[CONST.blendModes.EXCLUSION] = 'source-over'; - this.blendModes[CONST.blendModes.HUE] = 'source-over'; - this.blendModes[CONST.blendModes.SATURATION] = 'source-over'; - this.blendModes[CONST.blendModes.COLOR] = 'source-over'; - this.blendModes[CONST.blendModes.LUMINOSITY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.NORMAL] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.ADD] = 'lighter'; //IS THIS OK??? + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SCREEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DARKEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.HUE] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.SATURATION] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.COLOR] = 'source-over'; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = 'source-over'; } } }; diff --git a/src/core/renderers/webgl/WebGLRenderer.js b/src/core/renderers/webgl/WebGLRenderer.js index 6778133..7ef7b99 100644 --- a/src/core/renderers/webgl/WebGLRenderer.js +++ b/src/core/renderers/webgl/WebGLRenderer.js @@ -235,7 +235,7 @@ WebGLRenderer.prototype.renderDisplayObject = function (displayObject, renderTarget)//projection, buffer) { // TODO is this needed... - //this.blendModeManager.setBlendMode(CONST.blendModes.NORMAL); + //this.blendModeManager.setBlendMode(CONST.BLEND_MODES.NORMAL); this.setRenderTarget(renderTarget); // start the filter manager @@ -314,17 +314,17 @@ gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultipliedAlpha); gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); if (texture.mipmap && texture.isPowerOfTwo) { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR_MIPMAP_LINEAR : gl.NEAREST_MIPMAP_NEAREST); gl.generateMipmap(gl.TEXTURE_2D); } else { - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); } if (!texture.isPowerOfTwo) @@ -436,22 +436,22 @@ { this.blendModes = {}; - this.blendModes[CONST.blendModes.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; - this.blendModes[CONST.blendModes.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; - this.blendModes[CONST.blendModes.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; - this.blendModes[CONST.blendModes.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.NORMAL] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.ADD] = [gl.SRC_ALPHA, gl.DST_ALPHA]; + this.blendModes[CONST.BLEND_MODES.MULTIPLY] = [gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SCREEN] = [gl.SRC_ALPHA, gl.ONE]; + this.blendModes[CONST.BLEND_MODES.OVERLAY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DARKEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LIGHTEN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_DODGE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR_BURN] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HARD_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SOFT_LIGHT] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.DIFFERENCE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.EXCLUSION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.HUE] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.SATURATION] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.COLOR] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; + this.blendModes[CONST.BLEND_MODES.LUMINOSITY] = [gl.ONE, gl.ONE_MINUS_SRC_ALPHA]; } }; diff --git a/src/core/renderers/webgl/shaders/Shader.js b/src/core/renderers/webgl/shaders/Shader.js index cc613b2..83e427f 100644 --- a/src/core/renderers/webgl/shaders/Shader.js +++ b/src/core/renderers/webgl/shaders/Shader.js @@ -456,8 +456,8 @@ { gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texture.source); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, texture.scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); diff --git a/src/core/renderers/webgl/utils/RenderTarget.js b/src/core/renderers/webgl/utils/RenderTarget.js index e36764e..deda715 100644 --- a/src/core/renderers/webgl/utils/RenderTarget.js +++ b/src/core/renderers/webgl/utils/RenderTarget.js @@ -68,7 +68,7 @@ * @property scaleMode * @type Number */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; this.root = root; @@ -87,8 +87,8 @@ gl.bindTexture(gl.TEXTURE_2D, this.texture); // set the scale properties of the texture.. - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.scaleModes.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); + gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, scaleMode === CONST.SCALE_MODES.LINEAR ? gl.LINEAR : gl.NEAREST); // check to see if the texture is a power of two! var isPowerOfTwo = utils.isPowerOfTwo(width, height); diff --git a/src/core/sprites/Sprite.js b/src/core/sprites/Sprite.js index 3e86965..ffa12c8 100644 --- a/src/core/sprites/Sprite.js +++ b/src/core/sprites/Sprite.js @@ -66,12 +66,12 @@ this.tint = 0xFFFFFF; /** - * The blend mode to be applied to the sprite. Set to CONST.blendModes.NORMAL to remove any blend mode. + * The blend mode to be applied to the sprite. Set to CONST.BLEND_MODES.NORMAL to remove any blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = CONST.blendModes.NORMAL; + this.blendMode = CONST.BLEND_MODES.NORMAL; /** * The shader that will be used to render the sprite. Set to null to remove a current shader. @@ -339,7 +339,7 @@ if (renderer.smoothProperty && renderer.currentScaleMode !== this.texture.baseTexture.scaleMode) { renderer.currentScaleMode = this.texture.baseTexture.scaleMode; - renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.scaleModes.LINEAR); + renderer.context[renderer.smoothProperty] = (renderer.currentScaleMode === CONST.SCALE_MODES.LINEAR); } // If the texture is trimmed we offset by the trim x/y, otherwise we use the frame dimensions diff --git a/src/core/textures/BaseTexture.js b/src/core/textures/BaseTexture.js index 6f711a7..017790b 100644 --- a/src/core/textures/BaseTexture.js +++ b/src/core/textures/BaseTexture.js @@ -8,7 +8,7 @@ * @mixes eventTarget * @namespace PIXI * @param source {Image|Canvas} the source object of the texture. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values */ function BaseTexture(source, scaleMode) { @@ -43,7 +43,7 @@ * @member {{number}} * @default scaleModes.LINEAR */ - this.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + this.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; /** * Set to true once the base texture has successfully loaded. @@ -341,7 +341,7 @@ * @static * @param imageUrl {string} The image url of the texture * @param [crossorigin=(auto)] {boolean} Should use anonymouse CORS? Defaults to true if the URL is not a data-URI. - * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link scaleModes} for possible values + * @param [scaleMode=scaleModes.DEFAULT] {number} See {@link SCALE_MODES} for possible values * @return BaseTexture */ BaseTexture.fromImage = function (imageUrl, crossorigin, scaleMode) diff --git a/src/core/textures/RenderTexture.js b/src/core/textures/RenderTexture.js index a8db4a6..1a62ba9 100644 --- a/src/core/textures/RenderTexture.js +++ b/src/core/textures/RenderTexture.js @@ -43,7 +43,7 @@ * @param renderer {CanvasRenderer|WebGLRenderer} The renderer used for this RenderTexture * @param [width=100] {number} The width of the render texture * @param [height=100] {number} The height of the render texture - * @param [scaleMode] {number} See {@link scaleModes} for possible values + * @param [scaleMode] {number} See {@link SCALE_MODES} for possible values * @param [resolution=1] {number} The resolution of the texture being generated */ function RenderTexture(renderer, width, height, scaleMode, resolution) @@ -66,7 +66,7 @@ baseTexture.width = width * resolution; baseTexture.height = height * resolution; baseTexture.resolution = resolution; - baseTexture.scaleMode = scaleMode || CONST.scaleModes.DEFAULT; + baseTexture.scaleMode = scaleMode || CONST.SCALE_MODES.DEFAULT; baseTexture.hasLoaded = true; diff --git a/src/core/textures/VideoBaseTexture.js b/src/core/textures/VideoBaseTexture.js index 74f3889..f6b72c7 100644 --- a/src/core/textures/VideoBaseTexture.js +++ b/src/core/textures/VideoBaseTexture.js @@ -10,7 +10,7 @@ * @extends BaseTexture * @namespace PIXI * @param source {HTMLVideoElement} - * @param [scaleMode] {number} See {@link scaleModes} for possible values + * @param [scaleMode] {number} See {@link SCALE_MODES} for possible values */ function VideoBaseTexture(source, scaleMode) { @@ -116,7 +116,7 @@ * * @static * @param video {HTMLVideoElement} - * @param scaleMode {number} See {@link scaleModes} for possible values + * @param scaleMode {number} See {@link SCALE_MODES} for possible values * @return {VideoBaseTexture} */ VideoBaseTexture.fromVideo = function (video, scaleMode) @@ -161,7 +161,7 @@ * @param [videoSrc.src] {string} One of the source urls for the video * @param [videoSrc.mime] {string} The mimetype of the video (e.g. 'video/mp4'). If not specified * the url's extension will be used as the second part of the mime type. - * @param scaleMode {number} See {@link scaleModes} for possible values + * @param scaleMode {number} See {@link SCALE_MODES} for possible values * @return {VideoBaseTexture} */ VideoBaseTexture.fromUrl = function (videoSrc, scaleMode) diff --git a/src/extras/Strip.js b/src/extras/Strip.js index 7bbe85b..a6fa179 100644 --- a/src/extras/Strip.js +++ b/src/extras/Strip.js @@ -47,9 +47,9 @@ * The blend mode to be applied to the sprite. Set to blendModes.NORMAL to remove any blend mode. * * @member {number} - * @default CONST.blendModes.NORMAL; + * @default CONST.BLEND_MODES.NORMAL; */ - this.blendMode = core.CONST.blendModes.NORMAL; + this.blendMode = core.CONST.BLEND_MODES.NORMAL; /** * Triangles in canvas mode are automatically antialiased, use this value to force triangles to overlap a bit with each other. diff --git a/src/filters/bloom/BloomFilter.js b/src/filters/bloom/BloomFilter.js index b358d16..83a3c1a 100644 --- a/src/filters/bloom/BloomFilter.js +++ b/src/filters/bloom/BloomFilter.js @@ -33,11 +33,11 @@ this.blurXFilter.applyFilter(renderer, input, renderTarget); - renderer.blendModeManager.setBlendMode(core.CONST.blendModes.SCREEN); + renderer.blendModeManager.setBlendMode(core.CONST.BLEND_MODES.SCREEN); this.blurYFilter.applyFilter(renderer, renderTarget, output); - renderer.blendModeManager.setBlendMode(core.CONST.blendModes.NORMAL); + renderer.blendModeManager.setBlendMode(core.CONST.BLEND_MODES.NORMAL); renderer.filterManager.returnRenderTarget(renderTarget); };