Class LabelCollisionGrid
First-come-first-served screen-space occupancy grid that rejects overlapping labels.
public sealed class LabelCollisionGrid
- Inheritance
-
objectLabelCollisionGrid
Remarks
Place candidates in priority order; the first accepted rect wins and later collisions are dropped. Call Reset() before each selection pass.
Constructors
LabelCollisionGrid(int, int, int)
Builds a grid covering the screen plus an optional off-screen margin.
public LabelCollisionGrid(int screenWidth, int screenHeight, int marginPx = 0)
Parameters
screenWidthintViewport width in screen px.
screenHeightintViewport height in screen px.
marginPxintExtra placeable band past each edge in screen px, so a partially visible label is not dropped.
Methods
Reset()
Clears every reserved rectangle so a new selection pass can start.
public void Reset()
TryPlace(float, float, float, float)
Reserves the rectangle when it fits without overlapping any already placed rect.
public bool TryPlace(float x, float y, float w, float h)
Parameters
xfloatLeft edge in screen px, origin top-left.
yfloatTop edge in screen px, origin top-left.
wfloatWidth in screen px.
hfloatHeight in screen px.
Returns
- bool
True when the rect was reserved; false when it is off-screen or collides.