UNPKG

2.54 kBTypeScriptView Raw
1import { Extrapolation } from './interpolation';
2import type { SharedValue } from './commonTypes';
3/** @deprecated Please use Extrapolation instead */
4export declare const Extrapolate: typeof Extrapolation;
5/**
6 * Options for color interpolation.
7 *
8 * @param gamma - Gamma value used in gamma correction. Defaults to `2.2`.
9 * @param useCorrectedHSVInterpolation - Whether to reduce the number of colors
10 * the interpolation has to go through. Defaults to `true`.
11 */
12export type InterpolationOptions = {
13 gamma?: number;
14 useCorrectedHSVInterpolation?: boolean;
15};
16export interface InterpolateRGB {
17 r: number[];
18 g: number[];
19 b: number[];
20 a: number[];
21}
22export interface InterpolateHSV {
23 h: number[];
24 s: number[];
25 v: number[];
26 a: number[];
27}
28/**
29 * Lets you map a value from a range of numbers to a range of colors using
30 * linear interpolation.
31 *
32 * @param value - A number from the `input` range that is going to be mapped to
33 * the color in the `output` range.
34 * @param inputRange - An array of numbers specifying the input range of the
35 * interpolation.
36 * @param outputRange - An array of output colors values (eg. "red", "#00FFCC",
37 * "rgba(255, 0, 0, 0.5)").
38 * @param colorSpace - The color space to use for interpolation. Defaults to
39 * 'RGB'.
40 * @param options - Additional options for interpolation -
41 * {@link InterpolationOptions}.
42 * @returns The color after interpolation from within the output range in
43 * rgba(r, g, b, a) format.
44 * @see https://docs.swmansion.com/react-native-reanimated/docs/utilities/interpolateColor
45 */
46export declare function interpolateColor(value: number, inputRange: readonly number[], outputRange: readonly string[], colorSpace?: 'RGB' | 'HSV', options?: InterpolationOptions): string;
47export declare function interpolateColor(value: number, inputRange: readonly number[], outputRange: readonly number[], colorSpace?: 'RGB' | 'HSV', options?: InterpolationOptions): number;
48export declare enum ColorSpace {
49 RGB = 0,
50 HSV = 1
51}
52export interface InterpolateConfig {
53 inputRange: readonly number[];
54 outputRange: readonly (string | number)[];
55 colorSpace: ColorSpace;
56 cache: SharedValue<InterpolateRGB | InterpolateHSV | null>;
57 options: InterpolationOptions;
58}
59export declare function useInterpolateConfig(inputRange: readonly number[], outputRange: readonly (string | number)[], colorSpace?: ColorSpace, options?: InterpolationOptions): SharedValue<InterpolateConfig>;
60//# sourceMappingURL=interpolateColor.d.ts.map
\No newline at end of file