# `Cauldron3D.Texture`
[🔗](https://github.com/jaman/cauldron/blob/v0.2.2/cauldron_3d/lib/cauldron_3d/texture.ex#L1)

A picture, rows top to bottom: indexed colour, one byte per pixel and optionally its
own palette, or RGBA, four bytes per pixel.

    Cauldron3D.Texture.new(64, 64, pixels)
    Cauldron3D.Texture.new(64, 64, pixels, palette)
    Cauldron3D.Texture.rgba(64, 64, rgba_pixels)
    Cauldron3D.Texture.at(texture, 3, 7)

`palette` is 768 bytes of red, green and blue, or `nil` for an indexed texture whose
indices are into the palette of whatever it is drawn on; `colours` is that palette as
1024 bytes of RGBA, four a colour (`colour/2` reads one). An RGBA texture's alpha is 0 where it is see-through.

# `t`

```elixir
@type t() :: %Cauldron3D.Texture{
  colours: binary() | nil,
  format: :indexed | :rgba,
  height: pos_integer(),
  palette: binary() | nil,
  pixels: binary(),
  width: pos_integer()
}
```

# `at`

```elixir
@spec at(t(), integer(), integer()) :: byte()
```

The colour index at `{x, y}` of an indexed texture, wrapping both ways.

# `colour`

```elixir
@spec colour(binary(), byte()) :: binary()
```

Colour `index` of `colours/1`'s table, as four bytes of RGBA.

# `colours`

```elixir
@spec colours(binary()) :: binary()
```

A 768-byte palette as 1024 bytes of opaque RGBA, four a colour.

# `new`

```elixir
@spec new(pos_integer(), pos_integer(), binary()) :: t()
```

An indexed texture of `width` by `height` from its pixels. Raises `ArgumentError` when the sizes disagree.

# `new`

```elixir
@spec new(pos_integer(), pos_integer(), binary(), binary()) :: t()
```

An indexed texture of `width` by `height` from its pixels and its own 768-byte `palette`.

# `rgba`

```elixir
@spec rgba(pos_integer(), pos_integer(), binary()) :: t()
```

An RGBA texture of `width` by `height`. Raises `ArgumentError` when the sizes disagree.

# `split`

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

The texture with `left` columns from its left edge, as two textures `{left, rest}`.

---

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