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">

64 lines (60 loc) 1.74 kB
'use strict'; var Extensions = require('../../../extensions/Extensions.js'); "use strict"; class CanvasColorMaskPipe { 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) { this._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) { this._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) { } destroy() { this._renderer = null; this._colorStack = null; } } /** @ignore */ CanvasColorMaskPipe.extension = { type: [ Extensions.ExtensionType.CanvasPipes ], name: "colorMask" }; exports.CanvasColorMaskPipe = CanvasColorMaskPipe; //# sourceMappingURL=CanvasColorMaskPipe.js.map