Skip to content
party.js logoparty.js logo

ReferenceSamplersType

SamplerFn

A function that produces a value.

type SamplerFn<T> = (ctx: SamplerContext) => T;

A function that produces a value each time it’s called, such as a random size or color.

T
T
// Every particle's size will be a bit larger than the one before.
const growing: SamplerFn<number> = (ctx) => 2 + ctx.index * 0.5;