Raxol. UI. Charts. BrailleCanvas
(Raxol v2.6.0)
View Source
A dot-addressable canvas that renders to Unicode braille characters.
Each terminal character maps to a 2x4 dot region, giving 2x horizontal and 4x vertical resolution compared to character-grid rendering.
Supports multiple named layers for multicolor output: each layer's dots are independently tracked, then merged into braille codepoints at render time. The foreground color of each character cell goes to the layer with the most dots in that cell's 2x4 region.
Summary
Functions
Returns the dot-resolution dimensions {dot_width, dot_height}.
Creates a new canvas sized in terminal characters.
Dot resolution is {width * 2, height * 4}.
Places a dot at {dot_x, dot_y} on the given layer.
Out-of-bounds dots are silently ignored.
Converts the canvas to cell tuples with a single foreground color. All layers' dots contribute to the braille codepoint.
Converts the canvas to cell tuples with per-layer colors.
Types
@type cell() :: Raxol.UI.Charts.ChartUtils.cell()
@type t() :: %Raxol.UI.Charts.BrailleCanvas{ height: pos_integer(), layers: %{ required(term()) => MapSet.t({non_neg_integer(), non_neg_integer()}) }, width: pos_integer() }
Functions
@spec get_dimensions(t()) :: {pos_integer(), pos_integer()}
Returns the dot-resolution dimensions {dot_width, dot_height}.
@spec new(pos_integer(), pos_integer()) :: t()
Creates a new canvas sized in terminal characters.
Dot resolution is {width * 2, height * 4}.
@spec put_dot(t(), non_neg_integer(), non_neg_integer(), term()) :: t()
Places a dot at {dot_x, dot_y} on the given layer.
Out-of-bounds dots are silently ignored.
@spec to_cells(t(), {non_neg_integer(), non_neg_integer()}, atom()) :: [cell()]
Converts the canvas to cell tuples with a single foreground color. All layers' dots contribute to the braille codepoint.
@spec to_cells_multicolor( t(), {non_neg_integer(), non_neg_integer()}, %{required(term()) => atom()} ) :: [cell()]
Converts the canvas to cell tuples with per-layer colors.
color_map maps layer_id => color_atom. Each character cell's fg color
is assigned to whichever layer has the most dots in that cell's 2x4 region.
Ties are broken by the order of layers in the color_map (earlier wins).
The braille codepoint is the bitwise OR of all layers' dots.