Ratatouille v0.2.0 Ratatouille.Renderer.Canvas View Source
A canvas represents a terminal window (or a subdivision of it) and a sparse mapping of positions to cells.
A %Canvas{}
struct can be rendered to different output formats. This includes
the primary use-case of rendering to the termbox-managed window, but also
rendering to strings, which is useful for testing.
Link to this section Summary
Functions
Copies the canvas to a new one with the box consumed by the given dx
and
dy
Creates a new canvas with n
columns (from the left) consumed
Creates a new canvas with n
rows (from the top) consumed
Creates an empty canvas with the given dimensions
Copies the canvas to a new one with the box padded on each side (top, left,
bottom, right) by size
. Pass a negative size to remove padding
Link to this section Types
t()
View Source
t() :: %Ratatouille.Renderer.Canvas{
box: Ratatouille.Renderer.Box.t(),
cells: map()
}
t() :: %Ratatouille.Renderer.Canvas{ box: Ratatouille.Renderer.Box.t(), cells: map() }
Link to this section Functions
consume(canvas, dx, dy)
View Source
consume(Ratatouille.Renderer.Canvas.t(), integer(), integer()) ::
Ratatouille.Renderer.Canvas.t()
consume(Ratatouille.Renderer.Canvas.t(), integer(), integer()) :: Ratatouille.Renderer.Canvas.t()
Copies the canvas to a new one with the box consumed by the given dx
and
dy
.
The box is used to indicate the empty, renderable space on the canvas,
so this might be called with a dy
of 1 after rendering a line of text. The
box is consumed left-to-right and top-to-bottom.
consume_columns(canvas, n)
View Source
consume_columns(Ratatouille.Renderer.Canvas.t(), integer()) ::
Ratatouille.Renderer.Canvas.t()
consume_columns(Ratatouille.Renderer.Canvas.t(), integer()) :: Ratatouille.Renderer.Canvas.t()
Creates a new canvas with n
columns (from the left) consumed.
consume_rows(canvas, n)
View Source
consume_rows(Ratatouille.Renderer.Canvas.t(), integer()) ::
Ratatouille.Renderer.Canvas.t()
consume_rows(Ratatouille.Renderer.Canvas.t(), integer()) :: Ratatouille.Renderer.Canvas.t()
Creates a new canvas with n
rows (from the top) consumed.
from_dimensions(x, y)
View Source
from_dimensions(non_neg_integer(), non_neg_integer()) ::
Ratatouille.Renderer.Canvas.t()
from_dimensions(non_neg_integer(), non_neg_integer()) :: Ratatouille.Renderer.Canvas.t()
Creates an empty canvas with the given dimensions.
Examples
iex> Canvas.from_dimensions(10, 20)
%Canvas{
box: %Ratatouille.Renderer.Box{
top_left: %ExTermbox.Position{x: 0, y: 0},
bottom_right: %ExTermbox.Position{x: 9, y: 19}
},
cells: %{}
}
padded(canvas, size)
View Source
padded(Ratatouille.Renderer.Canvas.t(), integer()) ::
Ratatouille.Renderer.Canvas.t()
padded(Ratatouille.Renderer.Canvas.t(), integer()) :: Ratatouille.Renderer.Canvas.t()
Copies the canvas to a new one with the box padded on each side (top, left,
bottom, right) by size
. Pass a negative size to remove padding.
put_box(canvas, box)
View Source
put_box(Ratatouille.Renderer.Canvas.t(), Ratatouille.Renderer.Box.t()) ::
Ratatouille.Renderer.Canvas.t()
put_box(Ratatouille.Renderer.Canvas.t(), Ratatouille.Renderer.Box.t()) :: Ratatouille.Renderer.Canvas.t()
render_to_string(canvas)
View Source
render_to_string(Ratatouille.Renderer.Canvas.t()) :: String.t()
render_to_string(Ratatouille.Renderer.Canvas.t()) :: String.t()
render_to_strings(canvas)
View Source
render_to_strings(Ratatouille.Renderer.Canvas.t()) :: [String.t()]
render_to_strings(Ratatouille.Renderer.Canvas.t()) :: [String.t()]
render_to_termbox(bindings, canvas) View Source
translate(canvas, dx, dy)
View Source
translate(Ratatouille.Renderer.Canvas.t(), integer(), integer()) ::
Ratatouille.Renderer.Canvas.t()
translate(Ratatouille.Renderer.Canvas.t(), integer(), integer()) :: Ratatouille.Renderer.Canvas.t()