vivid v0.1.1 Vivid.Frame
A frame buffer or something.
Summary
Functions
Return the colour depth of the frame
Clear the frame of any shapes
Return the height of the frame
Initialize a frame buffer
Add a shape to the frame buffer
Print the frame buffer to stdout for debugging
Convert a frame buffer to a string for debugging
Return the width of the frame
Functions
Return the colour depth of the frame.
Example
iex> Vivid.Frame.init(80, 25) |> Vivid.Frame.background_colour
#Vivid.RGBA<{0, 0, 0, 0}>
Initialize a frame buffer.
width
the width of the frame, in pixels.height
the height of the frame, in pixels.colour
the default colour of the frame.
Example
iex> Vivid.Frame.init(4, 4)
#Vivid.Frame<[width: 4, height: 4, background_colour: #Vivid.RGBA<{0, 0, 0, 0}>]>
Add a shape to the frame buffer.
Examples
iex> Vivid.Frame.init(5,5)
...> |> Vivid.Frame.push(Vivid.Line.init(Vivid.Point.init(1,1), Vivid.Point.init(3,3)), Vivid.RGBA.white)
...> |> Vivid.Frame.to_string
" \n" <>
" @ \n" <>
" @ \n" <>
" @ \n" <>
" \n"
iex> Vivid.Frame.init(5,5)
...> |> Vivid.Frame.push(
...> Vivid.Path.init([
...> Vivid.Point.init(1,1),
...> Vivid.Point.init(1,3),
...> Vivid.Point.init(3,3),
...> Vivid.Point.init(3,1),
...> ]), Vivid.RGBA.white
...> )
...> |> Vivid.Frame.to_string
" \n" <>
" @@@ \n" <>
" @ \n" <>
" @@@ \n" <>
" \n"
iex> Vivid.Frame.init(5,5)
...> |> Vivid.Frame.push(
...> Vivid.Polygon.init([
...> Vivid.Point.init(1,1),
...> Vivid.Point.init(1,3),
...> Vivid.Point.init(3,3),
...> Vivid.Point.init(3,1),
...> ]), Vivid.RGBA.white
...> )
...> |> Vivid.Frame.to_string
" \n" <>
" @@@ \n" <>
" @ @ \n" <>
" @@@ \n" <>
" \n"
iex> circle = Vivid.Circle.init(Vivid.Point.init(5,5), 4)
...> Vivid.Frame.init(11, 10)
...> |> Vivid.Frame.push(circle, Vivid.RGBA.white)
...> |> Vivid.Frame.to_string
" @@@ \n" <>
" @@ @@ \n" <>
" @ @ \n" <>
" @ @ \n" <>
" @ @ \n" <>
" @ @ \n" <>
" @ @ \n" <>
" @@ @@ \n" <>
" @@@ \n" <>
" \n"
iex> line = Vivid.Line.init(Vivid.Point.init(0,0), Vivid.Point.init(50,50))
...> Vivid.Frame.init(5,5)
...> |> Vivid.Frame.push(line, Vivid.RGBA.white)
...> |> Vivid.Frame.to_string
" @\n" <>
" @ \n" <>
" @ \n" <>
" @ \n" <>
"@ \n"