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

Start · tutorial

Your first image

Current Apexify.js 6.0.0 documentation for Your first image.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

Goal

Produce first.png on disk using ApexPainter.createCanvas.


Full example

SOURCEtypescript
typescript
Studio
import { ApexPainter } from 'apexify.js';import fs from 'fs'; async function main() {  const painter = new ApexPainter();   const { buffer } = await painter.createCanvas({    width: 800,    height: 450,    colorBg: '#0f172a',  });   fs.writeFileSync('first.png', buffer);  console.log('Wrote first.png');} main();

What each part does

PieceWhy
async functioncreateCanvas returns a Promise — you await it.
createCanvas({ … })Builds a bitmap with width, height, and background.
colorBgEasiest primary fill — any CSS-style color string.
bufferRaw PNG bytes — what you save or pass onward.
fs.writeFileSyncWrites the buffer to a file (Node.js built-in).

Result

You get an 800×450 image filled with slate #0f172a.


Try changing

  • width / height — canvas size in pixels.
  • colorBg — try '#ffffff', 'rgb(255,99,71)', '#6366f133' (alpha).

Next steps