MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / toRgb255

Function toRgb255

src/compute-engine/compilation/javascript-target.ts:1066–1094  ·  view source on GitHub ↗

* Normalize a color input to an `RgbColor` (0-255 channels). * * Strings are parsed as CSS colors; arrays are interpreted as Oklch * `[L, C, H]` (or `[L, C, H, alpha]`) — the canonical compiled-runtime * representation produced by `_SYS.color`, `_SYS.colorMix`, etc. Arrays * cross the sRGB gamu

(input: string | number[])

Source from the content-addressed store, hash-verified

1064 (a) => couldBeCollectionParticipant(a) || isPossiblyCollectionTypedJS(a)
1065 );
1066}
1067
1068/**
1069 * Whether binary collection equality can use `_SYS.eq` or `_SYS.neq`: every
1070 * participant must be a provably flat all-string value
1071 * (`isFlatAllStringComparisonParticipant`) and
1072 * at least one of which is a collection. It lowers to the `_SYS.eq`/`_SYS.neq`
1073 * dispatch, whose scalar leaf now compares two strings with `===` (see
1074 * `eqTensor`) — so both interpreter shapes come out right:
1075 * `Equal(["a","b"], ["a","b"])` is the whole-collection `True`, and
1076 * `Equal(["a","b"], "a")` the element-wise `[True, False]` (both probed).
1077 *
1078 * This mirrors the Python target's `_ce_eqcoll` admission. The deliberately
1079 * narrow predicate excludes a mixed
1080 * (`list<string | number>`) or NESTED all-string participant fails closed even
1081 * though the kernel was probed faithful on it, and a numeric participant
1082 * (`Equal(["a","b"], 1)`) fails closed under the tier-0 mixed ruling.
1083 */
1084function isStringCollectionEquality(args: ReadonlyArray<Expression>): boolean {
1085 return (
1086 args.length === 2 &&
1087 args.every(isFlatAllStringComparisonParticipant) &&
1088 args.some(
1089 (a) => couldBeCollectionParticipant(a) || isPossiblyCollectionTypedJS(a)
1090 )
1091 );
1092}
1093
1094/**
1095 * Fail closed when a comparison participant is an aggregate whose
1096 * whole-value comparison neither kernel can reproduce — a `dictionary`, a
1097 * `record`, or a `tuple` (`unfaithfulComparisonAggregate`).

Callers 7

colorToStringFunction · 0.85
colorContrastFunction · 0.85
contrastingColorFunction · 0.85
colorToColorspaceFunction · 0.85
asRgbFunction · 0.85
asHsvFunction · 0.85
asHslFunction · 0.85

Calls 1

normalizeAlphaFunction · 0.70

Tested by

no test coverage detected