@thi.ng/ramp
Version:
Extensible keyframe interpolation/tweening of arbitrary, nested types
37 lines • 1.27 kB
TypeScript
import type { RampImpl } from "./api.js";
export type NestedImpl<T extends Record<string, any>> = {
[P in keyof T]: RampImpl<T[P]>;
};
/**
* Higher order ramp implementation for nested (object based) values. The given
* `children` object must specify a {@link RampImpl} for each key in the object.
*
* @remarks
* Since this is only a {@link RampImpl}, all keys in the to-be-interpolated
* objects will share the same keyframe times (specified in the parent
* {@link ramp}). If a nested ramp is desired where each child can have its own
* set of keyframes, please use {@link group} instead. Both of these concepts
* are somewhat similar but satisfy different use cases.
*
* @example
* ```ts tangle:../export/nested.ts
* import { ramp, nested, LINEAR_N, HERMITE_N } from "@thi.ng/ramp";
*
* const example = ramp(
* // nested ramp spec w/ interpolation modes for each key
* nested({a: LINEAR_N, b: HERMITE_N }),
* // keyframes
* [
* [0, { a: 0, b: 1000 }],
* [100, { a: -10, b: 2000 }],
* ]
* )
*
* console.log(example.at(25));
* // { a: -2.5, b: 1156.25 }
* ```
*
* @param children
*/
export declare const nested: <T extends Record<string, any>>(children: NestedImpl<T>) => RampImpl<T>;
//# sourceMappingURL=nested.d.ts.map