Lightning API
Lightning
Extends Effect.
Factory Function
typescript
createLightning(config?: LightningConfig)Methods
See Effect for the full method reference: mount(), start(), pause(), resume(), configure(), withFade(), and destroy().
LightningConfig
typescript
interface LightningConfig {
frequency?: number;
color?: string;
branches?: boolean;
flash?: boolean;
scale?: number;
}| Property | Type | Default | Description |
|---|---|---|---|
frequency | number | 1 | Bolt spawn rate multiplier. 1 means roughly one bolt every 3 seconds. |
color | string | '#b4c8ff' | Hex color string for the bolt glow. The inner line is always white. |
branches | boolean | true | Enable smaller branch bolts forking off the main bolt. |
flash | boolean | true | Enable a brief white screen flash when a bolt strikes. |
scale | number | 1 | Global scale factor for line widths. |
LightningBolt
Internal representation of a lightning bolt.
typescript
type LightningBolt = {
segments: { x: number; y: number }[]; // Normalized positions (0-1)
branches: LightningBranch[]; // Forked sub-bolts
alpha: number; // Current opacity (1 to 0)
lifetime: number; // Total lifetime in ticks
ticksAlive: number; // Ticks since spawn
};LightningBranch
Internal representation of a branch forking off a main bolt.
typescript
type LightningBranch = {
segments: { x: number; y: number }[]; // Normalized positions (0-1)
alpha: number; // Branch opacity relative to parent
};