Pictures for NanoKVMGo.Display: filled rectangles and text, drawn in the
order given over a background, then rendered as RGB565.
alias NanoKVMGo.Display.Canvas
Canvas.new(240, 284, Canvas.rgb(0, 0, 0))
|> Canvas.rect(0, 0, 240, 40, Canvas.rgb(0, 80, 160))
|> Canvas.text(8, 4, "NanoKVM-Go", Canvas.rgb(255, 255, 255), scale: 2)
|> Canvas.render()Text is in an 8 × 16 pixel font (Spleen) of printable ASCII, other
characters shown as ?, scaled by a whole factor.
Summary
Functions
An empty picture.
Fills a rectangle; what falls outside the picture is left out.
The picture as rows of little-endian RGB565 pixels, top to bottom, as a framebuffer takes them.
The RGB565 colour nearest to 8-bit red, green and blue.
Writes text from its top left corner; the background shows between the strokes.
The width of text in pixels, a character each Unicode code point, as
text/6 draws it.
Types
@type color() :: 0..65535
A colour in RGB565, see rgb/3.
@type t() :: %NanoKVMGo.Display.Canvas{ background: color(), height: pos_integer(), items: [item()], width: pos_integer() }
Functions
@spec new(pos_integer(), pos_integer(), color()) :: t()
An empty picture.
@spec rect(t(), integer(), integer(), non_neg_integer(), non_neg_integer(), color()) :: t()
Fills a rectangle; what falls outside the picture is left out.
The picture as rows of little-endian RGB565 pixels, top to bottom, as a framebuffer takes them.
Options
:rotate- 0 (the default) or 180 degrees, for a display mounted upside down
@spec rgb(0..255, 0..255, 0..255) :: color()
The RGB565 colour nearest to 8-bit red, green and blue.
iex> NanoKVMGo.Display.Canvas.rgb(255, 255, 255)
0xFFFF
iex> NanoKVMGo.Display.Canvas.rgb(255, 0, 0)
0xF800
Writes text from its top left corner; the background shows between the strokes.
Options
:scale- the size, 1 for 8 × 16 pixels a character (the default)
@spec text_width(String.t(), pos_integer()) :: non_neg_integer()
The width of text in pixels, a character each Unicode code point, as
text/6 draws it.
iex> NanoKVMGo.Display.Canvas.text_width("NanoKVM", 2)
112