UNPKG

@thi.ng/color

Version:

Array-based color types, CSS parsing, conversions, transformations, declarative theme generation, gradients, presets

86 lines 3.46 kB
import type { ColorMatrix, ReadonlyColor } from "./api.js"; /** * Transforms `src` RGBA color with given matrix and stores result in * `out` (writes back to `src` if `out` is `null` or `undefined`). * Unless `clampOut` is false, the result color will be clamped to `[0,1]` * interval. * * @param out - result * @param mat - transform matrix * @param src - source color * @param clampOut - true, if result should be clamped to `[0,1]` */ export declare const transform: (out: import("./api.js").Color | null, mat: ColorMatrix, src: ReadonlyColor, clampOut?: boolean) => import("@thi.ng/vectors").Vec<number>; /** * Concatenates given color matrices by pairwise multiplying them in * left-right order. Returns combined result matrix to be used with * {@link transform}. * * @remarks * Using {@link concat} is the recommended way when applying multiple * color transformations in sequence. Since the transforms are combined * into a single matrix, it is faster than multiple, individual * {@link transform} calls and will also produce more correct results, * since result color clamping is only applied once at the end (by * default, unless disabled). * * @param mat - first matrix * @param rest - other matrices */ export declare const concat: (mat: ColorMatrix, ...rest: ColorMatrix[]) => ColorMatrix; export declare const IDENTITY: ColorMatrix; /** * Returns a transformation matrix which subtracts user color from given * `src` color. With the default color white, this results in the * inverted color. Does NOT modify alpha channel. * * @param src - source color */ export declare const subtractMat: (src?: ReadonlyColor) => ColorMatrix; /** * Returns a transformation matrix which adds the given constant offset * `x` to RGB channels. Does NOT modify alpha channel. * * If `x < 0` results in darker color. * If `x > 0` results in brighter color. * * @param x - brightness offset */ export declare const brightnessMat: (x: number) => ColorMatrix; export declare const contrastMat: (x: number, o?: number) => ColorMatrix; export declare const exposureMat: (x: number) => ColorMatrix; export declare const saturationMat: (x: number) => ColorMatrix; export declare const hueRotateMat: (theta: number) => ColorMatrix; /** * Color temperature adjustment matrix. `x` controls blue/yellow, `y` controls * green/magenta axis (both params in `[-1,1]` range). * * @param x * @param y */ export declare const temperatureMat: (x: number, y?: number) => ColorMatrix; export declare const sepiaMat: (x?: number) => ColorMatrix; export declare const tintMat: (x: number) => ColorMatrix; /** * Returns transformation matrix which computes luminance of user color * (optionally with custom coefficients). Does NOT modify alpha channel. * * @remarks * See {@link RGB_LUMINANCE_REC709} for default coefficients * * @param coeffs - luminance coefficients * @param offset - brightness offset */ export declare const grayscaleMat: ([r, g, b]?: number[], offset?: number) => ColorMatrix; /** * Returns transformation matrix which computes luminance of user color * (optionally with custom coefficients), uses result as alpha channel * and clears RGB channels (all set to zero). * * @remarks * See {@link RGB_LUMINANCE_REC709} for default coefficients * * @param coeffs - luminance coefficients */ export declare const luminanceAlphaMat: ([r, g, b]?: number[]) => ColorMatrix; //# sourceMappingURL=transform.d.ts.map