import { z } from 'zod'; /** A zod schema for a hex color. */ declare const hexZ: z.ZodString; /** A zod schema for an RGBA color. */ declare const rgbaZ: z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt, z.ZodNumber], null>; /** A zod schema for an RGB color. */ declare const rgbZ: z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt], null>; declare const legacyObjectZ: z.ZodObject<{ rgba255: z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt, z.ZodNumber], null>; }, z.core.$strip>; /** A zod schema for an RGBA struct (r, g, b, a fields). */ declare const rgbaStructZ: z.ZodObject<{ r: z.ZodInt; g: z.ZodInt; b: z.ZodInt; a: z.ZodNumber; }, z.core.$strip>; /** A zod schema for an HSLA color. */ declare const hslaZ: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>; /** A color in RGBA format. See https://en.wikipedia.org/wiki/RGBA_color_model */ export type RGBA = z.infer; /** A color in HSLA format. See https://en.wikipedia.org/wiki/HSL_and_HSV */ export type HSLA = z.infer; /** A color in RGB format. See https://en.wikipedia.org/wiki/RGB_color_model */ export type RGB = z.infer; /** A color in hex format. See https://en.wikipedia.org/wiki/Web_colors */ export type Hex = z.infer; /** A legacy color object. Used for backwards compatibility. */ type LegacyObject = z.infer; /** A color in RGBA format as a struct. */ type RGBAStruct = z.infer; /** A zod schema for a crude color representation. */ export declare const crudeZ: z.ZodUnion, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodObject<{ rgba255: z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt, z.ZodNumber], null>; }, z.core.$strip>, z.ZodObject<{ r: z.ZodInt; g: z.ZodInt; b: z.ZodInt; a: z.ZodNumber; }, z.core.$strip>]>; /** * An unparsed representation of a color i.e. a value that can be converted into * a Color object. */ export type Crude = Hex | RGBA | Color | RGB | LegacyObject | RGBAStruct; /** A zod schema to parse color values from various crude representations. */ export declare const colorZ: z.ZodPipe, z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodObject<{ rgba255: z.ZodTuple<[z.ZodInt, z.ZodInt, z.ZodInt, z.ZodNumber], null>; }, z.core.$strip>, z.ZodObject<{ r: z.ZodInt; g: z.ZodInt; b: z.ZodInt; a: z.ZodNumber; }, z.core.$strip>]>, z.ZodTransform<[number, number, number, number], string | [number, number, number, number] | [number, number, number] | { rgba255: [number, number, number, number]; } | { r: number; g: number; b: number; a: number; }>>; /** * A color in RGBA format. Used as the standard representation of a color in this package. * See https://en.wikipedia.org/wiki/RGBA_color_model */ export type Color = RGBA; /** @returns true if the given color can be parsed into a valid color object. */ export declare const isCrude: (color: unknown) => color is Crude; /** @returns true if the color is a true Color type. */ export declare const isColor: (color: unknown) => color is Color; /** * Converts a crude color to its most meaningful CSS format. * @returns undefined if the color is undefined. * @returns an RGBA CSS string if the color can be parsed into a Color. * @returns the color directly if it is a css variable. * @throws if the color does not match any of the preceding conditions. */ export interface CSSString { (color: Crude): string; (color?: Crude): string | undefined; } export declare const cssString: CSSString; /** * @constructor Creates a new color from the given color value. The color value can be * a hex string, an array of RGB or RGBA values, or another color. * * @param color - The color value to create the color from. If the color value is a * string, it must be a valid hex color (with or without the '#') with a hash-less * length 6 or 8. If the hex color is 8 characters long, the last two characters are * used as the alpha value. If the color value is an array, it must be an array of * length 3 or 4, with each value between 0 and 255. If the color value is another * color, the color will be copied. * * @param alpha - An optional alpha value to set. If the color value carries its own * alpha value, this value will be ignored. Defaults to 1. */ export declare const construct: (color: Crude, alpha?: number) => Color; /** * @returns true if the given color is semantically equal to this color. Different * representations of the same color are considered equal (e.g. hex and rgba). */ export declare const equals: (a?: Crude, b?: Crude) => boolean; export interface ToHex { (color: Crude): string; (color?: Crude): string | undefined; } /** * @returns the hex representation of the color. If the color has an opacity of 1, * the returned hex will be 6 characters long. Otherwise, it will be 8 characters * long. */ export declare const hex: ToHex; /** @returns the color as a CSS RGBA string. i.e. rgba(r, g, b, a) */ export declare const rgbaCSS: (color: Crude) => string; /** @returns the color as a CSS RGB string with no alpha value. i.e. rgb(r, g, b) */ export declare const rgbCSS: (color: Crude) => string; /** * @returns the color as an RGB string, with each color value between 0 and 255. * @example "255, 255, 255" */ export declare const rgbString: (color: Crude) => string; /** * @returns the color as an RGBA tuple, with each color value between 0 and 1, * and the alpha value between 0 and 1. */ export declare const rgba1: (color: Crude) => RGBA; /** @returns the red value of the color, between 0 and 255. */ export declare const rValue: (color: Crude) => number; /** @returns the green value of the color, between 0 and 255. */ export declare const gValue: (color: Crude) => number; /** @returns the blue value of the color, between 0 and 255. */ export declare const bValue: (color: Crude) => number; /** @returns the alpha value of the color, between 0 and 1. */ export declare const aValue: (color: Crude) => number; /** @returns true if all RGBA values are 0. */ export declare const isZero: (color?: Crude) => boolean; /** @returns the HSLA representation of the color. */ export declare const hsla: (color: Crude) => HSLA; /** * @returns A new color with the given alpha. * @param color - The color to set the alpha value on. * @param alpha - The alpha value to set (0-1). */ export declare const setAlpha: (color: Crude, alpha: number) => Color; /** * @returns the luminance of the color, between 0 and 1. * @see https://en.wikipedia.org/wiki/Relative_luminance for more information. */ export declare const luminance: (color: Crude) => number; /** * @returns an approximation of the colors 'grayness' from 0 to 1 by measuring the * deviation between the RGB values of the color. */ export declare const grayness: (color: Crude) => number; /** * @returns the contrast ratio between this color and the given color. The contrast * ratio is a number between 1 and 21, where 1 is the lowest contrast and 21 is the * highest. * @param a - The first color to compare. * @param b - The second color to compare. * @returns The contrast ratio between the two colors. * * @see https://www.accessibility-developer-guide.com/knowledge/colours-and-contrast/how-to-calculate/ */ export declare const contrast: (a: Crude, b: Crude) => number; /** * @returns the color with the highest contrast ratio to the given colors. */ export declare const pickByContrast: (source: Crude, ...colors: Crude[]) => Color; /** @returns true if the color is dark i.e. it has a luminance less than 0.5. */ export declare const isDark: (color: Crude) => boolean; /** @returns true if the color is light i.e. the luminance is greater than 0.5. */ export declare const isLight: (color: Crude) => boolean; /** A totally zero color with no alpha. */ export declare const ZERO: Color; /** * Parses a CSS color string into a Color. * Supports hex colors, rgb/rgba functions, and named colors. * @param cssColor - The CSS color string to parse * @returns The parsed color or undefined if invalid */ export declare const fromCSS: (cssColor: string) => Color | undefined; /** @returns parse a color from an HSLA tuple. */ export declare const fromHSLA: (hsla: HSLA) => RGBA; /** The color black. */ export declare const BLACK: [number, number, number, number]; /** The color white. */ export declare const WHITE: [number, number, number, number]; export {}; //# sourceMappingURL=color.d.ts.map