SurfaceWidget
Namespace: Hex1b.Widgets
Assembly: Hex1b.dll
A widget that renders layered surfaces with compositing support.
public record SurfaceWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<SurfaceWidget>Inheritance
Object → Hex1bWidget → SurfaceWidget
Implements
Constructors
SurfaceWidget(Func<SurfaceLayerContext, IEnumerable<SurfaceLayer>>)
A widget that renders layered surfaces with compositing support.
Parameters:
LayerBuilder(Func<SurfaceLayerContext, SurfaceLayer>>): A function that receives a and returns the layers to composite. Called each render with current mouse position.
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>>
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.
public SurfaceWidget Height(SizeHint hint)Size(int, int)
Returns a new widget with fixed dimensions.
Parameters:
Returns: SurfaceWidget
A new widget with fixed dimensions.
public SurfaceWidget Size(int width, int height)Width(SizeHint)
Returns a new widget with the specified width hint.
Parameters:
hint(SizeHint): The width sizing hint.
Returns: SurfaceWidget
A new widget with the updated width hint.
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.
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
])