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

A polygon made ready for drawing: clipped to the near plane, projected, and reduced to
the rows it covers, its edges, and a plane `{at_origin, per_x, per_y}` for each
attribute across the picture.

    Cauldron3D.Setup.new(view, polygon)
    #=> %Cauldron3D.Setup{} | nil

`nil` is a polygon that cannot be seen: wholly behind the near plane, facing away
under its `cull`, edge-on, or outside the picture.

The attributes are `:near` (grows toward the camera), `:w` (see `Cauldron3D.View`),
`:uw` and `:vw` (the paint position times `w`), `:light` (carried straight across
the picture, or `nil`) and `:tint` (four planes, each of red, green, blue and alpha
times `w`, or `nil`). Rows are sampled at their centres.

A polygon drawn with `depth: :near_third` has its `:near` plane moved into the nearest
third of the depth range: `0.333 * near + 0.6665 / view.near`.

# `edge`

```elixir
@type edge() :: {float(), float(), float(), float()}
```

# `plane`

```elixir
@type plane() :: {float(), float(), float()}
```

# `t`

```elixir
@type t() :: %Cauldron3D.Setup{
  alpha_test: float() | nil,
  blend: Cauldron3D.Polygon.blend(),
  bottom: non_neg_integer(),
  clear: byte() | nil,
  depth: :test | :always,
  edges: [edge()],
  light: plane() | nil,
  near: plane(),
  nearest: float(),
  paint: term(),
  tint: {plane(), plane(), plane(), plane()} | nil,
  top: non_neg_integer(),
  uw: plane(),
  vw: plane(),
  w: plane()
}
```

# `at`

```elixir
@spec at(plane(), number(), number()) :: float()
```

The value of an attribute plane at the centre of pixel `{x, y}`.

# `new`

```elixir
@spec new(Cauldron3D.View.t(), Cauldron3D.Polygon.t()) :: t() | nil
```

The polygon ready to draw in `view`, or `nil` when it cannot be seen.

# `opaque?`

```elixir
@spec opaque?(t()) :: boolean()
```

Whether an overlay setup hides what is behind it where it is drawn.

# `overlay?`

```elixir
@spec overlay?(t()) :: boolean()
```

Whether the setup is drawn over the solid polygons rather than among them.

# `span`

```elixir
@spec span(t(), integer(), pos_integer()) :: {integer(), integer()} | nil
```

The pixels row `y` covers, as `{first, last}` columns inside a picture `width` wide,
or `nil` when it covers none.

---

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