Table of Contents

Class LabelCollisionGrid

Namespace
LansMap.Core.Labels

First-come-first-served screen-space occupancy grid that rejects overlapping labels.

public sealed class LabelCollisionGrid
Inheritance
object
LabelCollisionGrid

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

screenWidth int

Viewport width in screen px.

screenHeight int

Viewport height in screen px.

marginPx int

Extra 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

x float

Left edge in screen px, origin top-left.

y float

Top edge in screen px, origin top-left.

w float

Width in screen px.

h float

Height in screen px.

Returns

bool

True when the rect was reserved; false when it is off-screen or collides.