# `Cauldron2D.Sheet`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d/lib/cauldron_2d/sheet.ex#L1)

A `Cauldron2D.Atlas` packed onto one raster, with an index of where every art is.

    sheet = Cauldron2D.Sheet.pack(:my_game)
    Cauldron2D.Sheet.index(sheet, "/atlas.png")

Every frame of every art is a tile on the sheet, laid out in rows of `columns/0`;
index 0 is left empty for "nothing here", so arts count from 1. `arts` maps each art
name to the index of its first frame, `frames` gives each index's pixel position on the
sheet, and `anim` maps the first index of each animated art to its indices and rate.
`index_at/3` is the index showing at a time. An art may be any term the atlas keys it
by; in the wire form it is named by `inspect/1` unless it is an atom.

# `t`

```elixir
@type t() :: %{
  tile: pos_integer(),
  columns: pos_integer(),
  rows: pos_integer(),
  arts: %{required(Cauldron2D.Atlas.art()) =&gt; pos_integer()},
  frames: [[non_neg_integer()]],
  anim: %{
    required(pos_integer()) =&gt; %{indices: [pos_integer()], fps: pos_integer()}
  },
  raster: FrenchCurve.Raster.t(),
  void: Cauldron2D.Atlas.rgb()
}
```

# `columns`

```elixir
@spec columns() :: pos_integer()
```

How many tiles wide a sheet is.

# `dimensions`

```elixir
@spec dimensions(t()) :: {pos_integer(), pos_integer()}
```

The sheet's pixel size.

# `index`

```elixir
@spec index(t(), String.t()) :: map()
```

What a client needs to draw from the sheet at `url`: the tile size, the columns, the
void colour as `#rrggbb`, the arts' indices by name, the frames' positions and the
animations keyed by their first index as a string.

# `index_at`

```elixir
@spec index_at(%{anim: map()}, pos_integer(), integer()) :: pos_integer()
```

The index showing at `at_ms` for an art whose first index is `index`; `index` itself when it is not animated.

# `pack`

```elixir
@spec pack(Cauldron2D.Atlas.t() | Cauldron2D.Atlas.name()) :: t()
```

Lay every frame of every art of `atlas` out on one raster.

---

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