UI/Renderable: Shared properties
Common properties and runtime controls available to all renderables and elements.
What this page covers #
Shared renderable and element-level properties that apply across box, panel, sprite, text, mesh, and circle.
Related concepts #
By task #
- Understand transform pivots and origin behaviour: see Origins and transforms
- Find common runtime mutators (
setPosition,setScale, etc.): see Shared transform API - Configure shared layout/content behaviour on any element: see Layout API and Content alignment API
- Understand shared animation fields across renderables: see Animation
Common properties shared by all renderables and element containers. These can be passed at creation to UI.createElement or adjusted later via runtime APIs.
Import #
import * as UI from 'Helix/UserInterface';Element structure #
UI.createElement(windowId, options).renderableobject optional - Renderable-specific options (box,panel,sprite,text,mesh,circle) plus shared transform properties.renderable.position{ x, y } optional - Pixel offset for the renderable.renderable.origin{ x, y } optional - Transform pivot for rotation/scale. Values0..1are normalized; outside that range are pixel-space.renderable.scale{ x, y } optional - Scale factor per axis.renderable.rotationnumber optional - Rotation in degrees.inheritAnimationboolean optional - Whether this element inherits parent animation transforms. Defaulttrue.layoutobject optional - Container layout properties (see UI/Layout).itemobject optional - Child layout properties (see UI/Layout).contentAlign{ x?, y? } | 'fill' optional - Aligns the renderable inside the layout slot, or'fill'to fill outer bounds.contentPositioning'raw' | 'contain' optional - Whether content is clamped inside the slot (contain) or allowed to overflow (raw).layoutOrdernumber optional - Sibling sort order.
Origins and transforms (important) #
There are three different "origin" concepts in UI. They affect different layers:
renderable.origin(create-time) /UI.setOrigin(runtime) — the renderable transform pivot used for rotation and scale. Values in the range0..1are treated as normalized pivots resolved from the renderable's current local bounds. Values outside0..1are treated as pixel-space pivots.frame.originin sprite/panel frame data — per-frame renderable metadata belonging to the renderable definition (atlas frame), not to layout.- Element layout bounds (
item.size,layout,contentAlign) — control where renderables are placed in the UI tree. They do not define the renderable transform pivot.
If you need a stable, explicit pivot for animation/rotation, set renderable.origin and avoid overloading frame metadata for element-level intent.
Shared transform API #
UI.setPosition(windowId, id, { x, y })0..1 = normalized; outside = pixel-space.UI.setOrigin(windowId, id, { x, y })UI.setScale(windowId, id, { x, y })UI.setEnabled(windowId, id, boolean)UI.setInheritAnimation(windowId, id, boolean)Measurement helpers #
UI.getRenderableBounds(windowId, id): { min, max, centre, size }UI.getRenderableSize(windowId, id): { x, y }UI.getElementFrame(windowId, id): { min, max, centre, size }Notes #
- Set creation-time transforms on
renderable(position,origin,scale,rotation). rotationcan be changed at runtime via the animation system (no direct setter yet).offsetexists internally on renderables but is not exposed in the JS API; useposition/origininstead.
Shader and texture overrides #
blendmay also be provided asblendMode.- Supported blend modes:
'premultiplied-alpha'(default),'opaque','additive', and'alpha'.
UI.setShader(windowId, id, { vert, frag, blend?: BlendMode })UI.clearShader(windowId, id)UI.setTexture(windowId, id, path)UI.clearTexture(windowId, id)Text renderables ignore setTexture; their texture is the font atlas.
Layout API #
UI.setLayout(windowId, id, { type, wrap?, wrapLimit?, gap?, padding?, justifyContent?, alignItems?, gridColumns?, gridRows?, columnGap?, rowGap?, gridFlowByRow?, gridAlignItems?, gridJustifyItems? })UI.setMargin(windowId, id, { t?, r?, b?, l? })UI.setLayoutSize(windowId, id, { x?, y? })item.absolutePosition).UI.setLayoutPosition(windowId, id, { x, y })item.absoluteAABB).UI.setLayoutAABB(windowId, id, { min, max })flexGrow value.UI.setGrow(windowId, id, number)UI.setContentPositioning(windowId, id, 'raw' | 'contain')Content alignment API #
UI.setPosition() moves the renderable transform. Use UI.setLayoutPosition() / UI.setLayoutAABB() when you need layout-space placement.
- The slot is the child's
item.sizeif specified; otherwise the size computed by the parent. - Requires that the element is positioned by a container with
layout.type. Without a parent container,contentAlignhas no effect; useorigin/positioninstead. - Exception: specifying a child
item.sizeon an absolutely positioned element allowscontentAlignto work even without a parent layout. - Special
'fill': requests the renderable to fill the element's OUTER bounds (ignores padding). Only renderables that opt in will resize geometry (currentlybox).
UI.setContentAlign(windowId, id, { x?: 'start'|'center'|'end', y?: 'start'|'center'|'end' } | 'fill')Animation #
All renderables support keyframed animation of transforms and colour. Colours accept arrays [r,g,b,a] (0..1) or hex strings (#RGB, #RGBA, #RRGGBB, #RRGGBBAA, 0xRRGGBB[AA]):
const a = UI.addAnimation(win, id, [
{ time: 0.0, position: { x: 0, y: 0 } },
{ time: 0.3, ease: 'outCubic', position: { x: 40, y: 0 }, scale: { x: 1.1, y: 1.1 } },
{ time: 0.6, ease: 'inOutQuad', rotation: 10, colour: [1,1,1,0.8] },
{ time: 1.0, position: { x: 0, y: 0 }, rotation: 0 }
]);
UI.startAnimation(win, id, a);Supported keyframe fields: position, origin, scale, rotation (degrees), colour/color (array or hex), and advanced noise options for procedural motion. See UI/Animation for full reference.
Z-ordering and layers #
Elements render back-to-front by layer, then by Y stacking for sprites where applicable. A dedicated layer setter may be added in future; for now prefer scene ordering and Y positioning.
Sibling order #
- Children of a container are kept sorted by a per-child
orderkey. - Set at creation:
orderorlayoutOrderinUI.createElementoptions. - Change at runtime:
UI.setLayoutOrder(windowId, id, number); only affected parents are resorted.
Hit-testing #
Virtual handlers enable hit testing and receive one event object. See /helix-input for recognition and ownership.