三次贝塞尔曲线 Cubic
三次贝塞尔曲线 Cubic 是图形对象的一种,用于创建一个三次贝塞尔曲线的图形实例,包含曲线的控制点、箭头等信息,用于渲染引擎进行绘制及交互操作。
示例
import { Cubic } from '@visactor/vgraph';
const cubic = new Cubic({
points: [[308.2842712474619, 320], [324.8528137423857, 360], [275.1471862576143, 360], [291.7157287525381, 320]],
strokeStyle: '#f50',
lineWidth: 2,
endArrow: true,
hitWidth: 6,
});

Cubic 配置项
| 字段 | 类型 | 描述 |
|---|---|---|
| points | number[][] | 一个 4×2 二维数组,每个一维数组表示一个控制点坐标,总共四个控制点 |
| startArrow | ArrowType | 起始箭头配置项 |
| endArrow | ArrowType | 终点箭头配置项 |
| hitWidth | number | 事件触发的感应宽度 |
注:当 startArrow 或 endArrow 被指定为 undefined,null 或 false 时,将不绘制任何箭头,当指定为 true 时,绘制默认的三角箭头,箭头配置项 ArrowType 定义如下:
type ArrowType = boolean | { type?: 'default' | 'default-round', width?: number, height?: number, };
| 字段 | 类型 | 描述 |
|---|---|---|
| type | string | 箭头类型,default 为默认三角形箭头,default-round 为圆角的三角形箭头 |
| width | number | 箭头翼展宽度 |
| height | number | 箭头于终点处的切向高度 |