Skip to content

Lanterns API

Lanterns

Extends Effect.

Factory Function

typescript
createLanterns(config?: LanternsConfig)

Methods

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


LanternsConfig

typescript
interface LanternsConfig {
    count?: number;
    colors?: string[];
    size?: number;
    speed?: number;
    scale?: number;
}
PropertyTypeDefaultDescription
countnumber25Number of lanterns. Automatically halved on small screens.
colorsstring[]LANTERN_COLORSArray of hex color strings for the lantern colors.
sizenumber20Base lantern size in pixels (before scale).
speednumber0.5Rise speed multiplier.
scalenumber1Scales all lantern sizes proportionally.

Lantern

Internal representation of a lantern particle.

typescript
type Lantern = {
    x: number;            // Normalized X position (0-1)
    y: number;            // Normalized Y position (0-1)
    vx: number;           // Horizontal velocity (unused, reserved)
    vy: number;           // Rise speed factor
    size: number;         // Lantern size in pixels
    glowPhase: number;    // Glow pulse phase offset
    glowSpeed: number;    // Individual glow pulse speed
    swayPhase: number;    // Sway oscillation phase offset
    swaySpeed: number;    // Sway oscillation speed
    swayAmplitude: number; // Sway oscillation amplitude
    colorIndex: number;   // Index into the colors array
    opacity: number;      // Base opacity (0-1)
};