Skip to content
Apexify.jsDocs
Apexify.js version v5.4.5

Advanced / Scene · guide

Scene backgrounds

Current Apexify.js 6.0.0 documentation for Scene backgrounds.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

The root background (and each surface’s background) uses the same shape as CanvasConfig minus the required width / height on the scene object — those come from SceneRenderInput.width/height or from placement.width/height for surfaces.

Painting is done by CanvasCreator.composeCanvasForScene → paintConfiguredCanvasSurface (gradients, bgLayers, patternBg, noiseBg, clip, zoom, shadow, stroke, videoBg if extraction is wired, etc.). Deep behaviour: Canvas backgrounds, bg-layers, transparent base.


Variant: flat color

SOURCEtypescript
typescript
Studio
const scene = {  width: 800,  height: 450,  background: { colorBg: "#0f172a" },  layers: [/* … */],};

Transparent “letterbox” feel

SOURCEtypescript
typescript
Studio
background: { colorBg: "transparent" },

Combine with transparentBase: true and bgLayers if you need a stacked transparent stack (see transparent base).


Variant: linear gradient (sketch)

SOURCEtypescript
typescript
Studio
background: {  gradientBg: {    type: "linear",    x0: 0,    y0: 0,    x1: 800,    y1: 450,    colors: [      { stop: 0, color: "#1e293b" },      { stop: 1, color: "#0f172a" },    ],  },},

(Match your gradient type from Gradients / canvas docs.)


Variant: full-screen image

SOURCEtypescript
typescript
Studio
background: {  customBg: {    source: "./assets/hero.jpg",    fit: "cover",    align: "center",  },},

Inherit image dimensions (root scene)

If customBg.inherit: true, CanvasCreator can set width/height from the image — you may omit width/height on SceneRenderInput only when that resolution path runs successfully; otherwise set explicit width/height.


Variant: bgLayers stack (tint over image)

SOURCEtypescript
typescript
Studio
background: {  customBg: { source: "./bg.png", fit: "cover", align: "center" },  bgLayers: [    { type: "color", value: "#000000", opacity: 0.35, blendMode: "source-over" },    { type: "noise", intensity: 0.04 },  ],},

Only layers, no primary fill

SOURCEtypescript
typescript
Studio
background: {  transparentBase: true,  bgLayers: [    { type: "gradient", value: { /* … */ }, opacity: 1 },  ],},

Variant: pattern + noise

SOURCEtypescript
typescript
Studio
background: {  colorBg: "#ffffff",  patternBg: { /* PatternOptions — see pattern guide */ },  noiseBg: { intensity: 0.03 },},

Variant: border, shadow, zoom (card-style root)

SOURCEtypescript
typescript
Studio
background: {  colorBg: "#fff",  x: 24,  y: 24,  width: 752,  height: 402,  borderRadius: 16,  shadow: {    color: "rgba(0,0,0,0.15)",    offsetX: 0,    offsetY: 8,    blur: 24,  },  stroke: { color: "#e2e8f0", width: 1 },},

Note: For root scene, width/height on SceneRenderInput are still the full bitmap size; x,y,width,height on background define the clipped rounded rect inside that bitmap (same as createCanvas).


videoBg caveat

CanvasConfig.videoBg requires CanvasCreator.setExtractVideoFrame to be set (typically from video stack wiring). If unset, videoBg may not size or paint. Prefer customBg with a still frame you extracted yourself if you need reliability without that hook.


Next steps