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

Node / Lines Connectors · guide

Arrows, markers, dash presets & textures

Current Apexify.js 6.0.0 documentation for Arrows, markers, dash presets & textures.

apexify.jsRuntime: nodeCURRENTSince 6.0.0

Helpers live in lib-next/path/advanced-lines.ts and are invoked from custom-lines.ts after the main stroke for each CustomOptions row.


Arrows (arrow)

SOURCEtypescript
typescript
Studio
arrow?: {  start?: boolean;  end?: boolean;  size?: number;              // default 10  style?: 'filled' | 'outline';  color?: string;             // fallback: line colour → black};

drawArrow translates to (x,y), rotates by segment angle, draws a triangular head:

  • filled — fillStyle = color
  • outline — strokeStyle, lineWidth = 2

Angles derive from atan2(end.y - start.y, end.x - start.x) where start respects singleLine chaining (previous row end).


Markers (markers)

SOURCEtypescript
typescript
Studio
markers?: Array<{  position: number;        // 0 … 1 along polyline length [start → end]  shape: 'circle' | 'square' | 'diamond' | 'arrow';  size: number;  color: string;}>;

getPointOnLinePath walks straight segments (currently only [start, end] pair per row) and interpolates position clamped [0,1].

drawMarker shapes:

ShapeDrawing
circleFilled arc (radius = size/2)
squarefillRect centred
diamondFour lineTo polygon
arrowUp-pointing triangle

Markers paint above the connector stroke.


Dash presets (pattern)

SOURCEtypescript
typescript
Studio
pattern?: {  type: 'dots' | 'dashes' | 'custom';  segments?: number[];   // custom dash array  offset?: number;       // lineDashOffset};
typesetLineDash
dots[2, 4]
dashes[10, 5]
customsegments array (must be non-empty)

When pattern is present lineDash from lineStyle is skipped.


Image texture (texture)

texture?: string | Buffer

applyLineTexture resolves sources:

InputResolution
BufferloadImage(buffer)
http… URLloadImage(url)
Else filesystem pathpath.join(process.cwd(), texture) + fs.readFileSync

On success strokeStyle = ctx.createPattern(image, 'repeat'). Errors console.error and leave prior strokeStyle.


Example — dashed lane + markers

SOURCEtypescript
typescript
Studio
await painter.path2d.custom(  {    startCoordinates: { x: 40, y: 120 },    endCoordinates: { x: 560, y: 120 },    lineStyle: {      width: 3,      color: '#475569',      pattern: { type: 'dashes', offset: 4 },    },    markers: [      { position: 0.25, shape: 'circle', size: 12, color: '#22c55e' },      { position: 0.75, shape: 'diamond', size: 14, color: '#eab308' },    ],    arrow: { end: true, style: 'outline', color: '#0f172a', size: 16 },  },  buffer);

Next steps