Skip to content

KgpVisibility

Namespace: Hex1b.Surfaces

Assembly: Hex1b.dll

Tracks visibility of a KGP image placement after occlusion by other content.

csharp
public sealed class KgpVisibility

Inheritance

ObjectKgpVisibility

Constructors

KgpVisibility(TrackedObject<KgpCellData>, int, int, int)

Creates a new KGP visibility tracker.

Parameters:

  • kgp (TrackedObject<KgpCellData>):
  • anchorX (Int32):
  • anchorY (Int32):
  • layerIndex (Int32):
csharp
public KgpVisibility(TrackedObject<KgpCellData> kgp, int anchorX, int anchorY, int layerIndex)

Properties

AnchorPosition

Gets the anchor position (top-left cell) of the KGP image.

Returns: ValueTuple<Int32, Int32>

csharp
public (int X, int Y) AnchorPosition { get; }

IsFullyOccluded

Gets whether the image is fully occluded (no visible regions).

Returns: Boolean

csharp
public bool IsFullyOccluded { get; }

IsFullyVisible

Gets whether the image is fully visible (no occlusions applied).

Returns: Boolean

csharp
public bool IsFullyVisible { get; }

Kgp

Gets the tracked KGP cell data.

Returns: TrackedObject<KgpCellData>

csharp
public TrackedObject<KgpCellData> Kgp { get; }

LayerIndex

Gets the layer index for z-ordering.

Returns: Int32

csharp
public int LayerIndex { get; }

VisibleRegions

Gets the visible pixel regions after occlusion.

Returns: IReadOnlyList<PixelRect>

csharp
public IReadOnlyList<PixelRect> VisibleRegions { get; }

Methods

ApplyOcclusion(Rect, CellMetrics)

Applies an occlusion from a cell rect, subtracting the occluded area from visible regions.

Parameters:

  • cellRect (Rect): The occluding rectangle in cell coordinates, relative to the surface.
  • metrics (CellMetrics): Cell metrics for pixel conversion.
csharp
public void ApplyOcclusion(Rect cellRect, CellMetrics metrics)

GeneratePlacements(CellMetrics)

Generates placement data for each visible region. Each placement uses the same ImageId but different source rectangles.

Parameters:

Returns: IReadOnlyList<KgpCellData, Int32, Int32>>

csharp
public IReadOnlyList<(KgpCellData Data, int CellX, int CellY)> GeneratePlacements(CellMetrics metrics)

Remarks

Similar to but leverages KGP's native source-rectangle clipping — adjusting placement parameters is a pure metadata operation, no image re-encoding is needed.

Usage: create a for each KGP image, apply occlusions from overlapping text or higher-layer content, then call to produce clipped instances for emission.

Released under the MIT License.