butterfly-dag
Version:
一个基于数据驱动的节点式编排组件库,让你有方便快捷定制可视化流程图表
27 lines (21 loc) • 954 B
JavaScript
;
import {_calcOrientation, _findSecondControlPoint} from './_utils.js';
const drawSecondBezier = (sourcePoint, targetPoint, shapeType) => {
if (!sourcePoint.orientation) {
sourcePoint.orientation = _calcOrientation(targetPoint.pos[0], targetPoint.pos[1], sourcePoint.pos[0], sourcePoint.pos[1]);
}
if (!targetPoint.orientation) {
targetPoint.orientation = _calcOrientation(sourcePoint.pos[0], sourcePoint.pos[1], targetPoint.pos[0], targetPoint.pos[1]);
}
// 控制点
let _so = sourcePoint.orientation;
let _to = targetPoint.orientation;
let ctrlPoint = _findSecondControlPoint(sourcePoint, targetPoint, _so, _to, shapeType);
// 起始点
let result = ['M', sourcePoint.pos[0], sourcePoint.pos[1]];
result = result.concat(['Q', ctrlPoint[0], ctrlPoint[1]]);
// 结束点
result = result.concat([targetPoint.pos[0], targetPoint.pos[1]]);
return result.join(' ');
}
export default drawSecondBezier;