diff --git a/src/core/math/shapes/Rectangle.js b/src/core/math/shapes/Rectangle.js index 6fa9306..5c56091 100644 --- a/src/core/math/shapes/Rectangle.js +++ b/src/core/math/shapes/Rectangle.js @@ -118,23 +118,28 @@ if (this.x < rectangle.x) { this.width += this.x; + if(this.width < 0)this.width = 0; + this.x = rectangle.x; } if (this.y < rectangle.y) { this.height += this.y; + if(this.height < 0)this.height = 0; this.y = rectangle.y; } - if ( this.x + this.width > rectangle.width ) + if ( this.x + this.width > rectangle.x + rectangle.width ) { this.width = rectangle.width - this.x; + if(this.width < 0)this.width = 0; } - if ( this.y + this.height > rectangle.height ) + if ( this.y + this.height > rectangle.y + rectangle.height ) { this.height = rectangle.height - this.y; + if(this.height < 0)this.height = 0; } } diff --git a/src/core/math/shapes/Rectangle.js b/src/core/math/shapes/Rectangle.js index 6fa9306..5c56091 100644 --- a/src/core/math/shapes/Rectangle.js +++ b/src/core/math/shapes/Rectangle.js @@ -118,23 +118,28 @@ if (this.x < rectangle.x) { this.width += this.x; + if(this.width < 0)this.width = 0; + this.x = rectangle.x; } if (this.y < rectangle.y) { this.height += this.y; + if(this.height < 0)this.height = 0; this.y = rectangle.y; } - if ( this.x + this.width > rectangle.width ) + if ( this.x + this.width > rectangle.x + rectangle.width ) { this.width = rectangle.width - this.x; + if(this.width < 0)this.width = 0; } - if ( this.y + this.height > rectangle.height ) + if ( this.y + this.height > rectangle.y + rectangle.height ) { this.height = rectangle.height - this.y; + if(this.height < 0)this.height = 0; } } diff --git a/src/core/renderers/webgl/managers/MaskManager.js b/src/core/renderers/webgl/managers/MaskManager.js index 4c539ee..f82862d 100644 --- a/src/core/renderers/webgl/managers/MaskManager.js +++ b/src/core/renderers/webgl/managers/MaskManager.js @@ -12,7 +12,7 @@ this.scissor = false; - this.enableScissor = false; + this.enableScissor = true; this.alphaMaskPool = []; this.alphaMaskPool = []; @@ -152,13 +152,17 @@ MaskManager.prototype.pushScissorMask = function (target, maskData) { maskData.renderable = true; + + var renderTarget = this.renderer._activeRenderTarget; + var bounds = maskData.getBounds(); + bounds.fit(renderTarget.size) maskData.renderable = false; gl.enable(gl.SCISSOR_TEST); gl.scissor(bounds.x, - this.renderer._activeRenderTarget.root ? this.renderer._activeRenderTarget.size.height - bounds.y - bounds.height : bounds.y, + renderTarget.root ? renderTarget.size.height - bounds.y - bounds.height : bounds.y, bounds.width , bounds.height);