Skip to content

Rain API

Rain

Extends Effect.

Factory Function

typescript
createRain(config?: RainConfig)

Methods

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


RainConfig

typescript
interface RainConfig {
    variant?: RainVariant;
    drops?: number;
    wind?: number;
    speed?: number;
    splashes?: boolean;
    color?: string;
    groundLevel?: number;
    scale?: number;
}
PropertyTypeDefaultDescription
variantRainVariant'downpour'Rain intensity preset. Overrides defaults for drops, speed, wind, and splashes.
dropsnumberVaries by variantMaximum number of raindrops. Automatically halved on small screens.
windnumberVaries by variantHorizontal wind strength. Negative values blow left.
speednumberVaries by variantFall speed multiplier.
splashesbooleanVaries by variantEnable splash particles on ground impact.
colorstring'rgba(174, 194, 224, 0.6)'CSS color string for raindrops and splashes.
groundLevelnumber1.0Normalized Y position of the ground (0-1).
scalenumber1Scales raindrop sizes proportionally.

RainVariant

typescript
type RainVariant = 'drizzle' | 'downpour' | 'thunderstorm';
VariantDropsSpeedWindSplashes
drizzle700.550.1No
downpour2000.850.25Yes
thunderstorm3001.00.4Yes

Raindrop

Internal representation of a raindrop.

typescript
type Raindrop = {
    x: number;       // Normalized X position (0-1)
    y: number;       // Normalized Y position (0-1)
    vx: number;      // Horizontal velocity (pixels/tick)
    vy: number;      // Vertical velocity (pixels/tick)
    length: number;  // Visual length in pixels
    speed: number;   // Fall speed
    depth: number;   // Parallax depth (0.3-1)
    opacity: number; // Base opacity
};