51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
/*
|
|
* This file is part of the kernelstudio package.
|
|
*
|
|
* (c) 2014-2025 zlin <admin@kernelstudio.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE file
|
|
* that was distributed with this source code.
|
|
*/
|
|
|
|
export const createPort = (name: string = 'top', args: Record<any, any> = { dx: 0 }) => {
|
|
return {
|
|
position: { name: name, args: args },
|
|
attrs: {
|
|
circle: {
|
|
r: 4, // 大小
|
|
magnet: true,
|
|
stroke: '#1b5e9f', // 边框颜色
|
|
strokeWidth: 1, // 边框大小
|
|
fill: '#3578bf', // 填充颜色
|
|
style: {
|
|
visibility: 'visible', // 是否可见
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|
|
|
|
export const createPorts = (top: boolean = true, right: boolean = true, bottom: boolean = true, left: boolean = true) => {
|
|
const groups: any = {};
|
|
const items: any = [];
|
|
if (top) {
|
|
groups['top'] = createPort('top');
|
|
items.push({ group: 'top', id: 'top' });
|
|
}
|
|
if (right) {
|
|
groups['right'] = createPort('right');
|
|
items.push({ group: 'right', id: 'right' });
|
|
}
|
|
if (bottom) {
|
|
groups['bottom'] = createPort('bottom');
|
|
items.push({ group: 'bottom', id: 'bottom' });
|
|
}
|
|
if (left) {
|
|
groups['left'] = createPort('left');
|
|
items.push({ group: 'left', id: 'left' });
|
|
}
|
|
return {
|
|
groups: groups,
|
|
items: items,
|
|
};
|
|
}; |