# `Cauldron2D.Drafter.Surface.Patch`
[🔗](https://github.com/jaman/cauldron/blob/v0.2.2/cauldron_2d_drafter/lib/cauldron_2d/drafter/surface/patch.ex#L1)

Which parts of a projected picture have to be drawn again this frame.

    Patch.plan([{10, 20, 4, 4}], {960, 400}, {8, 16}, 0.4)
    #=> {:patches, [{8, 16, 8, 16}]}

`spots` are the pixel rectangles the moving parts of a scene cover, each
`{x, y, width, height}`; `picture` is its size in pixels; `cell` the pixels one
terminal cell covers, as `{across, down}`; `room` the share of the picture still worth
patching.

Answers `{:patches, rects}`, every rectangle clipped to the picture, grown out to cell
edges, and merged with any it touches, so no two of them meet and each starts on a
whole cell. Answers `:whole` when the rectangles would cover more than `room` of the
picture.

# `rect`

```elixir
@type rect() :: {integer(), integer(), pos_integer(), pos_integer()}
```

# `plan`

```elixir
@spec plan([rect()], {pos_integer(), pos_integer()}, {number(), number()}, number()) ::
  {:patches, [rect()]} | :whole
```

The rectangles to redraw, as the module documentation describes.

---

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