interface SpaceFormat {
    [instance]?: default;
    alpha?: boolean;
    commas?: boolean;
    coordGrammar?: (string & {
        range?: [number, number];
    })[];
    coords?: string[];
    id?: string;
    ids?: string[];
    name?: string;
    parse?: ((str) => ColorConstructor);
    serialize?: ((coords, alpha, opts?) => string);
    serializeCoords?: ((coords, precision) => [string, string, string]);
    space?: Space;
    test?: ((str) => boolean);
    toGamut?: boolean;
    type?: string;
}

Properties

[instance]?: default
alpha?: boolean

Whether to always have alpha at the end (true), never (false), or auto (undefined)

commas?: boolean

Whether commas should separate arguments for a format

coordGrammar?: (string & {
    range?: [number, number];
})[]
coords?: string[]
id?: string
ids?: string[]
name?: string

Default

"color"
parse?: ((str) => ColorConstructor)

Function to parse a string into a color

Type declaration

serialize?: ((coords, alpha, opts?) => string)

Serialize coordinates and an alpha channel into a string. Must be defined for a format to support serialization

Type declaration

    • (coords, alpha, opts?): string
    • Parameters

      • coords: Coords
      • alpha: number
      • Optional opts: Record<string, any>

      Returns string

serializeCoords?: ((coords, precision) => [string, string, string])

Type declaration

    • (coords, precision): [string, string, string]
    • Parameters

      • coords: Coords
      • precision: number

      Returns [string, string, string]

space?: Space
test?: ((str) => boolean)

Type declaration

    • (str): boolean
    • Parameters

      • str: string

      Returns boolean

toGamut?: boolean

Whether to adjust the coordinates to fit in the gamut

type?: string

Default

"function"