ElixirOpentui.Canvas (ElixirOpentui v0.2.0)

Copy Markdown View Source

User-facing drawing surface for the :frame_buffer widget type.

Cells are stored in a Map keyed by {x, y} for O(1) overwrites. The painter iterates unique cells only — no duplicate draws.

Summary

Functions

Draw a text string starting at {x, y}, advancing x per grapheme.

Create an empty canvas of the given dimensions.

Set a single cell at {x, y}. Overwrites any existing cell at that position.

Types

cell()

t()

@type t() :: %ElixirOpentui.Canvas{
  cells: %{required({integer(), integer()}) => cell()},
  height: non_neg_integer(),
  width: non_neg_integer()
}

Functions

draw_text(canvas, x, y, text, fg, bg)

@spec draw_text(
  t(),
  integer(),
  integer(),
  String.t(),
  ElixirOpentui.Color.t(),
  ElixirOpentui.Color.t()
) ::
  t()

Draw a text string starting at {x, y}, advancing x per grapheme.

new(width, height)

@spec new(non_neg_integer(), non_neg_integer()) :: t()

Create an empty canvas of the given dimensions.

set_cell(canvas, x, y, char, fg, bg)

@spec set_cell(
  t(),
  integer(),
  integer(),
  String.t(),
  ElixirOpentui.Color.t(),
  ElixirOpentui.Color.t()
) ::
  t()

Set a single cell at {x, y}. Overwrites any existing cell at that position.