Skip to content

SurfaceWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A widget that renders layered surfaces with compositing support.

csharp
public record SurfaceWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<SurfaceWidget>

Inheritance

ObjectHex1bWidgetSurfaceWidget

Implements

Constructors

SurfaceWidget(Func<SurfaceLayerContext, IEnumerable<SurfaceLayer>>)

A widget that renders layered surfaces with compositing support.

Parameters:

csharp
public SurfaceWidget(Func<SurfaceLayerContext, IEnumerable<SurfaceLayer>> LayerBuilder)

Properties

LayerBuilder

A function that receives a and returns the layers to composite. Called each render with current mouse position.

Returns: Func<SurfaceLayerContext, SurfaceLayer>>

csharp
public Func<SurfaceLayerContext, IEnumerable<SurfaceLayer>> LayerBuilder { get; init; }

Methods

Height(SizeHint)

Returns a new widget with the specified height hint.

Parameters:

  • hint (SizeHint): The height sizing hint.

Returns: SurfaceWidget

A new widget with the updated height hint.

csharp
public SurfaceWidget Height(SizeHint hint)

Size(int, int)

Returns a new widget with fixed dimensions.

Parameters:

  • width (Int32): The fixed width in columns.
  • height (Int32): The fixed height in rows.

Returns: SurfaceWidget

A new widget with fixed dimensions.

csharp
public SurfaceWidget Size(int width, int height)

Width(SizeHint)

Returns a new widget with the specified width hint.

Parameters:

Returns: SurfaceWidget

A new widget with the updated width hint.

csharp
public SurfaceWidget Width(SizeHint hint)

Remarks

provides direct access to the Surface API, enabling arbitrary visualizations with multiple composited layers. Each layer can be a static surface, dynamically drawn content, or computed cells that can query layers below.

Layers are composited bottom-up in the order returned by the builder. The first layer is at the bottom, and subsequent layers are drawn on top.

csharp
ctx.Surface(s => [
    s.Layer(terrainSurface),                           // Static background
    s.Layer(entitySurface, offsetX: 10, offsetY: 5),   // Positioned sprite
    s.Layer(ctx => FogOfWar(ctx, s.MouseX, s.MouseY)), // Effect layer
])

Released under the MIT License.