export interface ShadeGroup { shade: Shade; halfShade: Shade; onShade: Shade; } interface Color { name: string; light: ColorMode; dark: ColorMode; } interface ColorMode { key: string; name: string; shades: Shade[]; color: Color; } export interface SearchShadesArgs { condition: (shade: Shade) => boolean; add1: number; add2: number; } /** * A color shade. * * @category Utilities */ export declare class Shade { private static coreShadeMap; /** The black shade */ static BLACK: Shade; /** The near black shade */ static NEAR_BLACK: Shade; /** The half-black shade */ static HALF_BLACK: Shade; /** The off-black shade */ static OFF_BLACK: Shade; /** The white shade */ static WHITE: Shade; /** The half-white shade */ static HALF_WHITE: Shade; /** The off-white shade */ static OFF_WHITE: Shade; /** The gray shade */ static GRAY: Shade; /** The white dark mode shade */ static WHITE_DM: Shade; /** The half-white dark mode shade */ static HALF_WHITE_DM: Shade; /** The dark blue shade */ static DARK_BLUE: Shade; static DARKEN_MULTIPLIER: number; static LIGHTEN_MULTIPLIER: number; /** * Get a core shade given the core shade name. * @param coreShadeName The core shade name. * @returns The core shade, or undefined if none found by this name. */ static getCoreShade(coreShadeName: string): Shade | undefined; /** * Get all core shades. * @returns All core shades. */ static coreShades(): Shade[]; /** * Create a shade object from it's hex value. * @param hex The hex value for the color shade. * @param coreShadeName An optional core shade name for this object. * @returns The shade object */ static fromHex(hex: string, coreShadeName?: string): Shade; /** * Create a shade object from it's R, G, and B values. * @param R Red value. * @param G Green value. * @param B Blue value. * @returns The shade object */ static fromRGB(R: number, G: number, B: number): Shade; /** * Create a shade object from an [R,G,B] array. * @param rgbArray The [R,G,B] array. * @returns The shade object. */ static fromRGBArray(rgbArray: number[]): Shade; static fromRGBString(rgb: string): Shade; static fromRGBAString(rgba: string): Shade; /** The shade's hex value */ hex: string; /** The shade's RGB array */ rgbArray: number[]; /** The shade's R value */ R: number; /** The shade's G value */ G: number; /** The shade's B value */ B: number; /** The id of the shade */ id: string; /** The index of the shade */ index: number; /** The opacity of the shade */ opacity: number; /** The onHex value for this shade */ onHex: string; key?: string; coreShadeName?: string; private luminance?; private lightness?; private perceivedLightness?; private saturation?; private label?; private mode?; constructor(opts: { hex?: string; rgbArray?: number[]; }); fromHex(): Shade; fromRGB(): Shade; /** * Set the hex value for this shade. * @param hex The hex value for this shade. */ setHex(hex: string): Shade; /** * Determine if the shade has a mode. * @returns True if it has a mode */ hasMode(): boolean; /** * Get the shade's mode * @returns The mode, or throws exception if node. */ getMode(): ColorMode; /** * Set the mode of the shade * @param mode The mode of the shade * @returns The shade */ setMode(mode?: ColorMode): Shade; /** * Determine if this shade is a core shade. * @returns True if this is a core shade; false, otherwise. */ isCore(): boolean; /** * Set the id of the shade * @param id The id of the shade * @returns The shade */ setId(id: string): Shade; /** * Get the half shade for this shade. * @returns The half shade (opacity 0.5) of this shade */ getHalfShade(): Shade; /** * Get the quarter shade for this shade. * @returns The half shade (opacity 0.25) of this shade */ getQuarterShade(): Shade; /** * Get a partial shade * @param opacity The opacity to apply to this new shade * @returns */ getPartialShade(opacity: number): Shade; /** * Get the light mode shade for this shade. * @returns The corresponding light mode shade for this shade */ getLightModeShade(): Shade; getOnShade(): Shade; /** * Get the on shade for this shade. * @returns The on shade */ getOnShade2(lm: boolean): Shade; getShadeGroup(lm: boolean): ShadeGroup; setOpacity(opacity: number): Shade; getLabel(): number; /** * Get the luminance of this shade. * @returns The luminance */ getLuminance(): number; getContrastShade(lm: boolean): Shade; /** * Return either this shade or the onShade based on contrast requirements to 'shade'. * @param shade The shade to compare to this one * @param multiplier Optional multiplier * @returns This shade or the onShade */ getShadeOrOnShadeBasedOnContrast(shade: Shade, lm: boolean, multiplier?: number): Shade; /** * Get the lightness of this shade. * @returns The lightness of this shade. */ getLightness(): number; /** * Get the perceived lightness of this shade. * @returns The perceived lightness of this shade. */ getPerceivedLightness(): number; /** * Get the saturation of this shade. * @returns The saturation of this shade. */ getSaturation(): number; /** * Build light or dark mode shades for this shade. * @param lm True for light mode or false for dark mode * @returns Shades for this shade */ buildShades(lm: boolean): Shade[]; /** * Find a shade which meets the contrast ratio requirements on this background shade. * @param lm true for light mode and false for dark mode. * @param bgShade The background shade * @param ratio The contrast ratio requirement * @returns */ getShade(lm: boolean, bgShades: Shade[], ratio: number): Shade | undefined; /** * Find a light mode shade which meets the contrast ratio on this background shade * @param bgShade The background shade * @param ratio The required contrast ratio * @returns A light mode shade meeting the contrast ratio requirement, or throws an exception if not found. */ findLMShade(bgShades: Shade[], ratio: number): Shade; /** * Get a light mode shade which meets the contrast ratio on this background shade. * Find the shade closest to this shade which meets the contrast ratio requirement against the background shade. * @param bgShade The background shade * @param ratio The required contrast ratio * @returns A light mode shade meeting the contrast ratio requirement, or undefined if not found */ getLMShade(bgShades: Shade[], ratio: number): Shade | undefined; /** * Build light mode shades for this shade. * @returns Light mode shades for this shade */ buildLMShades(): Shade[]; /** * Find a dark mode shade which meets the contrast ratio on these background shades * @param bgShades The background shades * @param ratio The required contrast ratio * @returns A dark mode shade meeting the contrast ratio requirement, or throws an exception if not found. */ findDMShade(bgShades: Shade[], ratio: number): Shade; /** * Get a dark mode shade which meets the contrast ratio on these background shades * @param bgShades The background shades * @param ratio The required contrast ratio * @returns A dark mode shade meeting the contrast ratio requirements, or undefined if not found */ getDMShade(bgShades: Shade[], ratio: number): Shade | undefined; /** * Get the corresponding dark mode shade (i.e. at the same index) for a light mode shade. * @returns The corresponding dark mode shade */ getCorrespondingDarkModeShade(): Shade; /** * Return true if the contrast ratio of this shade to all 'bgShades' meets or exceeds 'ratio'; * otherwise, return false. * @param bgShades * @param ratio */ meetsContrastRequirements(bgShades: Shade[], ratio: number): boolean; searchShades(args: SearchShadesArgs): Shade | undefined; /** * Build dark mode shades for this shade. * @returns Dark mode shades for this shade */ buildDMShades(): Shade[]; /** * Build 10 shades from this shade, some of which may be lighter and some of which may be darker. * The number of lighter and darker depends on where in the spectrum this shade falls. * @param lm True if this is for light mode; else false if for dark mode. * @returns */ private getLighterAndDarkerShades; /** * Build 10 shades from this shade, some of which may be lighter and some of which may be darker. * The number of lighter and darker depends on where in the spectrum this shade falls. * @param lm True if this is for light mode; else false if for dark mode. * @returns */ private getLighterShades; private getDarkerShades; /** * Build a dark mode shade for this shade * @param minRatio The minimum contrast ratio to white or black * @returns The new dark mode shade */ buildDMShade(minRatio?: number): Shade; /** * Build a shade * @param lm True for light mode; false for dark mode * @param minRatio Optional minRatio for the contrast ratio comparison for the on text */ buildShade(lm: boolean, minRatio?: number): Shade; /** * Build a light mode shade for this shade which meets the min contrast ratio requirements * @param minRatio The minimum contrast ratio * @returns The adjusted shade meeting the contrast ratio requirements */ buildLMShade(minRatio?: number): Shade; getAdjustedShadeByContrastRatio(lm: boolean, minRatio?: number): Shade; getDesaturatedShade(): Shade; getElevationShades(): Shade[]; getElevationShade(opacity: number): Shade; mixShade(shade: Shade, opacity: number): Shade; numLighterShades(): number; numDarkerShades(): number; private getLMH; darken(): Shade; lighten(): Shade; adjust(multiplier: number): Shade; private calculateLightness; private calculatePerceivedLightness; calculateLuminance(): number; calculateSaturation(): number; private calculateLabel; /** * Calculate the contrast ratio between two shades. */ getContrastRatio(other: Shade): number; /** * Get the contrast of this shade to white or black. * @returns The contrast of this shade to white or black. */ getContrast(): number; /** * Get the contrast of this shade to white or black. * @returns */ getContrastToWhiteOrBlack(lm: boolean): number; /** * Mix this shade with another shade to produce a third shade. * @param shade The other shade to mix with this shade * @param ratio The ratio; a value between 0 and 1 denoting how much of this shade verses the other shade in the resulting shade. * @returns A third shade which is the mixture of this shade and the 'shade'. */ mix(shade: Shade, ratio: number): Shade; /** * Get the hex value if no opacity, or RGBA string if opacity is not 1. * @returns */ getHexOrRGBA(): string; getRGB(): string; getRGBA(): string; /** * Clone a shade object. * @returns A new shade object. */ clone(): Shade; equals(shade: Shade): boolean; isSameColor(shade: Shade): boolean; /** * Get shades ordered by the nearest to the current shade. */ getShadesOrderedByNearness(): Shade[]; getShadesOrderedByNearness2(add1: number, add2: number): Shade[]; buildComplimentaryShades(): Shade[]; toJSON(): Object; toString(): string; deserialize(obj: any): void; serialize(): any; } export {};