SurfaceExtensions
Namespace: Hex1b
Assembly: Hex1b.dll
Extension methods for creating instances using the fluent API.
csharp
public static class SurfaceExtensionsInheritance
Object → SurfaceExtensions
Methods
Surface<TParent>(WidgetContext<TParent>, Func<SurfaceLayerContext, IEnumerable<SurfaceLayer>>)
Creates a with the specified layer builder.
Parameters:
ctx(WidgetContext<<TParent>>): The widget context.layerBuilder(Func<SurfaceLayerContext, SurfaceLayer>>): A function that receives a and returns the layers to composite. Called each render with current mouse position.
Returns: SurfaceWidget
A new with the specified layers.
csharp
public static SurfaceWidget Surface<TParent>(this WidgetContext<TParent> ctx, Func<SurfaceLayerContext, IEnumerable<SurfaceLayer>> layerBuilder) where TParent : Hex1bWidgetSurface<TParent>(WidgetContext<TParent>, ISurfaceSource)
Creates a with a single static surface.
Parameters:
ctx(WidgetContext<<TParent>>): The widget context.source(ISurfaceSource): The surface source to display.
Returns: SurfaceWidget
A new displaying the source.
csharp
public static SurfaceWidget Surface<TParent>(this WidgetContext<TParent> ctx, ISurfaceSource source) where TParent : Hex1bWidgetRemarks
These methods enable creation of surface widgets that expose the full Surface API for arbitrary visualizations with layered compositing.
Examples
Creating a surface with multiple layers:
csharp
ctx.Surface(s => [
s.Layer(backgroundSurface),
s.Layer(surface => DrawSprite(surface)),
s.Layer(ctx => FogOfWar(ctx, s.MouseX, s.MouseY))
])