From 12d0903a778394e1253fe239422576e0e3c93f05 Mon Sep 17 00:00:00 2001 From: James Harton Date: Thu, 29 Dec 2016 10:05:49 +1300 Subject: [PATCH] Add some documenation to Frame. --- lib/vivid/frame.ex | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/vivid/frame.ex b/lib/vivid/frame.ex index 4ccd8c3..0e107b3 100644 --- a/lib/vivid/frame.ex +++ b/lib/vivid/frame.ex @@ -9,6 +9,10 @@ defmodule Vivid.Frame do @doc """ Initialize a frame buffer. + * `width` the width of the frame, in pixels. + * `height` the height of the frame, in pixels. + * `colour_depth` the colour depth of the frame, in bits. + ## Example iex> Vivid.Frame.init(4, 4, 1) @@ -108,6 +112,36 @@ defmodule Vivid.Frame do %{frame | buffer: buffer} end + @doc """ + Return the width of the frame. + + ## Example + + iex> Vivid.Frame.init(80, 25, 4) |> Vivid.Frame.width + 80 + """ + def width(%Frame{width: w}), do: w + + @doc """ + Return the height of the frame. + + ## Example + + iex> Vivid.Frame.init(80, 25, 4) |> Vivid.Frame.height + 25 + """ + def height(%Frame{height: h}), do: h + + @doc """ + Return the colour depth of the frame. + + ## Example + + iex> Vivid.Frame.init(80, 25, 4) |> Vivid.Frame.colour_depth + 4 + """ + def colour_depth(%Frame{colour_depth: d}), do: d + @doc ~S""" Convert a frame buffer to a string for debugging.