UNPKG

@antv/g6

Version:

A Graph Visualization Framework in JavaScript

28 lines 1.1 kB
import { mergeOptions } from '../../utils/style'; import { Cubic } from './cubic'; /** * <zh/> 垂直方向的三次贝塞尔曲线 * * <en/> Cubic Bezier curve in vertical direction * @remarks * <zh/> 特别注意,计算控制点时主要考虑 y 轴上的距离,忽略 x 轴的变化 * * <en/> Please note that when calculating the control points, the distance on the y-axis is mainly considered, and the change on the x-axis is ignored */ export class CubicVertical extends Cubic { constructor(options) { super(mergeOptions({ style: CubicVertical.defaultStyleProps }, options)); } getControlPoints(sourcePoint, targetPoint, curvePosition, curveOffset) { const yDist = targetPoint[1] - sourcePoint[1]; return [ [sourcePoint[0], sourcePoint[1] + yDist * curvePosition[0] + curveOffset[0]], [targetPoint[0], targetPoint[1] - yDist * curvePosition[1] + curveOffset[1]], ]; } } CubicVertical.defaultStyleProps = { curvePosition: [0.5, 0.5], curveOffset: [0, 0], }; //# sourceMappingURL=cubic-vertical.js.map