import type { Color, ColorLike } from './types'; export type { Color, ColorLike }; /** Create a Color (default RGBA = (0, 0, 0, 1) = opaque black). */ export declare function create(r?: number, g?: number, b?: number, a?: number): Color; /** Allocate a new Color copy. */ export declare function clone(c: ColorLike): Color; /** * out = sRGB → linear conversion (RGB channels only; alpha passed through). * * @degrade NaN propagation / negatives returned verbatim (HDR-friendly); alpha is strictly untouched. * * @example * ```ts * color.srgbToLinear(out, color.create(NaN, -0.1, 0.5, 0.8)); * // → out = (NaN, -0.1, ~0.214, 0.8); alpha 0.8 passed through unchanged. * ``` */ export declare function srgbToLinear(out: Color, c: ColorLike): Color; /** * out = linear → sRGB conversion (RGB channels only; alpha passed through). * * @degrade NaN propagation / negatives returned verbatim; alpha is strictly untouched. * * @example * ```ts * color.linearToSrgb(out, color.create(NaN, -0.05, 0.5, 1)); * // → out = (NaN, -0.05, ~0.735, 1); alpha is strictly untouched. * ``` */ export declare function linearToSrgb(out: Color, c: ColorLike): Color; /** Closed set of RGB colour spaces the engine converts between. Both share D65 and the sRGB transfer curve. */ export type RgbColorSpace = 'srgb' | 'display-p3'; /** CIE 1931 xy chromaticities of one RGB colour space. */ export interface RgbPrimaries { readonly red: readonly [number, number]; readonly green: readonly [number, number]; readonly blue: readonly [number, number]; readonly white: readonly [number, number]; } /** CIE 1931 xy of the D65 white point (IEC 61966-2-1 / SMPTE EG 432-1). */ export declare const D65_WHITE_XY: readonly [number, number]; /** * Primaries SSOT. Rec.709/sRGB per IEC 61966-2-1; Display P3 is DCI-P3 * primaries with the D65 white point (SMPTE EG 432-1). Every gamut matrix in * TS and the generated WGSL block derives from these numbers. */ export declare const RGB_PRIMARIES: Readonly>; /** Row-major 3x3 matrix in float64: `out = M * rgb`. */ export type RgbMatrix3 = readonly [ number, number, number, number, number, number, number, number, number ]; /** * Derive the linear RGB -> CIE XYZ matrix from xy primaries (SMPTE RP 177): * columns are the primaries' XYZ scaled so RGB (1, 1, 1) maps to the white * point with Y = 1. */ export declare function rgbToXyzMatrix(primaries: RgbPrimaries): RgbMatrix3; /** Linear RGB `from` -> linear RGB `to` (same white point, so no adaptation). */ export declare function rgbGamutMatrix(from: RgbColorSpace, to: RgbColorSpace): RgbMatrix3; /** Linear Rec.709/sRGB -> linear Display P3, derived from {@link RGB_PRIMARIES}. */ export declare const LINEAR_SRGB_TO_LINEAR_DISPLAY_P3: RgbMatrix3; /** Linear Display P3 -> linear Rec.709/sRGB; components outside sRGB become negative or > 1. */ export declare const LINEAR_DISPLAY_P3_TO_LINEAR_SRGB: RgbMatrix3; /** out = linear sRGB -> linear Display P3 (alpha passed through, no clamping). */ export declare function linearSrgbToLinearDisplayP3(out: Color, c: ColorLike): Color; /** out = linear Display P3 -> linear sRGB (alpha passed through; out-of-sRGB colours keep negatives). */ export declare function linearDisplayP3ToLinearSrgb(out: Color, c: ColorLike): Color; /** * out = CSS `color(display-p3 r g b)` (sRGB transfer curve, P3 primaries) -> * linear Rec.709 working colour. Colours outside sRGB keep negative components * so a Display-P3 output can reproduce them. */ export declare function displayP3ToLinear(out: Color, c: ColorLike): Color; /** * Write a Color from a hex string. * * Only supports the two forms `#RRGGBB` (7 chars) and `#RRGGBBAA` (9 chars) (D-P7); * the CSS-style `#RGB` / `#RGBA` short forms are not supported. * * @degrade Any illegal input (short form / non-hex chars / missing # / wrong length / empty string, * etc.) silently falls back to (0, 0, 0, 1); never throws (D-P12 / AC-06). * * @example * ```ts * color.fromHex(out, '#ff8000'); // → (1, ~0.216, 0, 1) * color.fromHex(out, '#ff800080'); // → (1, ~0.216, 0, 0.502) * color.fromHex(out, '#fff'); // → (0, 0, 0, 1) short form unsupported → silent fall-back * ``` */ export declare function fromHex(out: Color, hex: string): Color; /** * Write a Color from a deterministic CSS color string. * * Supports full and short hex, common named colors, rgb()/rgba() channel * numbers or percentages, and hsl()/hsla() with an optional alpha. RGB * channels are decoded to linear-sRGB; alpha is passed through unchanged. * Unsupported or malformed input silently falls back to opaque black. */ export declare function fromCss(out: Color, css: string): Color; /** * Serialize as hex string: alpha=1 → `#rrggbb`; alpha<1 → `#rrggbbaa`. * * @degrade Out-of-range components (HDR > 1 / negatives) are clamped to [0, 1] then rounded; * **truncated** rather than throwing (symmetric with fromHex's silent fall-back). NaN components → * literal '00' (same byte as 0.0; prevents the hex-string builder from throwing; alpha=NaN takes the * alpha=1 path, emitting the short `#rrggbb` form). * * @example * ```ts * color.toHex(color.create(2, -0.1, 0.5, 1)); // → '#ff00bc' (linear HDR/negative clamp) * color.toHex(color.create(1, 0, 0, 0.5)); // → '#ff000080' * color.toHex(color.create(NaN, 0, 0, NaN)); // → '#000000' (NaN→'00', alpha=NaN takes short form) * ``` */ export declare function toHex(c: ColorLike): string; //# sourceMappingURL=color.d.ts.map