# `Cauldron2D.Render`
[🔗](https://github.com/jaman/cauldron/blob/v0.2.2/cauldron_2d/lib/cauldron_2d/render.ex#L1)

A frame drawn once from a list of operations.

    Cauldron2D.Render.render({320, 200}, [
      {:raster, backdrop, {0, 0}},
      {:sprite, knight, %{position: {120.5, 88}, origin: {9, 28}, scale: {-1, 1}}}
    ], background: {20, 20, 40, 255})

Each operation is drawn by what its shape says it is:

  * `{:sprite, picture, placement}` — a picture placed as `Cauldron2D.Blend.draw/6`
    takes a placement: position, origin, scale, angle, blend, alpha
  * `{:raster, picture, {x, y}}` — a picture drawn as it is, its top-left corner at
    `{x, y}`

A picture is a `FrenchCurve.Raster` or `{width, height, rgba}`. Operations draw in
list order, each over what came before.

The frame is made once and drawn in bands of rows, each band drawn by one call that
lays every operation over it in place: four bands by default, fewer where there are
fewer schedulers. Where the C library is loaded the bands are drawn in C; where it is not, or with `native: false`,
in Elixir, to the same pixels. The number of bands never changes the result.

Options:

  * `:background` — what the frame starts as: a colour `{r, g, b, a}`, or a picture
    the frame's size; default transparent
  * `:format` — `:rgba` (default) gives a `FrenchCurve.Raster`; `:rgb` gives the
    pixels as a binary of three bytes each, alpha dropped
  * `:bands` — how many bands to draw at once
  * `:native` — `false` draws in Elixir

# `operation`

```elixir
@type operation() ::
  {:sprite, picture(), map()} | {:raster, picture(), {integer(), integer()}}
```

# `picture`

```elixir
@type picture() :: FrenchCurve.Raster.t() | {pos_integer(), pos_integer(), binary()}
```

# `render`

```elixir
@spec render({pos_integer(), pos_integer()}, [operation()], keyword()) ::
  FrenchCurve.Raster.t() | binary()
```

The frame `{width, height}` pixels in size with `operations` drawn on it.

---

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