Class BpxPatternColors

A set of two colors, used in combination with BpxDrawingPattern, where given pixels are colored with either the primary or the secondary.

Static factories

Properties

Static factories

Properties

primary: null | BpxRgbColor

The primary color or a transparency (denoted by null).

secondary: null | BpxRgbColor

The secondary color or a transparency (denoted by null).

type: "pattern" = "pattern"

A 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);
}