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