UI/Renderable: Circle
Circle/arc renderable with optional ring thickness and angle range.
What this page covers #
circle draws filled circles, ellipses, arcs, and ring-style shapes with optional texture/shader overrides.
By task #
- Build an arc/ring gauge: see Example: arc gauge
- Understand geometric defaults and update behaviour: see Defaults and Notes
- Align circles within layout slots: see Top-level element options
Ellipse or arc segment fitted to an AABB, with optional inner inset (ring thickness), colour tint, and optional texture/shader override.
Import #
import * as UI from 'Helix/UserInterface';Definition #
Renderable options object passed to UI.createElement(..., { renderable: { ... } }):
type'circle' - Renderable type identifier.aabb{ min: { x, y }, max: { x, y } } optional - Outer bounds. Square gives a circle; non-square gives an ellipse. Default{ min:{x:0,y:0}, max:{x:0,y:0} }.insetnumber optional - Ring thickness.0= filled,> 0= ring. Default0.startnumber optional - Start angle in degrees. Default0.endnumber optional - End angle in degrees. Default360.resolutionnumber optional - Sides used to approximate the circle. Default32.colour[r, g, b, a] optional - Tint colour. Default[1,1,1,1].texturestring optional - Path to image asset.shader{ vert: string, frag: string } optional - Optional SPIR-V shader override.
Defaults #
aabb:{ min:{x:0,y:0}, max:{x:0,y:0} }inset:0start:0end:360resolution:32colour:[1,1,1,1]
Notes #
- Fast updates: changing only
start/endrebuilds indices without touching vertices for best performance. - Geometry:
aabbdefines the outer bounds. A squareaabbgives a circle; a non-squareaabbgives an ellipse. - Inset: when
inset > 0, renders a ring inset from the outer ellipse. Wheninset == 0, renders a filled circle/ellipse/arc. - Pivot: element transform pivot is
renderable.originat creation (runtime:UI.setOrigin). - You can update resources at runtime via
UI.setTexture,UI.clearTexture,UI.setShader,UI.clearShader. - All circle-specific properties can be updated at runtime via the setters listed below.
Runtime setters #
After creation, individual circle properties can be changed without rebuilding the entire renderable. These are available on both the raw Helix/UserInterface module and the Element standard-library wrapper.
[r, g, b, a] or { r, g, b, a }.UI.setCircleColour(windowId, elementId, colour) / element.setCircleColour(colour)0 = filled, > 0 = ring.UI.setCircleInset(windowId, elementId, inset) / element.setCircleInset(inset)UI.setCircleStart(windowId, elementId, degrees) / element.setCircleStart(degrees)UI.setCircleEnd(windowId, elementId, degrees) / element.setCircleEnd(degrees)UI.setCircleResolution(windowId, elementId, resolution) / element.setCircleResolution(resolution){ min: { x, y }, max: { x, y } }.UI.setCircleRect(windowId, elementId, aabb) / element.setCircleRect(aabb)Top-level element options #
Pass these alongside renderable in UI.createElement (see also UI/Renderable: Shared properties):
UI.createElement(win, {
renderable: { type: 'circle', /* ... */ },
contentAlign?: { x?: 'start'|'center'|'end', y?: 'start'|'center'|'end' }
})Example: arc gauge #
Builds a 270-degree arc ring and spins it continuously with a rotation animation. This pattern is the basis for progress gauges, radial meters, and loading indicators.
import * as UI from 'Helix/UserInterface';
const id = await UI.createElement(win, {
renderable: {
type: 'circle',
aabb: { min: { x: 52, y: 52 }, max: { x: 148, y: 148 } },
inset: 6,
start: 135,
end: 405,
resolution: 64,
colour: [0.2, 0.8, 0.6, 1]
}
});
await UI.attachRoot(win, id);
const spin = await UI.addAnimation(win, id, [
{ time: 0.0, rotation: 0 },
{ time: 1.5, rotation: 360, looping: true }
]);
await UI.startAnimation(win, id, spin);