/** * Color conversion + parsing for `ColorEditor` / `ColorPicker`. * * Internally everything is HSV(A) (`Hsva`) so hue and saturation survive at the * extremes (black / white) where a hex round-trip would otherwise drop them. * Conversion to the public {@link ColorValue} (hex / rgb / hsl / hsb / css) * happens only on the way out. */ export type RGB = { r: number; g: number; b: number; a: number; }; export type HSL = { h: number; s: number; l: number; a: number; }; export type HSB = { h: number; s: number; b: number; a: number; }; /** Emitted color. Every channel set is self-contained (carries its own alpha). */ export type ColorValue = { /** `#rrggbb`, or `#rrggbbaa` when alpha < 1. */ hex: string; /** r,g,b 0–255 · a 0–1. */ rgb: RGB; /** h 0–360 · s,l 0–100 · a 0–1. */ hsl: HSL; /** h 0–360 · s,b 0–100 · a 0–1. */ hsb: HSB; /** Ready for `style={{ background }}` — `#rrggbb` when opaque, `rgba(...)` otherwise. */ css: string; }; /** Accepted by `value` / `defaultValue` — a CSS color string or any one channel set (alpha optional). */ export type ColorInput = string | { r: number; g: number; b: number; a?: number; } | { h: number; s: number; l: number; a?: number; } | { h: number; s: number; b: number; a?: number; }; export type GradientStop = { color: ColorValue; position: number; }; export type GradientValue = { type: 'linear'; /** Degrees, 0–360. */ angle: number; /** Two or more stops, sorted by `position` (0–100). */ stops: GradientStop[]; /** Ready for `style={{ background }}` — `linear-gradient(...)`. */ css: string; }; /** Solid value when gradient is enabled (tagged so it discriminates against {@link GradientValue}). */ export type SolidValue = ColorValue & { type: 'solid'; }; /** Union emitted by `ColorEditor` / `ColorPicker` when `gradient` is enabled. */ export type ColorEditorValue = SolidValue | GradientValue; export type GradientStopInput = { color: ColorInput; position: number; }; export type GradientInput = string | { type?: 'linear'; angle?: number; stops: GradientStopInput[]; }; /** Internal working color. h 0–360 · s,v 0–100 · a 0–1. */ export type Hsva = { h: number; s: number; v: number; a: number; }; export declare const BLACK: Hsva; export declare const hsvToRgb: ({ h, s, v, a }: Hsva) => RGB; export declare const rgbToHsv: ({ r, g, b, a }: RGB) => Hsva; export declare const hsvToHsl: ({ h, s, v, a }: Hsva) => HSL; export declare const hslToHsv: (h: number, s: number, l: number, a: number) => Hsva; export declare const buildColorValue: (hsva: Hsva) => ColorValue; /** Parse any {@link ColorInput} into the internal `Hsva`. Falls back to black. */ export declare const parseColor: (input: ColorInput | undefined | null) => Hsva; export declare const isGradientInput: (input: ColorInput | GradientInput | undefined | null) => input is GradientInput; type ParsedGradient = { angle: number; stops: { hsva: Hsva; position: number; }[]; }; export declare const parseGradient: (input: GradientInput) => ParsedGradient | null; export declare const gradientCss: (angle: number, stops: GradientStop[]) => string; /** * Two-tone checkerboard background for surfaces that can show transparency * (swatches, alpha tracks). Spread into a `style` prop: `style={CHECKER}`. */ export declare const CHECKER: { background: string; }; /** Horizontal preview gradient for the stop bar (ignores `angle`, like Sketch). */ export declare const gradientPreviewCss: (stops: GradientStop[]) => string; /** Stable signature used to detect *external* controlled-value changes. */ export declare const colorSignature: (hsva: Hsva) => string; export {}; //# sourceMappingURL=color.d.ts.map