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 parametersName |
---|
T |
#
Defined in#
Functions#
evaluateVariationâ–¸ evaluateVariation<T
>(variation
): T
Returns a value instance of a variation.
#
Type parametersName |
---|
T |
#
ParametersName | Type |
---|---|
variation | Variation <T > |
#
ReturnsT
#
Defined in#
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.
#
ParametersName | Type | Description |
---|---|---|
gradient | Gradient | The gradient to sample from. |
#
Returns#
Defined in#
rangeâ–¸ range(min
, max
): Variation
<number
>
Creates a variation function that returns a random number from min to max.
#
ParametersName | Type |
---|---|
min | number |
max | number |
#
ReturnsVariation
<number
>
#
Defined in#
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
.
#
ParametersName | Type |
---|---|
value | number |
amount | number |
#
ReturnsVariation
<number
>
#
Defined in#
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.
#
ParametersName | Type |
---|---|
value | number |
percentage | number |
#
ReturnsVariation
<number
>
#
Defined in#
splineSampleâ–¸ splineSample<T
>(spline
): Variation
<T
>
Creates a variation function that returns a random sample from the given spline.
#
Type parametersName |
---|
T |
#
ParametersName | Type | Description |
---|---|---|
spline | Spline <T > | The spline to sample from. |
#
ReturnsVariation
<T
>