A live, per-frame colour-matrix approximation of a blend towards color (0xRRGGBB) by
ratio, the same shape TintedSprite.lerpTint gives an additive-capable sprite, expressed
here as a plain matrix so a bare Pixi Sprite can use it too. This is not what
applyTextureModifiers uses for ~BLEND itself (that bakes an exact per-pixel blend once,
via blendPixels, rather than attaching a runtime filter) - kept as its own export for a
game that wants a cheap, adjustable-at-runtime approximation instead of a baked texture, the
tradeoff ~CS's colorShiftMatrix already makes for an additive shift.
Parameters
color: number
ratio: number
Returns ColorMatrix
Example
import { blendMatrix } from'@datamoc/mw_games/two-d/render'; constmatrix = blendMatrix(0xff0000, 0.5); // half-way to red
A live, per-frame colour-matrix approximation of a blend towards
color(0xRRGGBB) byratio, the same shapeTintedSprite.lerpTintgives an additive-capable sprite, expressed here as a plain matrix so a bare PixiSpritecan use it too. This is not whatapplyTextureModifiersuses for~BLENDitself (that bakes an exact per-pixel blend once, viablendPixels, rather than attaching a runtime filter) - kept as its own export for a game that wants a cheap, adjustable-at-runtime approximation instead of a baked texture, the tradeoff~CS'scolorShiftMatrixalready makes for an additive shift.