# `Cauldron3D.Paint.Spans`
[🔗](https://github.com/jaman/cauldron/blob/v0.2.2/cauldron_3d/lib/cauldron_3d/paint/spans.ex#L1)

The RGBA pixels of one row's run of a textured polygon, for `Cauldron3D.Paint.Rgba`.

    planes = {w0, wx, uw0, uwx, vw0, vwx}
    Cauldron3D.Paint.Spans.texture({pixels, 64, 64, colours}, nil, nil, planes, {10, 90})

A texture is `{pixels, width, height, colours}`, and a run `{first, stop}`, the pixels
from `first` up to `stop`. `planes` is a row's `{w, uw, vw}` planes as `{at_x_zero, per_x}` pairs, flattened; the
texel at pixel `x` is at `floor(uw / w)`, `floor(vw / w)` taken at `x + 0.5`.
`colours` is the texture's `Cauldron3D.Texture.colours/1` table for an indexed texture,
or `nil` for an RGBA one.

`available?/0` says whether the C library loaded. Where it did not the same bytes are
made in Elixir.

# `light`

```elixir
@type light() ::
  nil | number() | {number(), number(), number()} | {:plane, number(), number()}
```

# `planes`

```elixir
@type planes() :: {number(), number(), number(), number(), number(), number()}
```

# `run`

```elixir
@type run() :: {integer(), integer()}
```

# `source`

```elixir
@type source() :: {binary(), pos_integer(), pos_integer(), binary() | nil}
```

# `available?`

```elixir
@spec available?() :: boolean()
```

Whether the library is loaded and spans are filled in C.

# `surface`

```elixir
@spec surface(source(), planes(), run()) :: binary()
```

Pixels `first` up to `stop` of a texture whose edge pixels repeat beyond it.

# `texture`

```elixir
@spec texture(source(), byte() | nil, light(), planes(), run()) :: binary()
```

Pixels `first` up to `stop` of a texture repeated both ways. A texel of index `clear`
in an indexed texture is `<<0, 0, 0, 0>>`. `light` multiplies red, green and blue: a
scale, one scale a channel, `{:plane, origin, per_x}` for the scale
`(origin + per_x * (x + 0.5)) / 128` at pixel `x`, or `nil` for none.

# `tint`

```elixir
@spec tint(binary(), integer(), tuple(), number()) :: binary()
```

`base`, RGBA pixels from column `first`, each channel multiplied by its tint plane over
`w`: `planes` is `{w0, wx, r0, rx, g0, gx, b0, bx, a0, ax}`, each taken at `x + 0.5`. A
pixel whose alpha is below `threshold` is `<<0, 0, 0, 0>>`.

---

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