Static
noA mapping used by default, which takes sprite colors as they are,
without any changes. An equivalent of BpxSpriteColorMapping.of((c, _x, _y) => c)
.
Static
fromCreates a simplified color mapping, based on a map of sprite colors to the new ones.
null
can be used to map a given sprite color into a transparency. It is useful e.g. when
we have a sprite with a black used as a background, so we can treat all black pixels as
transparent when drawing.
Static
ofCreates a color mapping which uses a function to map a sprite color into a new one.
The main method of this class, used to get a mapped color for a given color on the sprite.
Readonly
typeA property helpful for TypeScript type inference, when distinguishing from other types of colors.
const c:
| null
| BpxRgbColor
| BpxPatternColors
| BpxSpriteColorMapping
| BpxCanvasSnapshotColorMapping
= getColor();
if (c == null) {
// c is transparent here
} else if (c.type === "rgb") {
// c is BpxRgbColor here
} else if (c.type === "pattern") {
// c is BpxPatternColors here
} else if (c.type === "sprite_mapping") {
// c is BpxSpriteColorMapping here
} else if (c.type === "canvas_snapshot_mapping") {
// c is BpxCanvasSnapshotColorMapping here
} else {
$u.assertUnreachable(c);
}
See
BeetPxDraw.setSpriteColorMapping