ASCIIGround - v1.1.2
    Preparing search index...

    Class Pattern<TOptions>Abstract

    Base class for all pattern generators in ASCIIGround.

    This abstract class provides the foundation for creating animated ASCII patterns. It handles option management, lifecycle methods, and defines the interface that all patterns must implement.

    Patterns are responsible for generating arrays of CharacterData objects that define what characters to render and where. The base class handles common functionality like option updates and dirty state tracking.

    interface CustomPatternOptions extends PatternOptions {
    speed: number;
    amplitude: number;
    }

    class CustomPattern extends Pattern<CustomPatternOptions> {
    public static readonly ID = 'custom';

    public generate(context: PatternContext): CharacterData[] {
    // Implementation here
    return [];
    }

    public update(context: PatternContext): Pattern {
    // Update pattern state
    return this;
    }
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Accessors

    Constructors

    Methods

    • Update pattern options without recreating the pattern instance. Override this method if your pattern has expensive initialization that should be preserved.

      Parameters

      • newOptions: Partial<TOptions>

        partial options to update

      Returns void

    • Called when the pattern is initialized or resized. Use this to set up any internal state or precompute values.

      Parameters

      • _region: RenderRegion

        the rendering region including visible area and padding.

      Returns void

    • Called when the pattern is destroyed. Use this to clean up resources, cancel timers, etc.

      Returns void

    • Handle mouse interactions with the pattern. Override to implement custom mouse effects.

      Parameters

      • _x: number

        mouse X position relative to canvas.

      • _y: number

        mouse Y position relative to canvas.

      • _clicked: boolean

        Whether mouse was clicked this frame.

      Returns void

    Properties

    ID: string

    Unique identifier for the pattern, that should be overridden in subclasses.

    _options: TOptions

    Options for the pattern, initialized with default values.

    _isDirty: boolean = false

    Flag indicating if the pattern needs to be re-rendered. This is set to true when pattern options change in a way that required re-render (e.g. color change).