ultra-design
Version:
29 lines (28 loc) • 915 B
TypeScript
export interface RGB {
r: number;
g: number;
b: number;
a?: number;
}
interface HSV {
h: number;
s: number;
v: number;
a?: number;
}
export declare type Color = {
hex: string;
rgb: RGB;
hsv: HSV;
};
export declare function toHex(value: string): string;
export declare function toRgb(value: string[]): Color['rgb'];
export declare function hex2rgb(hex: string): RGB;
export declare function rgb2hsv({ r, g, b, a }: RGB): HSV;
export declare function hsv2rgb({ h, s, v, a }: HSV): RGB;
export declare function rgb2hex({ r, g, b, a }: RGB): string;
export declare function transformColor(format: 'hex', color: string): Color;
export declare function transformColor(format: 'rgb', color: RGB): Color;
export declare function transformColor(format: 'hsv', color: Color['hsv']): Color;
export declare function clamp(value: number, max: number, min: number): number;
export {};