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

Where everything goes on a canvas: the map's tiles around the focus and the movers, as
sheet indices at pixel positions, for a frame and map in the shapes `Cauldron2D.Net.Wire`
gives.

    Cauldron2D.Wx.Painter.blits(frame, map, {width, height}, scale)

The focus sits at the centre of the canvas, at a map's edge and past it alike; a map
that wraps repeats around it. `scale` is the pixel size of a tile.

# `blit`

```elixir
@type blit() :: {non_neg_integer(), integer(), integer()}
```

# `frame`

```elixir
@type frame() :: %{
  focus: {number(), number()},
  movers: [{non_neg_integer(), number(), number()}]
}
```

# `map_layer`

```elixir
@type map_layer() :: %{
  width: pos_integer(),
  height: pos_integer(),
  wrap: boolean(),
  rows: [[non_neg_integer()]]
}
```

# `blits`

```elixir
@spec blits(frame(), map_layer(), {pos_integer(), pos_integer()}, pos_integer()) :: [
  blit()
]
```

Every tile and mover in view, bottom to top, as `{index, x, y}` in pixels.

# `cell_blits`

```elixir
@spec cell_blits(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer(),
  MapSet.t()
) :: [
  blit()
]
```

The tiles in view whose index is one of `indices`, as `{index, x, y}` in pixels: the cells a layer left out.

# `label_blits`

```elixir
@spec label_blits(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer(),
  {number(), number()}
) :: [{integer(), integer()}]
```

Where a label at world position `at` lands on the canvas, in pixels: once, or on every copy in view of a wrapping map.

# `layer_blits`

```elixir
@spec layer_blits(map_layer(), pos_integer(), keyword()) :: [blit()]
```

Every tile of the map once, as `{index, x, y}` in pixels from the map's top-left
corner: what a layer of the whole map is drawn from. `except:` is a set of indices to
leave out, for cells drawn every frame instead.

# `layer_offsets`

```elixir
@spec layer_offsets(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer()
) :: [
  {integer(), integer()}
]
```

Where a layer of the whole map goes on the canvas for `frame`: one pixel offset, or every copy in view of a wrapping map.

# `mover_blits`

```elixir
@spec mover_blits(frame(), map_layer(), {pos_integer(), pos_integer()}, pos_integer()) ::
  [blit()]
```

The movers in view, as `{index, x, y}` in pixels.

# `origin`

```elixir
@spec origin(frame(), map_layer(), {pos_integer(), pos_integer()}, pos_integer()) ::
  {float(), float()}
```

The world position at the canvas's top-left corner.

# `world_at`

```elixir
@spec world_at(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer(),
  {number(), number()}
) :: {float(), float()}
```

The world position under a canvas point.

# `zoom_about`

```elixir
@spec zoom_about(
  frame(),
  map_layer(),
  {pos_integer(), pos_integer()},
  pos_integer(),
  pos_integer(),
  {number(), number()}
) :: {float(), float()}
```

The focus that keeps the world under canvas point `{cx, cy}` there when the tile goes from `from` to `to` pixels.

---

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