Skip to content

Stars API

Stars

Extends Effect.

Factory Function

typescript
createStars(config?: StarsConfig)

Methods

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


StarsConfig

typescript
interface StarsConfig {
    mode?: StarMode;
    starCount?: number;
    shootingInterval?: [number, number];
    shootingSpeed?: number;
    twinkleSpeed?: number;
    color?: string;
    shootingColor?: string;
    trailLength?: number;
    scale?: number;
}
PropertyTypeDefaultDescription
modeStarMode'both'Which layers to display.
starCountnumber150Number of twinkling background stars. Automatically halved on small screens.
shootingInterval[number, number][120, 360]Tick range between shooting star spawns.
shootingSpeednumber1Shooting star speed multiplier.
twinkleSpeednumber1Twinkle animation speed multiplier.
colorstring'#ffffff'Star color (hex string).
shootingColorstring'#ffffff'Shooting star color (hex string).
trailLengthnumber15Number of trail points per shooting star.
scalenumber1Global scale factor.

StarMode

typescript
type StarMode = 'sky' | 'shooting' | 'both';
ModeDescription
skyOnly twinkling background stars.
shootingOnly shooting stars with trails.
bothBoth twinkling stars and shooting stars.

Star

Internal representation of a background star.

typescript
type Star = {
    x: number;           // Normalized X position (0-1)
    y: number;           // Normalized Y position (0-1)
    size: number;        // Radius in pixels
    twinklePhase: number; // Phase offset for twinkle
    twinkleSpeed: number; // Individual twinkle speed
    brightness: number;   // Base brightness (0-1)
};

ShootingStar

Internal representation of a shooting star.

typescript
type ShootingStar = {
    x: number;    // X position in pixels
    y: number;    // Y position in pixels
    vx: number;   // Horizontal velocity
    vy: number;   // Vertical velocity
    alpha: number; // Current opacity
    size: number;  // Head radius
    decay: number; // Alpha decay per frame
    trail: { x: number; y: number }[]; // Trail positions
};