@thi.ng/color
Version:
Array-based color types, CSS parsing, conversions, transformations, declarative theme generation, gradients, presets
78 lines • 2.22 kB
TypeScript
import type { FnN3, FnU4 } from "@thi.ng/api";
import type { Color, ColorMixFn, TypedColor } from "./api.js";
/**
* HOF color mix function. Takes 4 scalar mix fns (one per color channel) and
* returns new {@link ColorMixFn}.
*
* @param x -
* @param y -
* @param z -
* @param alpha -
*/
export declare const defMix: FnU4<FnN3, ColorMixFn>;
/**
* Single channel interpolation for (normalized) hues. Always interpolates via
* smallest angle difference, i.e. such that the effective `abs(a-b) <= 0.5`.
*
* @param a - start hue in `[0,1)` interval
* @param b - end hue in `[0,1)` interval
* @param t - interpolation factor
*/
export declare const mixH: FnN3;
/**
* Single channel linear interpolation function.
*
* @param a -
* @param b -
* @param t -
*/
export declare const mixN: FnN3;
export declare const mixHNNN: ColorMixFn;
export declare const mixNNHN: ColorMixFn;
/**
* Channelwise linear interpolation between colors `a` and `b` using `t` `[0,1]`
* as blend factor.
*
* @param out -
* @param a -
* @param b -
* @param t -
*/
export declare const mixNNNN: ColorMixFn;
/**
* Channelwise and {@link ColorMode}-aware interpolation between colors `a` and
* `b` using `t` `[0,1]` as blend factor. `a` and `b` MUST be of same color
* type.
*
* @remarks
* If `out` is null, the resulting color will be written back into `a`.
*
* Any hue channel will always be interpolated using the smallest angle
* difference (using {@link mixH}).
*
* The [thi.ng/math](https://thi.ng/thi.ng/math) package provides various easing
* functions to create non-linear interpolations. For example:
*
* @example
* ```ts tangle:../export/mix.ts
* import { mix, rgb, RED, GREEN } from "@thi.ng/color";
* import { circular } from "@thi.ng/math";
*
* console.log(
* mix([], rgb("#f00"), rgb("#0f0"), 0.5)
* );
* // [ 0.5, 0.5, 0, 1 ]
*
* console.log(
* mix([], rgb(RED), rgb(GREEN), circular(0.5))
* );
* // [ 0.1339745962155614, 0.8660254037844386, 0, 1 ]
* ```
*
* @param out -
* @param a -
* @param b -
* @param t -
*/
export declare const mix: import("@thi.ng/defmulti").MultiFn4<Color | null, TypedColor<any>, TypedColor<any>, number, Color>;
//# sourceMappingURL=mix.d.ts.map