import type { FnU2 , IDeref , IEqualsDelta , NumericArray , Range , Tuple , } from "@thi.ng/api" ; import type { IRandom } from "@thi.ng/random" ; import type { IVector , ReadonlyVec , Vec } from "@thi.ng/vectors" ; export type Color = Vec ; export type ReadonlyColor = ReadonlyVec ; export type MaybeColor = TypedColor < any > | IParsedColor | ReadonlyColor | string | number ; export type ColorOp = ( out : Color | null , src : ReadonlyColor ) => Color ; export type ColorMode = "argb32" | "abgr32" | "hcy" | "hsi" | "hsl" | "hsv" | "lab50" | "lab65" | "lch" | "oklab" | "rgb" | "srgb" | "xyy" | "xyz50" | "xyz65" | "ycc" ; /**
 * Hue names in radial order, e.g. used by  namedHueRgb .
  export enum Hue { RED , ORANGE , YELLOW , CHARTREUSE , GREEN , SPRING_GREEN , CYAN , AZURE , BLUE , VIOLET , MAGENTA , ROSE } export interface IColor { readonly mode : ColorMode ; } export interface ChannelSpec { /**
     * Acceptable value range for this channel. Used by  TypedColor . clamp .
     *
     *  defaultValue range ? : Range ; defaultValue hue ? : boolean ; } export interface ColorSpec < M extends ColorMode , K extends string > { mode : M ; /**
     * Define additional per-channel constraints, information. Currently only
     * used to define limits.
     */ channels ? : Partial < Record < K , ChannelSpec > > ; /**
     * Channel names in index order (used to define channel accessors).
     */ order : readonly K [ ] ; /**
     * Conversions from source modes. `rgb` is mandatory, others optional. If a
     * key specifies an array of functions, these will be applied to source
     * color in LTR order.
     */ from : Partial < Record < ColorMode , ColorOp | Tuple < ColorOp , 2 | 3 | 4 > > > & { rgb : ColorOp ; } ; /**
     * Mandatory conversion to RGB mode. Used as fallback solution if no other
     * direct conversion path is defined (e.g. for CSS formatting).
     */ toRgb : ColorOp | Tuple < ColorOp , 2 | 3 | 4 > ; } export type Conversions = Partial < Record < ColorMode , ColorOp > > & { rgb : ColorOp ; } ; export interface ColorFactory < T extends TypedColor < any > > { ( col , buf ? , idx ? , stride ? ) : T ; ( col ? , idx ? , stride ? ) : T ; ( a , b , c , ... xs ) : T ; readonly class : TypedColorConstructor < T > ; param rnd param buf param index param stride random ( rnd ? , buf ? , index ? , stride ? ) : T ; /**
     * Same as  TypedColor . range .
      readonly range : [ ReadonlyColor , ReadonlyColor ] ; remarks param buf param num param start param cstride param estride mapBuffer ( buf , num ? , start ? , cstride ? , estride ? ) : T [ ] ; } export interface TypedColorConstructor < T extends TypedColor < any > > { new ( buf ? , offset ? , stride ? ) : T ; } export interface TypedColor < T > extends IColor , IDeref < Color > , IEqualsDelta < T > , IVector < T > , Iterable < number > { /**
     * Backing array / memory
     */ buf : NumericArray ; /**
     * Start index in array
     */ offset : number ; /**
     * Step size between channels
     */ stride : number ; remarks readonly range : [ ReadonlyColor , ReadonlyColor ] ; remarks clamp ( ) : this ; param rnd randomize ( rnd ? ) : this ; param src set ( src ) : this ; /**
     * For memory mapped colors, this ensures only the elements used by this
     * color are being serialized (as array) by `JSON.stringify()`.
     */ toJSON ( ) : number [ ] ; } export interface IParsedColor extends IColor , IDeref < Color > { } /**
 * Result type returned by  parseCss , a simple wrapper for a raw color
 * array and color mode.
  export class ParsedColor implements IParsedColor { constructor ( public readonly mode , public value ) { } deref ( ) { return this . value ; } } /**
 * A 4x5 matrix in column-major order
 */ export type ColorMatrix = Tuple < number , 20 > ; export type ColorDistance < T = ReadonlyColor > = FnU2 < T , number > ; export type ColorMixFn < T = ReadonlyColor > = ( out : Color | null , a : T , b : T , t : number ) => Color ;