Skip to content
party.js logoparty.js logo

ReferenceSamplersFunction

spread()

Picks numbers spread evenly around a center.

function spread(center: number, deviation: number): SamplerFn<number>;

Creates a sampler that picks numbers from center - deviation to center + deviation, spread evenly across each batch of particles.

Within a batch (a group of particles spawned in the same simulation step, such as a burst), the range is divided into one equal slice per particle, and each particle gets a random value within its own slice. A burst therefore will always cover the whole range evenly, without the clumps and gaps that truly independent random values could produce. A particle spawned on its own gets a random value from the whole range.

centernumber

The middle of the range.

deviationnumber

How far values may lie from the center, in either direction.

SamplerFn<number>