Skip to content

Spirograph API

Spirograph

Extends Effect.

Factory Function

typescript
createSpirograph(config?: SpirographConfig)

Methods

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


SpirographConfig

typescript
interface SpirographConfig {
    speed?: number;
    curves?: number;
    colors?: string[];
    lineWidth?: number;
    fadeSpeed?: number;
    complexity?: number;
    scale?: number;
}
PropertyTypeDefaultDescription
speednumber1Drawing speed multiplier.
curvesnumber3Number of simultaneous spirograph curves.
colorsstring[]['#ff3366', '#33aaff', '#ffcc00', '#66ff99', '#cc66ff', '#ff6633']Colors assigned to curves, cycling if fewer than curves.
lineWidthnumber1.5Stroke width in pixels (before scale).
fadeSpeednumber0.003Rate at which a curve ages — higher values replace patterns faster.
complexitynumber5Controls the range of gear ratio denominators used.
scalenumber1Global scale factor.

SpirographCurve

Internal representation of a single spirograph curve.

typescript
type SpirographCurve = {
    outerRadius: number;
    innerRadius: number;
    penOffset: number;
    phase: number;
    color: string;
    colorRGB: [number, number, number];
    points: Point[];
    pointHead: number;
    maxPoints: number;
    age: number;
    maxAge: number;
};