# Particle descriptors
Define randomized spawn values and lifespan curves.

## APIs demonstrated

- [particleChoice](/reference/functions/particle-descriptors/) from `@pibbl/core/particles`
- [particleCurve](/reference/functions/particle-descriptors/) from `@pibbl/core/particles`
- [particleGradient](/reference/functions/particle-descriptors/) from `@pibbl/core/particles`
- [particleInteger](/reference/functions/particle-descriptors/) from `@pibbl/core/particles`
- [particleParameter](/reference/functions/particle-descriptors/) from `@pibbl/core/particles`
- [particleRange](/reference/functions/particle-descriptors/) from `@pibbl/core/particles`
- [PibblParticleChoice](/reference/types/particles/) from `@pibbl/core/particles`
- [PibblParticleCurve](/reference/types/particles/) from `@pibbl/core/particles`
- [PibblParticleCurveOptions](/reference/types/particles/) from `@pibbl/core/particles`
- [PibblParticleCurveValue](/reference/types/particles/) from `@pibbl/core/particles`
- [PibblParticleGradient](/reference/types/particles/) from `@pibbl/core/particles`
- [PibblParticleIntegerRange](/reference/types/particles/) from `@pibbl/core/particles`
- [PibblParticleParameterReference](/reference/types/particles/) from `@pibbl/core/particles`
- [PibblParticleRange](/reference/types/particles/) from `@pibbl/core/particles`
- [PibblParticleScalar](/reference/types/particles/) from `@pibbl/core/particles`
- [PibblParticleVector2](/reference/types/particles/) from `@pibbl/core/particles`

## Complete example

[Plain source](/minimal/particles/descriptors.ts). Run as a browser module after the document body exists. TSX uses `jsx: "react-jsx"` and `jsxImportSource: "@pibbl/core"`.

```ts
import {
  particleChoice,
  particleCurve,
  particleGradient,
  particleInteger,
  particleParameter,
  particleRange,
  type PibblParticleChoice,
  type PibblParticleCurve,
  type PibblParticleCurveOptions,
  type PibblParticleCurveValue,
  type PibblParticleGradient,
  type PibblParticleIntegerRange,
  type PibblParticleParameterReference,
  type PibblParticleRange,
  type PibblParticleScalar,
  type PibblParticleVector2,
} from "@pibbl/core/particles";

const speed: PibblParticleRange = particleRange(60, 120);
const count: PibblParticleIntegerRange = particleInteger(8, 16);
const colors: PibblParticleChoice<string> = particleChoice([
  { value: "#f97316", weight: 3 },
  { value: "#facc15", weight: 1 },
]);
const wind: PibblParticleParameterReference<"wind"> = particleParameter("wind");
const velocity: PibblParticleVector2 = [wind, speed];
const opacity: PibblParticleCurve<number> = particleCurve([
  [0, 1],
  [1, 0],
]);
const color: PibblParticleGradient = particleGradient([
  [0, "#facc15"],
  [1, "#ef4444"],
]);
const sizeValue: PibblParticleCurveValue = [12, 18];
const smooth: PibblParticleCurveOptions = { easing: (t) => t * t };
const size = particleCurve(
  [
    [0, sizeValue],
    [1, [0, 0]],
  ],
  smooth,
);
const lifetime: PibblParticleScalar = particleRange(500, 900);

const output = document.createElement("pre");
output.textContent = JSON.stringify(
  { count, colors, velocity, opacity, color, size, lifetime },
  null,
  2,
);
document.body.append(output);

```

## Usage notes

- Displays the resulting descriptor values in the document.

## Documentation version

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.
