# `Cauldron2D.Drafter.Sprites`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d_drafter/lib/cauldron_2d/drafter/sprites.ex#L1)

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.

# `image_id`

```elixir
@spec image_id(Cauldron2D.Atlas.name() | Cauldron2D.Atlas.t(), Cauldron2D.Atlas.art()) ::
  pos_integer()
```

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

# `image_id`

```elixir
@spec image_id(
  Cauldron2D.Atlas.name() | Cauldron2D.Atlas.t(),
  Cauldron2D.Atlas.art(),
  integer()
) ::
  pos_integer()
```

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

# `label_id`

```elixir
@spec label_id(
  Cauldron2D.Atlas.name() | Cauldron2D.Atlas.t(),
  String.t(),
  Cauldron2D.Atlas.rgb(),
  pos_integer()
) :: pos_integer()
```

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

# `label_transmit`

```elixir
@spec label_transmit(
  Cauldron2D.Atlas.name() | Cauldron2D.Atlas.t(),
  String.t(),
  Cauldron2D.Atlas.rgb(),
  pos_integer(),
  keyword()
) :: iodata()
```

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

# `resampled`

```elixir
@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`

```elixir
@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`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
