Answers "where is there room?" — for a legend, an annotation, a watermark, or anything else that has to go somewhere the marks are not.
Usage
vl_empty_region(
scene,
avoid = NULL,
within = NULL,
grid = 200,
unit = c("npc", "mm")
)Arguments
- scene
A
vl_scene()(or anything with anas_vellum_scene()method).- avoid
Names of the grobs to treat as obstacles.
NULL(default) takes every node that is not a label.- within
Region to search, as
c(x0, y0, x1, y1)innpcof the page. Defaults to the whole page.- grid
Grid resolution (cells across the longer side).
- unit
Unit of the returned rectangle:
"npc"(default) or"mm".
Value
A named numeric c(x0, y0, x1, y1), in unit, using the usual
y-grows-up convention. All zeros if there is no free space.
Details
Occupancy is rasterised onto a grid and the answer is exact on that grid.
The approximation is deliberate: the exact maximal empty rectangle over n
boxes is superquadratic, and nothing is placed to sub-pixel tolerance. Raise
grid to trade time for precision. Boxes are rounded outward, so the result
is conservative — it will never claim space that is in fact occupied.
