UNPKG

pixi.js

Version:

<p align="center"> <a href="https://pixijs.com" target="_blank" rel="noopener noreferrer"> <img height="150" src="https://files.pixijs.download/branding/pixijs-logo-transparent-dark.svg?v=1" alt="PixiJS logo"> </a> </p> <br/> <p align="center">

69 lines (65 loc) 1.92 kB
'use strict'; var Extensions = require('../../../extensions/Extensions.js'); "use strict"; class ColorMaskPipe { constructor(renderer) { this._colorStack = []; this._colorStackIndex = 0; this._currentColor = 0; this._renderer = renderer; } buildStart() { this._colorStack[0] = 15; this._colorStackIndex = 1; this._currentColor = 15; } push(mask, _container, instructionSet) { const renderer = this._renderer; renderer.renderPipes.batch.break(instructionSet); const colorStack = this._colorStack; colorStack[this._colorStackIndex] = colorStack[this._colorStackIndex - 1] & mask.mask; const currentColor = this._colorStack[this._colorStackIndex]; if (currentColor !== this._currentColor) { this._currentColor = currentColor; instructionSet.add({ renderPipeId: "colorMask", colorMask: currentColor, canBundle: false }); } this._colorStackIndex++; } pop(_mask, _container, instructionSet) { const renderer = this._renderer; renderer.renderPipes.batch.break(instructionSet); const colorStack = this._colorStack; this._colorStackIndex--; const currentColor = colorStack[this._colorStackIndex - 1]; if (currentColor !== this._currentColor) { this._currentColor = currentColor; instructionSet.add({ renderPipeId: "colorMask", colorMask: currentColor, canBundle: false }); } } execute(instruction) { const renderer = this._renderer; renderer.colorMask.setMask(instruction.colorMask); } destroy() { this._colorStack = null; } } /** @ignore */ ColorMaskPipe.extension = { type: [ Extensions.ExtensionType.WebGLPipes, Extensions.ExtensionType.WebGPUPipes, Extensions.ExtensionType.CanvasPipes ], name: "colorMask" }; exports.ColorMaskPipe = ColorMaskPipe; //# sourceMappingURL=ColorMaskPipe.js.map