UNPKG

graphics-ts

Version:

A porting of purescript-{canvas, free-canvas, drawing} featuring fp-ts

90 lines (89 loc) 2.15 kB
/** * @since 1.0.0 */ /** * Represents a color using a hexadecimal value. * * @category model * @since 1.0.0 */ export interface Hex { readonly _tag: 'Hex' /** * The hexadecimal value of a color. */ readonly value: string } /** * Represents a color using the HSL cylindrical-coordinate system. * * @category model * @since 1.0.0 */ export interface Hsla { readonly _tag: 'Hsla' /** * A number between `0` and `360` representing the hue of the color in degrees. */ readonly h: number /** * A number between `0` and `1` representing the percent saturation of the color * where `0` is completely denatured (grayscale) and `1` is fully saturated (full color). */ readonly s: number /** * A number between `0` and `1` representing the percent lightness of the color * where `0` is completely dark (black) and `1` is completely light (white). */ readonly l: number /** * A number between `0` and `1` representing the opacity or transparency of the color * where `0` is fully transparent and `1` is fully opaque. */ readonly a: number } /** * Adapted from https://github.com/sharkdp/purescript-colors. * * @category model * @since 1.0.0 */ export declare type Color = Hex | Hsla /** * Constructs a `Color` using a hexadecimal value. * * @category constructors * @since 1.0.0 */ export declare const hex: (value: string) => Hex /** * Constructs a `Color` using the specified hue, saturation, lightness, and alpha. * * @category constructors * @since 1.0.0 */ export declare const hsla: (h: number, s: number, l: number, a: number) => Hsla /** * Constructs a fully opaque `Color` using the specified hue, saturation, and lightness. * * @category constructors * @since 1.0.0 */ export declare const hsl: (h: number, s: number, l: number) => Color /** * @category constructors * @since 1.0.0 */ export declare const black: Color /** * @category constructors * @since 1.0.0 */ export declare const white: Color /** * Converts a `Color` into a valid CSS string. * * @category destructors * @since 1.0.0 */ export declare const toCss: (color: Color) => string