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

Advanced / Scene · guide

Scene layers — image, text, path, imageBuffer

Current Apexify.js 6.0.0 documentation for Scene layers — image, text, path, imageBuffer.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

These layers use ImageCreator, TextCreator, and Path2DCreator under the hood — same concepts as createImage, createText, and path2d.draw on a buffer.


image

images: ImageProperties | ImageProperties[] — same as createImage.
options: optional CreateImageOptions (grouped mode, clip, filters, etc. — see Create image basics).

Variant: single full-bleed image

SOURCEtypescript
typescript
Studio
{  type: "image",  images: {    source: "./photo.jpg",    x: 0,    y: 0,    width: 1280,    height: 720,  },}

Variant: multiple image entries (stacked in one layer)

SOURCEtypescript
typescript
Studio
{  type: "image",  images: [    { source: "./sky.png", x: 0, y: 0, width: 800, height: 400 },    { source: "./logo.png", x: 620, y: 24, width: 140, height: 140, opacity: 0.95 },  ],}

Order inside images[] is paint order within that layer (before the next SceneLayer).

Variant: URL or cwd-relative path

SOURCEtypescript
typescript
Studio
{  type: "image",  images: {    source: "https://example.com/asset.png",    x: 100,    y: 100,    width: 200,    height: 200,  },}

Resolution rules match ImageCreator (see image guides).


text

texts: TextProperties | TextProperties[] — rendered with TextCreator.renderTextsOntoContext.

Variant: single headline

SOURCEtypescript
typescript
Studio
{  type: "text",  texts: [    {      content: "Dashboard",      x: 48,      y: 72,      fontSize: 56,      color: "#0f172a",      fontPath: "./fonts/Bold.ttf",    },  ],}

Variant: stacked lines (subtitle + title)

SOURCEtypescript
typescript
Studio
{  type: "text",  texts: [    { content: "Q4 Report", x: 48, y: 48, fontSize: 20, color: "#64748b" },    { content: "Revenue", x: 48, y: 88, fontSize: 44, color: "#0f172a" },  ],}

Variant: two separate text layers (control z-order)

Putting subtitles in a separate SceneLayer lets you insert an image layer between title and subtitle if needed.

SOURCEtypescript
typescript
Studio
const layers = [  { type: "text" as const, texts: [{ content: "Back", x: 10, y: 10, fontSize: 14, color: "#888" }] },  { type: "image" as const, images: { source: "./divider.png", x: 0, y: 40, width: 400, height: 4 } },  { type: "text" as const, texts: [{ content: "Front", x: 10, y: 52, fontSize: 24, color: "#000" }] },];

path

path: PathCommand[] (or a path handle typed as unknown).
options: optional Path2DDrawOptions — stroke, fill, transform.

Variant: stroke only

SOURCEtypescript
typescript
Studio
{  type: "path",  path: [    { type: "moveTo", x: 40, y: 200 },    { type: "lineTo", x: 360, y: 200 },    { type: "lineTo", x: 200, y: 40 },    { type: "closePath" },  ],  options: {    stroke: { color: "#2563eb", width: 3, lineJoin: "round" },  },}

Variant: fill + rounded rect command

SOURCEtypescript
typescript
Studio
{  type: "path",  path: [    {      type: "roundedRect",      x: 50,      y: 50,      width: 200,      height: 100,      borderRadius: 16,    },  ],  options: {    fill: { color: "#dbeafe", rule: "nonzero" },    stroke: { color: "#1d4ed8", width: 2 },  },}

Variant: raw commands array passed from a helper

SOURCEtypescript
typescript
Studio
function badgePath(cx: number, cy: number, r: number) {  return [    { type: "moveTo" as const, x: cx + r, y: cy },    { type: "arc" as const, x: cx, y: cy, radius: r, startAngle: 0, endAngle: Math.PI * 2 },  ];} {  type: "path",  path: badgePath(100, 100, 40),  options: { fill: { color: "#ef4444" } },}

imageBuffer

Draws an already-decoded PNG/JPEG Buffer at x,y. Useful for badges, QR codes, or thumbnails produced elsewhere.

FieldRole
bufferRaster bytes
x, yTop-left
width, heightOptional draw size (defaults to image intrinsic size)
globalAlpha, globalCompositeOperationOptional compositing

Variant: logo buffer on top of gradient (another layer)

SOURCEtypescript
typescript
Studio
import fs from "fs"; const logo = await fs.promises.readFile("./logo.png"); const layer = {  type: "imageBuffer" as const,  buffer: logo,  x: 700,  y: 30,  width: 120,  height: 120,  globalAlpha: 1,};

Variant: soft watermark (multiply)

SOURCEtypescript
typescript
Studio
{  type: "imageBuffer",  buffer: watermarkBuf,  x: 0,  y: 0,  width: 800,  height: 450,  globalAlpha: 0.35,  globalCompositeOperation: "multiply",}

Variant: natural size (omit width/height)

SOURCEtypescript
typescript
Studio
{  type: "imageBuffer",  buffer: iconBuf,  x: 16,  y: 16,}

Next steps