Linocut.Pic (Linocut v0.1.3)

Copy Markdown View Source

A picture kept in a file: a palette, a blank line, and the picture.

R #c33
W white

..RR..
.RWWR.

Each palette line is one character, a space, and a colour as Linocut.Palette reads it: #rgb, #rrggbb, #rrggbbaa or a colour name. . and space in the picture are transparent. parse/2 takes Linocut.sprite/3's options.

Summary

Functions

The frames the text describes, one raster each, or why it could not be read.

The raster the text describes, or why it could not be read.

The text as data, nothing rendered: the palette as {key, colour_spec} pairs in the order written, and the frames as their rows of keys. write/1 turns it back.

The line that separates frames in a pic.

The text of a picture given as read/1 gives it.

Types

text()

@type text() :: %{palette: [{String.t(), String.t()}], frames: [[String.t()]]}

Functions

frames(text, opts \\ [])

@spec frames(String.t(), keyword()) ::
  {:ok, [FrenchCurve.Raster.t()]} | {:error, term()}

The frames the text describes, one raster each, or why it could not be read.

parse(text, opts \\ [])

@spec parse(String.t(), keyword()) :: {:ok, FrenchCurve.Raster.t()} | {:error, term()}

The raster the text describes, or why it could not be read.

Frames separated by a --- line come back as one raster with the frames side by side, left to right, as a strip; frames/2 gives them one by one.

read(text)

@spec read(String.t()) :: {:ok, text()} | {:error, term()}

The text as data, nothing rendered: the palette as {key, colour_spec} pairs in the order written, and the frames as their rows of keys. write/1 turns it back.

Examples

iex> Linocut.Pic.read("R #c33\n\n.R\nR.\n---\nR.\n.R\n")
{:ok, %{palette: [{"R", "#c33"}], frames: [[".R", "R."], ["R.", ".R"]]}}

separator()

@spec separator() :: String.t()

The line that separates frames in a pic.

write(map)

@spec write(text()) :: String.t()

The text of a picture given as read/1 gives it.