@rekurt/openkline - v0.2.0
    Preparing search index...

    Class DrawingLayer

    Ordered collection of drawings with a single "active" slot for creation in progress. Consumers drive creation via startDrawing, addPoint, and an implicit finalize when the drawing hits its required point count.

    The layer is render-only with respect to the chart — it doesn't listen to DOM events. Input handling lives in the consumer so the core stays framework-agnostic.

    Index

    Constructors

    Accessors

    • get selectedId(): string | null

      Id of the currently-selected drawing, or null.

      Returns string | null

    Methods

    • Return the topmost drawing whose rendered geometry is within tolerance pixels of the screen point (x, y), or null. Iterates in reverse paint order so the visually-frontmost drawing wins.

      Parameters

      • x: number
      • y: number
      • layout: ChartLayout
      • viewport: Viewport
      • tolerance: number = DRAWING_HIT_TOLERANCE_PX
      • maxIndex: number = Infinity

        Highest revealed index (replay cap). Drawings fully past it are skipped.

      Returns Drawing | null

    • Remove a drawing by id. Returns true if found.

      Parameters

      • id: string

      Returns boolean

    • Remove the selected drawing, if any. Returns true if one was removed.

      Returns boolean

    • Render all completed drawings plus the in-progress one.

      Parameters

      • ctx: CanvasRenderingContext2D
      • layout: ChartLayout
      • viewport: Viewport
      • theme: ThemeColors
      • maxIndex: number = Infinity

        Highest revealed index (replay cap). Drawings fully past it are hidden.

      Returns void

    • Select a drawing by id, or clear the selection with null.

      Parameters

      • id: string | null

      Returns void

    • Hit-test at (x, y) and select the topmost drawing found (or clear the selection when nothing is hit). Returns the newly-selected drawing.

      Parameters

      • x: number
      • y: number
      • layout: ChartLayout
      • viewport: Viewport
      • tolerance: number = DRAWING_HIT_TOLERANCE_PX
      • maxIndex: number = Infinity

        Highest revealed index (replay cap). A drawing fully past it can't be selected — otherwise its handles would redraw the hidden future anchors.

      Returns Drawing | null

    • Shift every anchor's buffer index by delta. Called after the buffer evicts old candles (eviction lowers every remaining candle's logical index) so drawings stay pinned to the same candles. Affects completed drawings and the in-progress one; undo history is not rewritten.

      Parameters

      • delta: number

      Returns void

    • Begin a new drawing. The drawing is immediately in the active slot but not yet in drawings. The next addPoint call pushes the first anchor; when the drawing becomes complete it is moved to drawings and active is cleared.

      Parameters

      Returns void

    • Revert the last mutation (add / remove / clear). Returns true if applied.

      Returns boolean

    • Update the last anchor of the active drawing — used during "rubber band" preview between clicks while a multi-point drawing is still in progress.

      Parameters

      Returns void

    • Register a new subclass so fromSnapshot can hydrate it.

      Parameters

      • kind: string
      • factory: DrawingFactory

      Returns void