Skip to content

Leaves API

Leaves

Extends Effect.

Factory Function

typescript
createLeaves(config?: LeavesConfig)

Methods

See Effect for the full method reference: mount(), start(), pause(), resume(), configure(), withFade(), and destroy().


LeavesConfig

typescript
interface LeavesConfig {
    count?: number;
    colors?: string[];
    size?: number;
    speed?: number;
    wind?: number;
    scale?: number;
}
PropertyTypeDefaultDescription
countnumber80Number of leaves. Automatically halved on small screens.
colorsstring[]Autumn palette (10 colors)Array of CSS color strings for leaf colors.
sizenumber22Maximum leaf size in pixels (before scale).
speednumber1Fall speed multiplier.
windnumber0.3Horizontal wind strength. Positive = right, negative = left.
scalenumber1Scales all leaf sizes proportionally.

Leaf

Internal representation of a leaf particle.

typescript
type Leaf = {
    x: number;          // Normalized X position (0-1)
    y: number;          // Normalized Y position (0-1)
    size: number;       // Leaf size in pixels
    depth: number;      // Depth layer (0.3-1) for parallax
    rotation: number;   // Current rotation angle
    rotationSpeed: number; // Rotation speed
    flipAngle: number;  // 3D flip angle for tumbling
    flipSpeed: number;  // Flip rotation speed
    shape: number;      // Leaf shape variant (0-2)
    colorIndex: number; // Index into sprite array
};