getSimpleBezierPath()
该 getSimpleBezierPath 工具返回了你在两个节点之间渲染一个简单的贝塞尔曲线边缘所需的一切。
import { Position, getSimpleBezierPath } from '@xyflow/react';
 
const source = { x: 0, y: 20 };
const target = { x: 150, y: 100 };
 
const [path, labelX, labelY, offsetX, offsetY] = getSimpleBezierPath({
  sourceX: source.x,
  sourceY: source.y,
  sourcePosition: Position.Right,
  targetX: target.x,
  targetY: target.y,
  targetPosition: Position.Left,
});
 
console.log(path); //=> "M0,20 C75,20 75,100 150,100"
console.log(labelX, labelY); //=> 75, 60
console.log(offsetX, offsetY); //=> 75, 40签名
| 名称 | 类型 | 默认值 | 
|---|---|---|
| #参数 |  |  | 
| # params | object |  | 
| # params.sourceX | number |  | 
| # params.sourceY | number |  | 
| # params.sourcePosition? | Position |  | 
| # params.targetX | number |  | 
| # params.targetY | number |  | 
| # params.targetPosition? | Position |  | 
| #返回 |  |  | 
| # [0] | string在 SVG <path> 元素中使用的路径。 |  | 
| # [1] | number你可以用来渲染此边缘标签的 x 位置。 |  | 
| # [2] | number你可以用来渲染此边缘标签的 y 位置。 |  | 
| # [3] | number源 x 位置与此路径中间点的 x 位置之间的绝对差值。 |  | 
| # [4] | number源 y 位置与此路径中间点的 y 位置之间的绝对差值。 |  | 
备注
- 此函数返回一个元组(也称为固定大小的数组),使其更容易一次处理多个边缘路径。