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

Node / Lines Connectors · guide

path2d.custom — API & validation

Current Apexify.js 6.0.0 documentation for path2d.custom — API & validation.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

Signature: await painter.path2d.custom(options, canvasBuffer)

  • options — one CustomOptions object or an array processed in order (later segments paint above earlier ones unless singleLine chains geometry).
  • canvasBuffer — Buffer or CanvasResults (.buffer PNG bytes).

Implementation: runDrawCustomLines (apex-painter/path-custom-lines.ts) loads the buffer into a fresh canvas, runs customLines(ctx, opts), returns image/png Buffer.


Validation

Throws if:

ConditionMessage prefix
Missing buffercreateCustom: buffer is required.
Empty options arraycreateCustom: At least one custom option is required.
startCoordinates.x/y not finite numberscreateCustom: startCoordinates with valid x and y are required.
endCoordinates.x/y not finite numberscreateCustom: endCoordinates with valid x and y are required.

CustomOptions shape (top level)

FieldRequiredRole
startCoordinatesYes{ x, y } segment start
endCoordinatesYes{ x, y } segment end
pathNoCurve generator (smooth, catmull-rom, bezier) — see Line style & path
arrowNostart/end arrowheads
markersNoSamples along the polyline [start→end]
lineStyleNoStroke appearance (defaults mimic thin black stroke)

Full lineStyle / arrow / markers tables live in the next chapters.


Batch drawing

Pass CustomOptions[] to paint multiple independent connectors (flowcharts, timelines). Order matters for overlaps — draw guides before foreground strokes.


Chained segments (lineStyle.singleLine)

When singleLine: true, customLines keeps beginPath open across consecutive rows:

  • Row i > 0 reuses previousEndCoordinates as the effective moveTo anchor (start vertex omitted from lineTo chain except on the first row of the sequence).
  • Stroke executes when singleLine ends or on the last row of the batch.

Use this for one continuous stroke through several endCoordinates knots while varying arrow/markers only on relevant rows.


Scene parity

SceneLayer { type: 'customLines', lines: CustomOptions | CustomOptions[] } uses the same validation (scene-normalizer) before customLines runs.


Example — two hops + arrow

SOURCEtypescript
typescript
Studio
await painter.path2d.custom(  [    {      startCoordinates: { x: 60, y: 180 },      endCoordinates: { x: 260, y: 180 },      lineStyle: { width: 3, color: '#cbd5e1', lineCap: 'round' },    },    {      startCoordinates: { x: 260, y: 180 },      endCoordinates: { x: 460, y: 280 },      lineStyle: { width: 3, color: '#cbd5e1', lineCap: 'round' },      arrow: { end: true, size: 12 },    },  ],  buffer);

Next steps