WasmGPU.createOverlay.legend¶
Summary¶
WasmGPU.createOverlay.legend creates a LegendLayer for scalar-to-color interpretation. The source can be a point cloud, glyph field, data material, or an explicit colormap/scale descriptor. Add the layer to an OverlaySystem to display a synchronized legend during interaction.
Syntax¶
WasmGPU.createOverlay.legend(descriptor: LegendLayerDescriptor): LegendLayer
const layer = wgpu.createOverlay.legend(descriptor);
Parameters¶
| Name | Type | Required | Description |
|---|---|---|---|
descriptor |
LegendLayerDescriptor |
Yes | Source binding and layout/format settings for the legend. |
Returns¶
LegendLayer - Legend layer instance for overlay.addLayer(...).
Type Details¶
BuiltinColormapName¶
Color4¶
OverlayLegendExplicitSource¶
type OverlayLegendExplicitSource = {
scaleTransform: ScaleTransformDescriptor | ScaleTransform;
colormap: Colormap | BuiltinColormapName;
colormapStops?: ReadonlyArray<Color4>;
};
OverlayLegendSource¶
LegendLayerDescriptor¶
type LegendLayerDescriptor = {
id?: string;
source: OverlayLegendSource;
title?: string;
anchor?: ScreenAnchorDescriptor;
widthPx?: number;
heightPx?: number;
tickCount?: number;
strictParity?: boolean;
font?: string;
formatValue?: (value: number) => string;
};
Example¶
const canvas = document.querySelector("canvas");
const wgpu = await WasmGPU.create(canvas);
const overlay = wgpu.createOverlay.system();
const legend = wgpu.createOverlay.legend({
title: "Velocity Magnitude",
source: {
scaleTransform: { mode: "linear", domainMin: 0, domainMax: 10 },
colormap: "viridis"
},
tickCount: 6
});
overlay.addLayer(legend);