UI/Renderable: Panel
Nine-slice style stretched panel renderable with optional texture and shader.
What this page covers #
panel is a framed/stretched renderable useful for UI containers, cards, and panel-like surfaces.
By task #
- Define panel frame/atlas options: see Definition
- Understand panel frame semantics: see Notes
- Place panels inside layout slots: see Top-level element options
Nine-slice style stretched panel with optional texture and shader. Currently uses a single frame definition.
Import #
import * as UI from 'Helix/UserInterface';Definition #
PanelRenderable
Nine-slice stretched panel with optional texture and shader.
type'panel' - Renderable type identifier.mode'stretched' | 'sliced' | 'cover' optional - Panel draw mode. Default'stretched'. Use'sliced'for nine-slice behaviour.slice{ top, right, bottom, left } optional - 9-slice border thicknesses in pixels.texturestring optional - Path to texture atlas.frameobject optional - Frame definition. If omitted, a default stretched panel is created.frame.size{ x, y } optional - Frame display size.frame.origin{ x, y } optional - Panel frame metadata origin.frame.aabb{ min: { x, y }, max: { x, y } } optional - Sub-rect of the texture atlas.frame.colour[r, g, b, a] optional - Frame tint colour.shader{ vert: string, frag: string } optional - Optional SPIR-V shader override.
Notes #
- If
frameis omitted, a default stretched panel is created. modedefaults tostretched. Useslicedfor nine-slice behaviour.slicedefines the 9-slice border thicknesses in pixels (top/right/bottom/left).frame.aabbselects the sub-rect of the texture atlas.frame.originis panel frame metadata.- Element-level pivot is
renderable.origininUI.createElement(orUI.setOriginat runtime). - Use
UI.setPanelSlice,UI.setTexture, andUI.setShaderto update after creation. - Set the runtime tint with
await UI.setPanelColour(win, id, [1, 0.5, 0.25, 1])(alias:setPanelColor). Tint multipliesframe.colourand inherited opacity in all panel modes. Pass[1,1,1,1]to clear it.
Top-level element options #
Pass these alongside renderable in UI.createElement (see also UI/Renderable: Shared properties):
UI.createElement(win, {
renderable: {
type: 'panel',
origin?: { x, y },
position?: { x, y },
scale?: { x, y },
rotation?: number
},
contentAlign?: { x?: 'start'|'center'|'end', y?: 'start'|'center'|'end' }
})Example #
Creates a textured panel using a frame sub-rectangle from an atlas image. This is the typical setup for UI card backgrounds, dialog frames, or any surface that should stretch with its container.
import * as UI from 'Helix/UserInterface';
const id = await UI.createElement(win, {
renderable: {
type: 'panel',
mode: 'sliced',
texture: '/rom/arch.png',
position: { x: 10, y: 4 },
origin: { x: 0, y: 0 },
frame: {
size: { x: 20, y: 20 },
origin: { x: 0, y: 0 },
aabb: { min: { x: 0, y: 0 }, max: { x: 128, y: 128 } }
}
}
});
await UI.attachRoot(win, id);
await UI.setPanelSlice(win, id, { top: 8, right: 8, bottom: 8, left: 8 });