Skip to content

declutterScreen

declutterScreen(count, sx, sy, radius, order, width, height, spacing, out, scratch?, ignore?): Uint8Array

Defined in: core/declutter.ts:37

Greedy screen-space declutter. Visits glyphs in order (importance descending; omitted ⇒ index order) and keeps each unless its centre is within spacing·(rᵢ + rⱼ) of an already-kept glyph — so the drawn circles don’t overlap and the most important glyph in a cluster survives. A glyph whose centre is off-screen is always kept and never occludes others (so panning never culls what’s barely out of view). O(n) via a uniform grid sized to the largest exclusion radius, so any overlapping pair falls in the 3×3 cell neighbourhood.

sx/sy are screen-pixel centres. radius is the per-glyph exclusion radius in px — a number for the uniform case (a point layer’s fixed spacing is passed as half the centre-to-centre distance, since two glyphs collide when dist < rᵢ + rⱼ). out (length ≥ count, written in index order) and scratch are reused across frames by the caller. Returns out.

ignore(i, j) (optional) drops a specific overlap from the test: when candidate i would be occluded by an already-kept glyph j, returning true means “not a real overlap” so i is not culled by j (but is still tested against every other glyph, and still occludes others). Used by the LOD cross-fade (#133): a glyph transitioning across the expand threshold ignores its ancestor as an occluder — so a fading parent doesn’t cull its fading-in children — while children still declutter against siblings. Omitted ⇒ no ignored pairs (zero added cost).

number

ArrayLike<number>

ArrayLike<number>

number | ArrayLike<number>

ArrayLike<number> | undefined

number

number

number

Uint8Array

DeclutterScratch = ...

(i, j) => boolean

Uint8Array