vivid v0.4.2 Vivid.Buffer View Source
Used to convert a Frame into a buffer for display.
You’re unlikely to need to use this module directly, instead you will
likely want to use Frame.buffer/2
instead.
Buffer implements the Enumerable
protocol.
Example
iex> use Vivid
...> box = Box.init(Point.init(1,1), Point.init(18,8))
...> Frame.init(20, 10, RGBA.white())
...> |> Frame.push(box, RGBA.black())
...> |> Buffer.horizontal()
...> |> Stream.chunk(20)
...> |> Stream.map(fn line ->
...> Stream.map(line, fn colour -> RGBA.to_ascii(colour) end)
...> |> Enum.join()
...> end)
...> |> Enum.join("\n")
"@@@@@@@@@@@@@@@@@@@@\n" <>
"@ @\n" <>
"@ @@@@@@@@@@@@@@@@ @\n" <>
"@ @@@@@@@@@@@@@@@@ @\n" <>
"@ @@@@@@@@@@@@@@@@ @\n" <>
"@ @@@@@@@@@@@@@@@@ @\n" <>
"@ @@@@@@@@@@@@@@@@ @\n" <>
"@ @@@@@@@@@@@@@@@@ @\n" <>
"@ @\n" <>
"@@@@@@@@@@@@@@@@@@@@"
Link to this section Summary
Functions
Returns the number of columns in the buffer
Render the buffer horizontally, ie across rows then up columns
Returns the number of rows in the buffer
Render the buffer vertically, ie up columns then across rows
Link to this section Types
Link to this section Functions
Returns the number of columns in the buffer.
Render the buffer horizontally, ie across rows then up columns.
Example
iex> use Vivid
...> Frame.init(5, 5, RGBA.white)
...> |> Frame.push(Line.init(Point.init(0, 2), Point.init(5, 2)), RGBA.black)
...> |> Buffer.horizontal
...> |> to_string
"@@@@@\n" <>
"@@@@@\n" <>
" \n" <>
"@@@@@\n" <>
"@@@@@\n"
Returns the number of rows in the buffer.
Render the buffer vertically, ie up columns then across rows.
Example
iex> use Vivid
...> Frame.init(5, 5, RGBA.white)
...> |> Frame.push(Line.init(Point.init(0, 2), Point.init(5, 2)), RGBA.black)
...> |> Buffer.vertical
...> |> to_string
"@@ @@\n" <>
"@@ @@\n" <>
"@@ @@\n" <>
"@@ @@\n" <>
"@@ @@\n"