hex is not always a native <input type="color"> value: it also arrives
from imported lens JSON (type-checked as a string, not format-validated)
and from the SDK's bim.viewer.colorize(), a published entry point any
external caller can pass an arbitrary string to. Both accept the 3-digit
CSS shorthand and the
8-digit #RRGGBBAA form, and neither is guaranteed well-formed. Rather
than let parseInt salvage whatever hex-looking prefix it can find in a
malformed string — which turns a typo like 'red' into a plausible-but-
wrong color instead of flagging it — the whole (post-shorthand-expansion,
post-alpha-trim) string is validated as exactly six hex digits before
parsing, and any input that fails that check, including the wrong length,
falls back to [0, 0, 0, alpha]. It does not throw: this is a published
SDK entry point and an unvalidated JSON import path, and a throw here
would crash the caller for one bad value instead of degrading a single
color.
Parameters
hex: string
Hex color (e.g. "#E53935", "E53935", the 3-digit "#E33", or
the 8-digit CSS #RRGGBBAA form — the trailing alpha pair is ignored
since alpha is supplied separately)
Parse hex color string to RGBA tuple (0–1 range).
hexis not always a native<input type="color">value: it also arrives from imported lens JSON (type-checked as a string, not format-validated) and from the SDK'sbim.viewer.colorize(), a published entry point any external caller can pass an arbitrary string to. Both accept the 3-digit CSS shorthand and the 8-digit#RRGGBBAAform, and neither is guaranteed well-formed. Rather than letparseIntsalvage whatever hex-looking prefix it can find in a malformed string — which turns a typo like'red'into a plausible-but- wrong color instead of flagging it — the whole (post-shorthand-expansion, post-alpha-trim) string is validated as exactly six hex digits before parsing, and any input that fails that check, including the wrong length, falls back to[0, 0, 0, alpha]. It does not throw: this is a published SDK entry point and an unvalidated JSON import path, and a throw here would crash the caller for one bad value instead of degrading a single color.