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

A sprite sheet PNG as wx bitmaps: the sheet scaled up once with nearest-neighbour
sampling, and a bitmap per index cut from it on first use.

    sheet = Cauldron2D.Wx.Sheet.load(index, png, 2)
    bitmap = Cauldron2D.Wx.Sheet.bitmap(sheet, 7)

`index` is what `Cauldron2D.Net.Wire.sheet/1` gives; `png` the bytes; the scale the
pixels a sheet pixel becomes. Needs a running wx. The cut bitmaps are kept in a
public ETS table, so any process with the wx environment can draw from the sheet:
the sheet's own, or one given as `:bitmaps` and shared by many sheets, which then
lives as long as its owner rather than any one sheet — a painter in another process
can hold a sheet the loader has moved on from and still draw it.

# `t`

```elixir
@type t() :: %Cauldron2D.Wx.Sheet{
  anim: map(),
  bitmaps: :ets.table(),
  frames: [{integer(), integer()}],
  id: integer(),
  image: term(),
  scale: number(),
  tile: pos_integer(),
  void: {byte(), byte(), byte()}
}
```

# `animated`

```elixir
@spec animated(t()) :: MapSet.t()
```

The indices the sheet animates: the first index of every animated art.

# `bitmap`

```elixir
@spec bitmap(t(), non_neg_integer()) :: term() | nil
```

The bitmap for `index`, cut on first use; `nil` for an index the sheet has not got.

# `bitmap_at`

```elixir
@spec bitmap_at(t(), non_neg_integer(), integer()) :: term() | nil
```

The bitmap for `index` as it shows at `at_ms`, following the sheet's animations.

# `load`

```elixir
@spec load(
  %{tile: pos_integer(), frames: [{integer(), integer()}]},
  binary(),
  number(),
  keyword()
) ::
  t()
```

Load the sheet, scaled `scale` times — a whole number, or a fraction such as 0.25 that
leaves a tile a whole number of pixels. `:bitmaps` is an ETS table to keep the cut
bitmaps in; default a new one of the sheet's own.

# `pixels`

```elixir
@spec pixels(t()) :: pos_integer()
```

The pixel size of a tile on this sheet.

# `unload`

```elixir
@spec unload(t()) :: :ok
```

Let the sheet's cut bitmaps go, leaving the table to any other sheet sharing it.

---

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