Advanced / Composition · guide
Preset scene components (painter.components)
Current Apexify.js 6.0.0 documentation for Preset scene components (painter.components).
painter.components exposes small factories. Every toLayers(options) returns ordinary SceneLayer[] that you can spread into renderScene, SceneBuilder.addLayers, or template insertions.
They are static rendering helpers, not DOM widgets. They do not carry accessibility semantics such as alt text, ARIA labels, or reading order. If the generated image is shown in HTML or another accessible UI, provide the appropriate accessible name/description in that surrounding UI.
All built-ins validate finite/positive geometry and relevant resource limits before returning layers.
Common pattern
Earlier entries paint below later entries.
badge.toLayers
BadgeToLayersOptions: required text, x, y; optional paddingX, paddingY, radius, background, color, fontSize.
The component estimates pill width from text length/font size, enforces non-negative padding/radius and positive font size, and clamps the corner radius to the produced box.
progressBar.toLayers
ProgressBarToLayersOptions: x, y, width, height, value; optional max (default 100), track background, fill, radius, showLabel, labelColor.
- Width/height and
maxmust be positive. valueis clamped into[0, max].- The fill never exceeds the declared progress-bar width.
- Zero progress emits no fill layer.
avatar.toLayers
AvatarToLayersOptions: source (non-empty path/URL string or Buffer), x, y, size, optional borderColor, borderWidth.
The image uses circular clipping. A positive borderWidth with borderColor emits a ring layer behind the clipped image. Invalid/empty sources and border widths larger than the avatar size are rejected.
card.toLayers
CardToLayersOptions: x, y, width, height, optional radius, background, borderColor / borderWidth, title, body, title/body font sizes and colors, padding.
The component emits a rounded panel followed by optional text layers. Padding and border width are validated so a positive content area remains. Text uses the available card width as its wrap bound.
watermark.toLayers
WatermarkToLayersOptions: text, canvasWidth, canvasHeight, optional position (bottom-right, bottom-left, top-right, top-left, center), fontSize, color, margin.
The watermark is canvas-aware: invalid position values are rejected, text must fit the supplied canvas dimensions, and corner margins may not push the estimated watermark outside the canvas. Use it late in the layer array when it should paint on top.
Mixing with arbitrary scene layers
The option types are exported from apexify.js and the type-only apexify.js/types subpath.