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

Node / Canvas · reference

Canvas size and coordinates

Reference the width, height, x, and y sizing and coordinate behavior used by Apexify.js createCanvas.

apexify.jsRuntime: nodeCURRENTSince 6.0.0
SurfaceAvailableNotes
widthYesExplicit output width in pixels
heightYesExplicit output height in pixels
xYesCoordinate offset; normally zero
yYesCoordinate offset; normally zero
customBg.inheritYesMay derive missing dimensions from the loaded image
videoBg.inheritYesWhen true, adopts dimensions from the extracted still frame

Width and height

Implicit sizing

Omit dimensions and rely on the 500 × 500 fallback.

Production sizing

Set explicit dimensions when output size is part of the contract.

SOURCEtypescript
typescript
Studio
await painter.createCanvas({ width: 1920, height: 1080, colorBg: '#000000' });
SOURCEtypescript
typescript
Studio
{ width: 1920, height: 1080 }

The grouped fragments above compare sizing policy only; they are not separate executable examples. The canonical runnable source remains the stable DOC-5 example linked from the canvas overview.

If both dimensions remain unset and neither image background opts into inherit: true, the creator defaults to 500 × 500.

When can another source determine size?
  • customBg.inherit: true can take width and height from the loaded image.
  • videoBg.inherit: true extracts the selected still frame once and adopts that frame's width and height.

Coordinates

FeatureDefaultPurpose
x0Horizontal offset used by rotation/layout math
y0Vertical offset used by rotation/layout math

Before

SOURCEtypescript
typescript
await painter.createCanvas({ colorBg: '#18181b' });

After

SOURCEtypescript
typescript
await painter.createCanvas({ width: 640, height: 360, colorBg: '#18181b' });

Installation reference

TERMINALbash
bash
$ npm install apexify.js

Minimal valid example

Explicit 640 × 360 output

SOURCEtypescript
typescript
Studio
await painter.createCanvas({  width: 640,  height: 360,  colorBg: '#18181b',});
Expected sizing result

The resulting PNG surface is 640 pixels wide and 360 pixels high unless a different documented configuration path intentionally changes the effective size.

Next steps

Return to the Canvas and createCanvas overview for validation, return-value, background, and paint-pipeline context.

Next steps