molstar
Version:
A comprehensive macromolecular library.
69 lines (68 loc) • 3.18 kB
TypeScript
/**
* Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
*
* @author Alexander Rose <alexander.rose@weirdbyte.de>
*/
import { NumberArray } from '../../mol-util/type-helpers';
import { Vec3 } from '../../mol-math/linear-algebra';
/** RGB color triplet expressed as a single number */
export declare type Color = {
readonly '@type': 'color';
} & number;
export declare function Color(hex: number): Color;
export declare namespace Color {
function toStyle(hexColor: Color): string;
function toHexString(hexColor: Color): string;
function toRgbString(hexColor: Color): string;
function toRgb(hexColor: Color): [number, number, number];
function toRgbNormalized(hexColor: Color): [number, number, number];
function fromRgb(r: number, g: number, b: number): Color;
function fromNormalizedRgb(r: number, g: number, b: number): Color;
function fromArray(array: NumberArray, offset: number): Color;
function fromNormalizedArray(array: NumberArray, offset: number): Color;
/** Copies hex color to rgb array */
function toArray(hexColor: Color, array: NumberArray, offset: number): NumberArray;
/** Copies normalized (0 to 1) hex color to rgb array */
function toArrayNormalized<T extends NumberArray>(hexColor: Color, array: T, offset: number): T;
/** Copies hex color to rgb vec3 */
function toVec3(out: Vec3, hexColor: Color): Vec3;
/** Copies normalized (0 to 1) hex color to rgb vec3 */
function toVec3Normalized(out: Vec3, hexColor: Color): Vec3;
/** Linear interpolation between two colors in rgb space */
function interpolate(c1: Color, c2: Color, t: number): Color;
function saturate(c: Color, amount: number): Color;
function desaturate(c: Color, amount: number): Color;
function darken(c: Color, amount: number): Color;
function lighten(c: Color, amount: number): Color;
function sRGBToLinear(c: Color): Color;
function linearToSRGB(c: Color): Color;
}
export declare type ColorListEntry = Color | [Color, number /** normalized value from 0 to 1 */];
export interface ColorList {
label: string;
description: string;
list: ColorListEntry[];
type: 'sequential' | 'diverging' | 'qualitative';
}
export declare function ColorList(label: string, type: 'sequential' | 'diverging' | 'qualitative', description: string, list: (number | [number, number])[]): ColorList;
export declare type ColorTable<T extends {
[k: string]: number[];
}> = {
[k in keyof T]: Color[];
};
export declare function ColorTable<T extends {
[k: string]: number[];
}>(o: T): ColorTable<T>;
export declare type ColorMap<T extends {
[k: string]: number;
}> = {
[k in keyof T]: Color;
};
export declare function ColorMap<T extends {
[k: string]: number;
}>(o: T): ColorMap<T>;
export declare function getAdjustedColorMap<T extends {
[k: string]: number;
}>(map: ColorMap<T>, saturation: number, lightness: number): ColorMap<T>;
export declare type ColorSwatch = [string, Color][];
export declare function ColorSwatch(l: [string, number][]): ColorSwatch;