UNPKG

@jupyter/web-components

Version:

A component library for building extensions in Jupyter frontends.

52 lines (51 loc) 1.81 kB
import { Swatch, SwatchRGB } from './swatch.js'; import { RelativeLuminance } from './utilities/relative-luminance.js'; /** * A collection of {@link Swatch} instances * @public */ export interface Palette<T extends Swatch = Swatch> { readonly source: T; readonly swatches: ReadonlyArray<T>; /** * Returns a swatch from the palette that most closely matches * the contrast ratio provided to a provided reference. */ colorContrast(reference: Swatch, contrast: number, initialIndex?: number, direction?: 1 | -1): T; /** * Returns the index of the palette that most closely matches * the relativeLuminance of the provided swatch */ closestIndexOf(reference: RelativeLuminance): number; /** * Gets a swatch by index. Index is clamped to the limits * of the palette so a Swatch will always be returned. */ get(index: number): T; } /** @public */ export type PaletteRGB = Palette<SwatchRGB>; /** * Creates a PaletteRGB from input R, G, B color values. * @param r - Red value represented as a number between 0 and 1. * @param g - Green value represented as a number between 0 and 1. * @param b - Blue value represented as a number between 0 and 1. */ declare function create(r: number, g: number, b: number): PaletteRGB; /** * Creates a PaletteRGB from a source SwatchRGB object. * @deprecated - Use PaletteRGB.from() */ declare function create(source: SwatchRGB): PaletteRGB; /** * Creates a PaletteRGB from a source color object. * @param source - The source color */ declare function from(source: SwatchRGB): PaletteRGB; declare function from(source: Record<'r' | 'g' | 'b', number>): PaletteRGB; /** @public */ export declare const PaletteRGB: Readonly<{ create: typeof create; from: typeof from; }>; export {};