Cauldron2D.Drafter.Sprites (Cauldron2D.Drafter v0.1.3)

Copy Markdown View Source

An atlas's art as stored kitty images, transmitted once and placed many times.

Drafter.Compositor.write_raw(Cauldron2D.Drafter.Sprites.transmit(:my_game))

Every frame of every art in the atlas gets a stable image id from image_id/3, so a surface can place it by id on any later frame without sending pixels again. Transmit once per session, and again after anything that empties the terminal's image store or changes the atlas.

Summary

Functions

The kitty image id under which the first frame of art of atlas is stored; the same on every call.

The kitty image id of the frame of art showing at at_ms.

The kitty image id of text drawn in colour at scale by Linocut.Font, the same on every call.

The bytes that store text drawn in colour at scale under its label_id/4.

raster at {width, height} pixels, each output pixel the nearest source pixel; the raster itself at its own size or with nil.

The bytes that store every frame of every art of atlas in the terminal, without displaying any.

Functions

image_id(atlas, art)

The kitty image id under which the first frame of art of atlas is stored; the same on every call.

image_id(atlas, art, at_ms)

The kitty image id of the frame of art showing at at_ms.

label_id(atlas, text, colour, scale)

The kitty image id of text drawn in colour at scale by Linocut.Font, the same on every call.

label_transmit(atlas, text, colour, scale, opts \\ [])

The bytes that store text drawn in colour at scale under its label_id/4.

resampled(raster, arg2)

@spec resampled(FrenchCurve.Raster.t(), {pos_integer(), pos_integer()} | nil) ::
  FrenchCurve.Raster.t()

raster at {width, height} pixels, each output pixel the nearest source pixel; the raster itself at its own size or with nil.

transmit(atlas, opts \\ [])

@spec transmit(Cauldron2D.Atlas.name() | Cauldron2D.Atlas.t(), keyword()) :: iodata()

The bytes that store every frame of every art of atlas in the terminal, without displaying any.

Options

  • :size{width, height} in pixels to store each sprite at, resampled nearest-neighbour once here, so a placement of that size is drawn pixel for pixel and the terminal scales nothing. Default: the sprite's own size
  • :compress — zlib each transmit. Default true