ReferenceCustom effectsFunction
createEffect()
Creates and starts a custom effect.
function createEffect(options: CreateEffectOptions): Effect;Creates and starts a custom effect, using the provided options.
The built-in effects like confetti() are made using this function. You can use it directly if your needs are not covered by them.
Parameters
Section titled “Parameters”optionsCreateEffectOptionsEverything that defines the effect.
Returns
Section titled “Returns”EffectA handle to pause, resume or stop the effect early.
Example
Section titled “Example”createEffect({ origin: { x: 200, y: 300 }, schedule: { bursts: [{ count: 30 }] }, particleInit: { position: emitFrom({ type: "disk", radius: 20 }), velocity: cone(90, 30, range(200, 400)), orientation: randomOrientation(), angularVelocity: randomSpin(90, 270), size: range(8, 14), color: pick(["#ff5a5f", "#ffb400", "#00a699"]), shape: { type: "circle" }, lifetime: range(2, 3), }, behaviors: [gravity(800), fade(0, 0.5)],});