Ascii.Diagram.Layout (Ascii v0.3.0)

Copy Markdown View Source

Compiled cell geometry for a diagram, reusable for drawing and hit testing.

Node, boundary, fragment, note and activation bounds use zero-based x, y, width, height. Edges retain their ordered orthogonal points and stable IDs. Bounds and routes are independent of theme and character set. frame/2 does no parsing or layout work.

Summary

Functions

Draws retained geometry. charset: :ascii | :unicode, theme: maps visual roles to inks.

The node, note, activation, edge, fragment or boundary at a cell, as {kind, id}, or nil.

Types

t()

@type t() :: %Ascii.Diagram.Layout{
  activations: map(),
  boundaries: map(),
  cols: pos_integer(),
  commands: [tuple()],
  description: String.t(),
  edges: [map()],
  fragments: map(),
  nodes: map(),
  notes: map(),
  rows: pos_integer()
}

Functions

frame(layout, opts \\ [])

@spec frame(layout :: t(), opts :: keyword()) ::
  {:ok, Ascii.Frame.t()} | Ascii.Diagram.error()

Draws retained geometry. charset: :ascii | :unicode, theme: maps visual roles to inks.

hit_at(layout, x, y)

@spec hit_at(layout :: t(), x :: integer(), y :: integer()) ::
  {atom(), String.t()} | nil

The node, note, activation, edge, fragment or boundary at a cell, as {kind, id}, or nil.