Skip to content

Sandstorm API

Sandstorm

Extends Effect.

Factory Function

typescript
createSandstorm(config ? : SandstormConfig)

Methods

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


SandstormConfig

typescript
interface SandstormConfig {
    count?: number;
    wind?: number;
    turbulence?: number;
    color?: string;
    hazeOpacity?: number;
    scale?: number;
}
PropertyTypeDefaultDescription
countnumber300Number of sand grains. Halved on small screens.
windnumber1Horizontal wind strength multiplier.
turbulencenumber1Chaotic movement intensity.
colorstring'#c2956b'CSS color string for sand and haze.
hazeOpacitynumber0.15Opacity of the atmospheric haze overlay (0-1).
scalenumber1Scales grain sizes proportionally.

SandGrain

Internal representation of a sand particle.

typescript
type SandGrain = {
    x: number;       // Normalized X position (0-1)
    y: number;       // Normalized Y position (0-1)
    vx: number;      // Horizontal velocity
    vy: number;      // Vertical velocity
    size: number;    // Grain size in pixels
    depth: number;   // Depth layer (0.2-1) for parallax
    opacity: number; // Base opacity (0.3-0.8)
};