/* eslint-disable */
import G6 from '@antv/g6';
const FORM_NOOD = {
width: 150,
height: 50
};
function registerFormNode() {
G6.registerNode(
'rect-form-node',
{
draw(cfg, group) {
let form_node_main_box = renderFormNodeMainBox(cfg, group);
let form_node_txt = renderFormTxt(cfg, group);
return form_node_main_box
}
},
'rect'
);
return 'rect-form-node';
};
function renderFormNodeMainBox(cfg, group) {
return group.addShape('rect', {
attrs: {
stroke: '#333',
x: 0,
y: 0,
width: FORM_NOOD.width,
height: FORM_NOOD.height,
lineWidth: 1,
cursor: 'pointer',
shadowColor: 'rgb(184, 185, 187)',
shadowBlur: 5,
shadowOffsetX: 2,
shadowOffsetY: 2,
fill: '#fff',
},
name: 'form-node-main-box-shape',
});
};
function renderFormTxt(cfg, group) {
return group.addShape('text', {
attrs: {
text: cfg.label,
x: FORM_NOOD.width/2,
y: FORM_NOOD.height/2,
fontSize: 14,
textAlign: 'center',
textBaseline: 'middle',
fill: '#0000D9',
},
name: 'form-node-text-shape',
draggable: true,
});
};
function renderAnchorPoints() {
return [
[0, 0], // 0
[0.1, 0], // 1
[0.2, 0], // 2
[0.3, 0], // 3
[0.4, 0], // 4
[0.5, 0], // 5
[0.6, 0], // 6
[0.7, 0], // 7
[0.8, 0], // 8
[0.9, 0], // 9
[1, 0], // 10
[1, 0.1], // 11
[1, 0.2], // 12
[1, 0.3], // 13
[1, 0.4], // 14
[1, 0.5], // 15
[1, 0.6], // 16
[1, 0.7], // 17
[1, 0.8], // 18
[1, 0.9], // 19
[1, 1], // 20
[0.9, 1], // 21
[0.8, 1], // 22
[0.7, 1], // 23
[0.6, 1], // 24
[0.5, 1], // 25
[0.4, 1], // 26
[0.3, 1], // 27
[0.2, 1], // 28
[0.1, 1], // 29
[0, 1], // 30
[0, 0.9], // 31
[0, 0.8], // 32
[0, 0.7], // 33
[0, 0.6], // 34
[0, 0.5], // 35
]
};
// shapes: [form-node-main-box-shape, form-node-text-shape]
let formNodeConfig = {
customNode: registerFormNode(),
anchorPoints: renderAnchorPoints()
};
export default formNodeConfig;