Cauldron2D.Drafter.Surface.Patch (Cauldron2D.Drafter v0.2.2)

Copy Markdown View Source

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.

Summary

Functions

The rectangles to redraw, as the module documentation describes.

Types

rect()

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

Functions

plan(spots, picture, cell, room)

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

The rectangles to redraw, as the module documentation describes.