Merge pull request #4301 from tfelix/feat-invert-geo-mask

Adds invertAlpha flag to GeometryMask
This commit is contained in:
Richard Davey 2019-01-23 21:52:16 +00:00 committed by GitHub
commit 87a83d4ff8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,6 +36,16 @@ var GeometryMask = new Class({
* @since 3.0.0 * @since 3.0.0
*/ */
this.geometryMask = graphicsGeometry; this.geometryMask = graphicsGeometry;
/**
* Similiar to the BitmapMasks invertAlpha setting this to true will then hide all pixels
* drawn to the Geometry Mask.
*
* @name Phaser.Display.Masks.GeometryMask#invertAlpha
* @type {boolean}
* @since 3.16.0
*/
this.invertAlpha = false;
}, },
/** /**
@ -82,7 +92,16 @@ var GeometryMask = new Class({
// Use stencil buffer to affect next rendering object // Use stencil buffer to affect next rendering object
gl.colorMask(true, true, true, true); gl.colorMask(true, true, true, true);
if (this.invertAlpha)
{
gl.stencilFunc(gl.NOTEQUAL, 1, 1);
}
else
{
gl.stencilFunc(gl.EQUAL, 1, 1); gl.stencilFunc(gl.EQUAL, 1, 1);
}
gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
}, },