diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 79b8c71..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,21 +41,6 @@ NEAREST:1 }; -// Canvas specific controls -PIXI.canvas = { - - // If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color. - // Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. - FILL_RECT: true, - - // If the Stage is transparent Pixi will use clearRect to clear the canvas every frame. - // Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. - CLEAR_RECT: true, - - // If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation. Handy for crisp pixel art and speed on legacy devices. - PX_ROUND: false -} - // interaction frequency PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 79b8c71..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,21 +41,6 @@ NEAREST:1 }; -// Canvas specific controls -PIXI.canvas = { - - // If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color. - // Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. - FILL_RECT: true, - - // If the Stage is transparent Pixi will use clearRect to clear the canvas every frame. - // Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. - CLEAR_RECT: true, - - // If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation. Handy for crisp pixel art and speed on legacy devices. - PX_ROUND: false -} - // interaction frequency PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index 1d06537..c95e127 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -345,7 +345,7 @@ // allow for trimming - if (PIXI.canvas.PX_ROUND) + if (renderSession.roundPixels) { context.setTransform(transform.a, transform.c, transform.b, transform.d, Math.floor(transform.tx), Math.floor(transform.ty)); } diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 79b8c71..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,21 +41,6 @@ NEAREST:1 }; -// Canvas specific controls -PIXI.canvas = { - - // If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color. - // Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. - FILL_RECT: true, - - // If the Stage is transparent Pixi will use clearRect to clear the canvas every frame. - // Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. - CLEAR_RECT: true, - - // If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation. Handy for crisp pixel art and speed on legacy devices. - PX_ROUND: false -} - // interaction frequency PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index 1d06537..c95e127 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -345,7 +345,7 @@ // allow for trimming - if (PIXI.canvas.PX_ROUND) + if (renderSession.roundPixels) { context.setTransform(transform.a, transform.c, transform.b, transform.d, Math.floor(transform.tx), Math.floor(transform.ty)); } diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index ed3b921..d23013f 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -91,7 +91,7 @@ // alow for trimming - if (PIXI.canvas.PX_ROUND) + if (renderSession.roundPixels) { context.setTransform(transform.a, transform.c, transform.b, transform.d, Math.floor(transform.tx), Math.floor(transform.ty)); } diff --git a/src/pixi/Pixi.js b/src/pixi/Pixi.js index 79b8c71..768ef4e 100644 --- a/src/pixi/Pixi.js +++ b/src/pixi/Pixi.js @@ -41,21 +41,6 @@ NEAREST:1 }; -// Canvas specific controls -PIXI.canvas = { - - // If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color. - // Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. - FILL_RECT: true, - - // If the Stage is transparent Pixi will use clearRect to clear the canvas every frame. - // Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. - CLEAR_RECT: true, - - // If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation. Handy for crisp pixel art and speed on legacy devices. - PX_ROUND: false -} - // interaction frequency PIXI.INTERACTION_FREQUENCY = 30; PIXI.AUTO_PREVENT_DEFAULT = true; \ No newline at end of file diff --git a/src/pixi/display/Sprite.js b/src/pixi/display/Sprite.js index 1d06537..c95e127 100644 --- a/src/pixi/display/Sprite.js +++ b/src/pixi/display/Sprite.js @@ -345,7 +345,7 @@ // allow for trimming - if (PIXI.canvas.PX_ROUND) + if (renderSession.roundPixels) { context.setTransform(transform.a, transform.c, transform.b, transform.d, Math.floor(transform.tx), Math.floor(transform.ty)); } diff --git a/src/pixi/display/SpriteBatch.js b/src/pixi/display/SpriteBatch.js index ed3b921..d23013f 100644 --- a/src/pixi/display/SpriteBatch.js +++ b/src/pixi/display/SpriteBatch.js @@ -91,7 +91,7 @@ // alow for trimming - if (PIXI.canvas.PX_ROUND) + if (renderSession.roundPixels) { context.setTransform(transform.a, transform.c, transform.b, transform.d, Math.floor(transform.tx), Math.floor(transform.ty)); } diff --git a/src/pixi/renderers/canvas/CanvasRenderer.js b/src/pixi/renderers/canvas/CanvasRenderer.js index 9c93ee6..cfaac27 100644 --- a/src/pixi/renderers/canvas/CanvasRenderer.js +++ b/src/pixi/renderers/canvas/CanvasRenderer.js @@ -19,6 +19,35 @@ this.type = PIXI.CANVAS_RENDERER; + /** + * If the Stage is NOT transparent Pixi will use a canvas sized fillRect operation every frame to set the canvas background color. + * Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. + * + * @property useFillRect + * @type Boolean + * @default + */ + this.useFillRect = true; + + /** + * If the Stage is transparent Pixi will use clearRect to clear the canvas every frame. + * Disable this by setting this to false. For example if your game has a canvas filling background image you often don't need this set. + * + * @property useClearRect + * @type Boolean + * @default + */ + this.useClearRect = true; + + /** + * If true Pixi will Math.floor() x/y values when rendering, stopping pixel interpolation. + * Handy for crisp pixel art and speed on legacy devices. + * + * @property roundPixels + * @type Boolean + * @default + */ + this.roundPixels = false; /** * Whether the render view is transparent @@ -165,12 +194,12 @@ this.context.setTransform(1,0,0,1,0,0); this.context.globalAlpha = 1; - if (!this.transparent && PIXI.canvas.FILL_RECT) + if (!this.transparent && this.useFillRect) { this.context.fillStyle = stage.backgroundColorString; this.context.fillRect(0, 0, this.width, this.height); } - else if (this.transparent && PIXI.canvas.CLEAR_RECT) + else if (this.transparent && this.useClearRect) { this.context.clearRect(0, 0, this.width, this.height); }