PIXI.MaskSystem

class MaskSystem implements PIXI.ISystem

System plugin to the renderer to manage masks.

There are three built-in types of masking: Scissor Masking: Scissor masking discards pixels that are outside of a rectangle called the scissor box. It is the most performant as the scissor test is inexpensive. However, it can only be used when the mask is rectangular. Stencil Masking: Stencil masking discards pixels that don't overlap with the pixels rendered into the stencil buffer. It is the next fastest option as it does not require rendering into a separate framebuffer. However, it does cause the mask to be rendered twice for each masking operation; hence, minimize the rendering cost of your masks. Sprite Mask Filtering: Sprite mask filtering discards pixels based on the red channel of the sprite-mask's texture. (Generally, the masking texture is grayscale). Using advanced techniques, you might be able to embed this type of masking in a custom shader - and hence, bypassing the masking system fully for performance wins.

The best type of masking is auto-detected when you push one. To use scissor masking, you must pass in a Graphics object with just a rectangle drawn.

Mask Stacks

In the scene graph, masks can be applied recursively, i.e. a mask can be applied during a masking operation. The mask stack stores the currently applied masks in order. Each PIXI.BaseRenderTexture holds its own mask stack, i.e. when you switch render-textures, the old masks only applied when you switch back to rendering to the old render-target.

Constructor


new PIXI.MaskSystem(renderer: PIXI.Renderer) → {}
Parameters:
Name Type Description
renderer PIXI.Renderer

The renderer this System works for.

Summary


Properties from MaskSystem

boolean
enableScissor = true
number
protected alphaMaskIndex = 0
Array<PIXI.SpriteMaskFilter[]>
protected alphaMaskPool

Pool of used sprite mask filters.

Methods from MaskSystem

Public Properties


enableScissor MaskSystem.ts:34
enableScissor: boolean = true

Flag to enable scissor masking.

Protected Properties


alphaMaskIndex MaskSystem.ts:43
protected alphaMaskIndex: number = 0

Current index of alpha mask pool.

alphaMaskPool MaskSystem.ts:40
protected alphaMaskPool: Array<PIXI.SpriteMaskFilter[]>

Pool of used sprite mask filters.

Public Methods


detect MaskSystem.ts:202
detect(maskData: PIXI.MaskData) → {void}

Sets type of MaskData based on its maskObject.

Parameters:
Name Type Description
maskData PIXI.MaskData
Returns:
Type Description
void
pop MaskSystem.ts:146
pop(target: PIXI.IMaskTarget) → {void}

Removes the last mask from the mask stack and doesn't return it.

NOTE: The batch renderer should be flushed beforehand to render the masked contents before the mask is removed.

Parameters:
Name Type Description
target PIXI.IMaskTarget

Display Object to pop the mask from

Returns:
Type Description
void
popColorMask MaskSystem.ts:322
popColorMask(maskData: PIXI.MaskData) → {void}

Pops the color mask.

Parameters:
Name Type Description
maskData PIXI.MaskData

The mask data

Returns:
Type Description
void
popSpriteMask MaskSystem.ts:283
popSpriteMask(maskData: PIXI.MaskData) → {void}

Removes the last filter from the filter stack and doesn't return it.

Parameters:
Name Type Description
maskData PIXI.MaskData

Sprite to be used as the mask.

Returns:
Type Description
void
push MaskSystem.ts:81
push(target: PIXI.DisplayObject, maskDataOrTarget: PIXI.MaskData | PIXI.Sprite | PIXI.Graphics | PIXI.DisplayObject) → {void}

Enables the mask and appends it to the current mask stack.

NOTE: The batch renderer should be flushed beforehand to prevent pending renders from being masked.

Parameters:
Name Type Description
target PIXI.DisplayObject

Display Object to push the mask to

maskDataOrTarget PIXI.MaskData | PIXI.Sprite | PIXI.Graphics | PIXI.DisplayObject

The masking data.

Returns:
Type Description
void
pushColorMask MaskSystem.ts:302
pushColorMask(maskData: PIXI.MaskData) → {void}

Pushes the color mask.

Parameters:
Name Type Description
maskData PIXI.MaskData

The mask data

Returns:
Type Description
void
pushSpriteMask MaskSystem.ts:228
pushSpriteMask(maskData: PIXI.MaskData) → {void}

Applies the Mask and adds it to the current filter stack.

Parameters:
Name Type Description
maskData PIXI.MaskData

Sprite to be used as the mask.

Returns:
Type Description
void
setMaskStack MaskSystem.ts:70
setMaskStack(maskStack: Array<PIXI.MaskData>) → {void}

Changes the mask stack that is used by this System.

Parameters:
Name Type Description
maskStack Array<PIXI.MaskData>

The mask stack

Returns:
Type Description
void

Powered by webdoc!