The library makes heavy use of so-called variations to allow the variation/customization of individual values. Variations are generic - in theory they can take any value, no matter if it's a number, vector or color. A variation can be represented by a constant, an array, or a function returning a value.
Variations can be evaluated by an internal helper method, so produce a raw value from it. This means that either:
- The primitive value is returned.
- A random element from the array is picked.
- The function is evaluated and returned.
This makes variations a powerful tool to customize properties of emitters. If you happen to be in need of evaluating a variation, you can use the
To assist in creating variations aside from constants and arrays, the library offers pre-made helper methods - these return a valid variation that can be evaluated as such.
party.variation.range(min, max): Creates a variation that returns a random number from min to max.
party.variation.skew(value, amount): Creates a variation 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.
party.variation.skewRelative(value, percentage): Creates a variation 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.
party.variation.splineSample(spline): Creates a variation that returns a random sample from the given spline.
party.variation.gradientSample(gradient): Creates a variation that returns a random color sample from the given gradient.