Skip to content
party.js logoparty.js logo

ReferenceBehaviorsFunction

twinkle()

Makes particles glint now and then, like glitter.

function twinkle(options?: TwinkleOptions): Behavior;

Creates a behavior that makes particles twinkle occasionally.

Each particle glints a few times during its life, at random moments: for a short while, it grows a little and flashes towards white, then settles back. Between glints, it looks as it would without this behavior.

The glint is applied on top of the particle’s size and color, so it works together with behaviors that change them. List it after scale(), which sets the size from scratch on every step and would otherwise overwrite the glint.

optionsoptionalTwinkleOptionsdefault{}

How often and how strongly particles glint. See TwinkleOptions.

PartyJSError

If an option is out of range.

const behaviors = [scale(0.05, 0.25), twinkle({ glints: 2, brightness: 0.8 })];