The 2D layer · function
unpackRgba
A packed 0xRRGGBBAA token as the four floats a node's background and tint are.
Explained in Sprites and tilemaps.
function unpackRgba(packed: number, out: Float32Array): Float32Arrayimport { unpackRgba } from '@driftengine/ui2d';Parameters
| Parameter | Type | Description |
|---|---|---|
packed | number | |
out | Float32Array |
In depth
Two of this package's own APIs did not meet: a theme token is one number and a UiNode
colour is a Float32Array, so every consumer wrote the same four shifts. The editor found it by
being the first thing to build widgets on both, which is what a consumer outside packages/ is
for.
>>> rather than >>, because a token with red at or above 0x80 has the sign bit set and an
arithmetic shift returns it negative — a red that turns the whole colour into a large negative
number, which is exactly the shape of bug that survives review.