cullLabels
cullLabels(
candidates,options):LabelBox[]
Defined in: labels/cull.ts:372
Reduce label candidates to a renderable subset: drop anchors outside the viewport (+padding), then place highest-priority first, skipping any whose box collides with an already-placed one. Collision uses each label’s true screen footprint (see labelGeometry) — the box it renders in, oriented labels included — so dense regions thin down to a readable set instead of overprinting (#204), and the survivor of each cluster is the most important label.
Placed boxes are binned into a uniform screen grid whose cell is the largest candidate extent,
so a colliding pair always lands within the 3×3 cell neighbourhood: the pass is O(candidates)
overlap tests, not the O(candidates²) placed.some(…) scan it replaces, and with a caller-owned
CullOptions.scratch it allocates only the survivor array. The same structure
core/declutter uses for glyphs — but rectangles, not discs: a text box’s bounding circle is
~10× its area, which would cull nearly everything.
Parameters
Section titled “Parameters”candidates
Section titled “candidates”readonly LabelBox[]
options
Section titled “options”Returns
Section titled “Returns”LabelBox[]