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

Node / Lines Connectors · guide

Lines & connectors — overview

Current Apexify.js 6.0.0 documentation for Lines & connectors — overview.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

lib-next exposes three related surfaces:

SurfaceApexPainter APIBest for
Styled connector segmentsawait painter.path2d.custom(options, canvasBuffer)Straight or lightly smoothed segments between startCoordinates / endCoordinates, gradients, dashes, arrows, markers, image textures (CustomOptions).
Vector geometrypainter.path2d.create(commands), await painter.path2d.draw(buffer, path, options?)Exact PathCommand[] shapes (arcs, Béziers, rounded rects, stars, arrows), shared fill/stroke/transform (Path2DDrawOptions).
Hit testingawait painter.detect.path(…), .region, .anyRegion, .distancePath2D / PathCommand[] / HitRegion primitives — same command vocabulary as create where type: 'path'.

Types CustomOptions, PathCommand, Path2DDrawOptions, HitRegion, HitDetectionOptions export from apexify.js.


How they relate

  1. path2d.custom rasterises polylines built per CustomOptions row (custom-lines.ts). It does not emit a reusable Path2D for hit-testing; for picks you typically model the same geometry with detect.region (rect, polygon, path) or rebuild PathCommand[].
  2. path2d.draw composites Path2D onto an existing canvasBuffer (path is painted above existing pixels).
  3. detect.path rebuilds Path2D from commands when needed and calls isPointInPath / isPointInStroke on an internal scratch canvas.

Scenes

SceneCreator accepts type: 'path' (path, options?: Path2DDrawOptions) and type: 'customLines' (lines — CustomOptions | CustomOptions[]) — same behaviour as path2d.draw / path2d.custom on a shared context.


Guide map


Minimal examples

Custom segment

SOURCEtypescript
typescript
Studio
const { buffer } = await painter.createCanvas({ width: 600, height: 400 }); await painter.path2d.custom(  {    startCoordinates: { x: 80, y: 200 },    endCoordinates: { x: 520, y: 200 },    lineStyle: { width: 4, color: '#64748b' },    arrow: { end: true, size: 14, style: 'filled', color: '#0f172a' },  },  buffer);

Path2D stroke + fill

SOURCEtypescript
typescript
Studio
const path = painter.path2d.create([  { type: 'moveTo', x: 100, y: 100 },  { type: 'lineTo', x: 400, y: 160 },  { type: 'quadraticCurveTo', cpx: 480, cpy: 80, x: 500, y: 200 },]); await painter.path2d.draw(buffer, path, {  stroke: { color: '#94a3b8', width: 3 },  fill: { color: '#1e293b', opacity: 0.35, rule: 'nonzero' },});

Next steps