Static
fromStatic
ofChecks if this color has same red, green, and blue components as the other one.
Readonly
bA blue component, an integer between 0 and 255.
Readonly
cssA hex representation of this color. Can be used e.g. for CSS. Or just for simple way to store a color as a single value.
Readonly
gA green component, an integer between 0 and 255.
Readonly
rA red component, an integer between 0 and 255.
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);
}
A representation of a RGB, fully opaque color