Skip to main content

Namespace: variation

index.variation

Type aliases#

Variation#

Ƭ Variation<T>: T | T[] | () => T

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.

Type parameters#

Name
T

Defined in#

systems/variation.ts:10

Functions#

evaluateVariation#

â–¸ evaluateVariation<T>(variation): T

Returns a value instance of a variation.

Type parameters#

Name
T

Parameters#

NameType
variationVariation<T>

Returns#

T

Defined in#

systems/variation.ts:15


gradientSample#

â–¸ gradientSample(gradient): Variation<Color>

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.

Parameters#

NameTypeDescription
gradientGradientThe gradient to sample from.

Returns#

Variation<Color>

Defined in#

systems/variation.ts:70


range#

â–¸ range(min, max): Variation<number>

Creates a variation function that returns a random number from min to max.

Parameters#

NameType
minnumber
maxnumber

Returns#

Variation<number>

Defined in#

systems/variation.ts:24


skew#

â–¸ skew(value, amount): 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.

Parameters#

NameType
valuenumber
amountnumber

Returns#

Variation<number>

Defined in#

systems/variation.ts:36


skewRelative#

â–¸ skewRelative(value, percentage): 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.

Parameters#

NameType
valuenumber
percentagenumber

Returns#

Variation<number>

Defined in#

systems/variation.ts:45


splineSample#

â–¸ splineSample<T>(spline): Variation<T>

Creates a variation function that returns a random sample from the given spline.

Type parameters#

Name
T

Parameters#

NameTypeDescription
splineSpline<T>The spline to sample from.

Returns#

Variation<T>

Defined in#

systems/variation.ts:57