UNPKG

s2maps-gpu

Version:

S2 Maps GPU - An open source, high-performance, and GPU-accelerated map engine for rendering large-scale, interactive maps.

119 lines (118 loc) 3.76 kB
import type { ColorBlindAdjust } from './colorBlindAdjust.js'; export * from './colorBlindAdjust.js'; export * from './colorGenerators.js'; export * from './colorParser.js'; /** ColorArray - [r, g, b, a] */ export type ColorArray = [r: number, g: number, b: number, a: number]; /** * # Color manager * * ### Description * Color class to handle color conversions and adjustments. Supports RGB, HSV, HSL, and LCH. * * ### Example Usage * * ex. name string * ```ts * const color = new Color('red'); * const rgb = color.getRGB(); * ``` * * ex. Hex string * ```ts * const color = new Color('#ff0000'); * const rgb = color.getRGB(); * ``` * * ex. String input array * ```ts * const color = new Color('hsv(180, 0.9, 0.7843137254901961)'); * const rgb = color.getRGB(); * ``` * * ex. RGBA array * ```ts * const color = new Color(255, 0, 0, 1, 'rgb'); * const rgb = color.getRGB(); * ``` * * ### COLOR INTERPOLATION: we support the use of the LCH color space: * - [interpolation guide here.](https://www.alanzucconi.com/2016/01/06/colour-interpolation/4/) * - use [chroma.js](https://github.com/gka/chroma.js) as a guide to create best interpolation * hsv is a good secondary. Saved for posterity. * * ### MORE INFORMATION ON COLOR BLIND ADJUST: * - [Link one](https://www.nature.com/articles/nmeth.1618), * - [Link two](http://www.daltonize.org/), * - [Link three](https://galactic.ink/labs/Color-Vision/Javascript/Color.Vision.Daltonize.js) */ export declare class Color { val: ColorArray; type: string; /** * @param x - either an input color, string defining a color, or first color value * @param y - second color value * @param z - third color value * @param a - alpha value * @param type - color type */ constructor(x?: number | string | Color, y?: number, z?: number, a?: number, type?: string); /** @returns a clone the color */ copy(): Color; /** * Get the rgb values of the color * @param normalize - whether to normalize the values * @param cbAdjust - colorblind adjustment * @returns Color as [r, g, b, a] */ getRGB(normalize?: boolean, cbAdjust?: ColorBlindAdjust): ColorArray; /** @returns the lch values of the color */ getLCH(): ColorArray; /** @returns the rgb values of the color */ toRGB(): this; /** @returns the hsv values of the color */ toHSV(): this; /** @returns the lch values of the color */ toLCH(): this; /** Convert rgb to lab */ RGB2LAB(): void; /** Convert lab to lch */ LAB2LCH(): void; /** Convert lch to lab */ LCH2LAB(): void; /** Convert lab to rgb */ LAB2RGB(): void; /** Convert rgb to hsv */ RGB2HSV(): void; /** Convert hsv to rgb */ HSV2RGB(): void; /** Convert hsl to rgb */ HSL2RGB(): void; /** * Get a sinebow color via interpolation input value * @param t - input value * @returns sinebow color at t */ static sinebow(t: number): Color; /** * Get a white color via interpolation * @param t - input value * @returns white color at t */ static fadeToWhite(t: number): Color; /** * Get a sinebow extended color via interpolation * @param t - input value * @returns sinebow extended color at t */ static sinebowExtended(t: number): Color; } /** * Given two colors, interpolate between them using a t value between 0 and 1. * 0 returns color1, 1 returns color2, and anything in between returns a mixture. * @param color1 - first color * @param color2 - second color * @param t - t value between 0 and 1 * @returns interpolated color */ export declare function interpolate(color1: Color, color2: Color, t: number): Color;