File size: 1,137 Bytes
863ce2d
a08cfee
863ce2d
 
 
 
 
 
a08cfee
863ce2d
 
 
 
 
 
 
a08cfee
 
 
863ce2d
b83f5a0
 
 
 
a08cfee
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { BaseEdge, Position } from "@xyflow/react";

function addOffset(x: number, y: number, p: Position, offset: number) {
  if (p === Position.Top) return `${x},${y - offset}`;
  if (p === Position.Bottom) return `${x},${y + offset}`;
  if (p === Position.Left) return `${x - offset},${y}`;
  return `${x + offset},${y}`;
}

export default function LynxKiteEdge(props: any) {
  const offset = 0.3 * Math.hypot(props.targetX - props.sourceX, props.targetY - props.sourceY);
  const s = addOffset(props.sourceX, props.sourceY, props.sourcePosition, 0);
  const sc = addOffset(props.sourceX, props.sourceY, props.sourcePosition, offset);
  const tc = addOffset(props.targetX, props.targetY, props.targetPosition, offset);
  const t = addOffset(props.targetX, props.targetY, props.targetPosition, 0);
  const path = `M${s} C${sc} ${tc} ${t}`;
  return (
    <>
      <BaseEdge
        path={path}
        labelX={props.labelX}
        labelY={props.labelY}
        markerStart={props.markerStart}
        markerEnd={props.markerEnd}
        style={{
          strokeWidth: 2,
          stroke: "black",
        }}
      />
    </>
  );
}