Skip to content

Matrix API

Matrix

Extends Effect.

Factory Function

typescript
createMatrix(config?: MatrixConfig)

Methods

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


MatrixConfig

typescript
interface MatrixConfig {
    columns?: number;
    speed?: number;
    color?: string;
    fontSize?: number;
    trailLength?: number;
    scale?: number;
}
PropertyTypeDefaultDescription
columnsnumber40Maximum number of active falling columns. Automatically halved on small screens.
speednumber1Fall speed multiplier. Higher values make characters fall faster.
colorstring'#00ff41'Hex color string for the trailing characters. The head character is always white.
fontSizenumber14Character size in pixels. Also determines column spacing. Scaled by scale.
trailLengthnumber20Base number of characters per column trail. Actual length varies randomly.
scalenumber1Scales font size proportionally.

MatrixColumn

Internal representation of a falling column.

typescript
type MatrixColumn = {
    x: number;              // X position in pixels (center of column)
    y: number;              // Y position of the head character in pixels
    speed: number;          // Fall speed of this column
    chars: string[];        // Array of characters in the trail
    length: number;         // Number of characters in the trail
    headBrightness: number; // Brightness of the head character (0.8-1.0)
};