UNPKG

party-js

Version:

A JavaScript library to brighten up your user's site experience with visual effects!

48 lines (47 loc) 2.02 kB
import { Color, Gradient } from "../components"; import { Spline } from "../components/spline"; /** * Represents a junction of types that can be used as a variation on a value. * At any point in time, the variation can be evaluated to retrieve a "primitive" value. * The variation can consist of a constant, an array or an evaluateable function. */ export declare type Variation<T> = T | T[] | (() => T); /** * Returns a value instance of a variation. */ export declare function evaluateVariation<T>(variation: Variation<T>): T; /** * Creates a variation function that returns a random number from min to max. */ export declare function range(min: number, max: number): Variation<number>; /** * Creates a variation function that skews the specified value by a specified, absolute * amount. This means that instead of the value itself, a random number that deviates * at most by the specified amount is returned. * * @remarks * If you want to skew by a percentage instead, use `skewRelative`. */ export declare function skew(value: number, amount: number): Variation<number>; /** * Creates a variation function that skews the specified value by a specified percentage. * This means that instead of the value itself, a random number that deviates by a maximum * of the specified percentage is returned. */ export declare function skewRelative(value: number, percentage: number): Variation<number>; /** * Creates a variation function that returns a random sample from the given spline. * * @param spline The spline to sample from. */ export declare function splineSample<T>(spline: Spline<T>): Variation<T>; /** * Creates a variation function that returns a random sample from the given gradient. * * @remarks * This function is an alias for the spline variation, since a gradient is just * a spline under the hood. * * @param gradient The gradient to sample from. */ export declare function gradientSample(gradient: Gradient): Variation<Color>;