Ascii.Meta (Ascii v0.3.0)

Copy Markdown View Source

What a piece is: upstream's meta, field for field.

name is the lowercase display name, note one lowercase line saying what you see. Every frame is exactly rows lines of cols characters, played at fps frames a second (0 for a still). options holds the default of every option, keyed by atom. clock is true when the picture reads the real time. A coloured piece has a palette of #rrggbb colours, which its colour indices point into, and scenes a ground behind them. cell is a cell's height in cell widths on a canvas: 2, the shape of a character, or 1.

bounds is this port's own addition: the range each numeric option is clamped to when it comes from outside (see Ascii.Options); for an option that holds lists or maps, a range for every number within it, or a map of ranges by key. So is loop: for a piece that closes a loop, the seconds after which its frames come round again exactly, with its default options and frame rate (measured by tools/loops.exs, held by a test). Ascii.loop/1 gives the frames of one cycle, which a player can repeat rather than draw anew. And shapes: for an option whose default cannot show what it takes (an empty list that takes numbers, a series that may carry its own values), an example of what it takes, which Ascii.Options checks against instead. And parts: for a piece in one ink that labels its frames' cells (see Ascii.Parts), the names of its parts, in the order they read best, each with the colour it suggests for it, or nil.

cols and rows are the size with the default options. A piece whose size follows its options (see Ascii.Piece.size/1) can be another size; a frame's own cols and rows always say.

Summary

Types

A range, or ranges by key for the maps an option holds.

One of the fourteen upstream categories.

t()

Functions

The fourteen categories, in upstream's order.

Whether the piece draws in colour.

Types

bound()

@type bound() :: {number(), number()} | %{optional(atom()) => bound()}

A range, or ranges by key for the maps an option holds.

category()

@type category() ::
  :scenes
  | :shapes
  | :space
  | :physics
  | :nature
  | :creatures
  | :objects
  | :generative
  | :effects
  | :ui
  | :data
  | :type
  | :logos
  | :distros

One of the fourteen upstream categories.

t()

@type t() :: %Ascii.Meta{
  bounds: %{optional(atom()) => bound()},
  category: category(),
  cell: 1 | 2,
  clock: boolean(),
  cols: pos_integer(),
  fps: 0..60,
  ground: String.t() | nil,
  loop: number() | nil,
  name: String.t(),
  note: String.t(),
  options: %{optional(atom()) => term()},
  palette: [String.t()] | nil,
  parts: [{String.t(), String.t() | nil}],
  rows: pos_integer(),
  shapes: %{optional(atom()) => term()}
}

Functions

categories()

@spec categories() :: [category()]

The fourteen categories, in upstream's order.

colored?(meta)

@spec colored?(meta :: t()) :: boolean()

Whether the piece draws in colour.