Skip to content

Function: getSmoothStepPath ​

▸ getSmoothStepPath(«destructured»): [path: string, labelX: number, labelY: number, offsetX: number, offsetY: number]

Get a smooth step path from source to target handle

Parameters ​

NameType
«destructured»GetSmoothStepPathParams

Returns ​

[path: string, labelX: number, labelY: number, offsetX: number, offsetY: number]

A path string you can use in an SVG, the labelX and labelY position (center of path) and offsetX, offsetY between source handle and label

Example

ts
const source = { x: 0, y: 20 };
   const target = { x: 150, y: 100 };
   
   const [path, labelX, labelY, offsetX, offsetY] = getSmoothStepPath({
     sourceX: source.x,
     sourceY: source.y,
     sourcePosition: Position.Right,
     targetX: target.x,
     targetY: target.y,
     targetPosition: Position.Left,
   });

Released under the MIT License.