math.color ​Contract 2.0.0 · package sha256
a857eca95b35921109faf997094bb4192f12527d9d0fcd4be7e97f06425bad6e· generated frommath.d.tsbyservices/onsite-scripter/scripts/build-contract-docs.mjs; edit the source, not this file.
Const · import { color } from '@holostep-configurators/runtime-client/math'; · stable · since 2.0.0 · section 23. /math
sRGB hex colours and linear components.
| Member | Kind | Summary |
|---|---|---|
toLinear |
method | Linear Rec.709 components 0..1 of an sRGB hex colour. |
toHex |
method | The sRGB hex colour of linear components 0..1. |
parse |
method | Checks a string from your data: '#rgb' or '#rrggbb' (any case), returned as '#rrggbb'; null otherwise. |
export const color: {
toLinear(hex: HexColor): {
r: number;
g: number;
b: number;
};
toHex(linear: {
r: number;
g: number;
b: number;
}): HexColor;
parse(text: string): HexColor | null;
};
Imports: values (has, validate, the Holo*Error classes, the pure helpers) from @holostep-configurators/runtime-client, types from @holostep-configurators/runtime-client/contract, /math and /testing names from those entries; boot from the runtime module the root's loadRuntimeAtFloor resolves to. A type your page defines is your app's: declare it there, never import it from the package.
Compiled under the contract's strict settings (examples/declaration/23-color.ts):
import { color } from '@holostep-configurators/runtime-client/math';
import type { Session } from '@holostep-configurators/runtime-client/contract';
declare const session: Session;
declare const signal: AbortSignal;
declare const row: { colour: string }; // a string from your data, not a HexColor
const hex = color.parse(row.colour) ?? '#ffffff';
await session.find({ tag: 'frame' }).set({ material: { baseColor: hex } });
| Rule | Result |
|---|---|
| 1. Neutral name | pass: color names no product |
| 2. A precedent | not recorded: no ledger row (coverage.json) names this member or its owner |
| 3. Two apps, or labs | not recorded: no ledger row names this member or its owner |
| 4. The cheaper fix first | not recorded per member (Appendix B decides it per need) |