Updating odd shape

This commit is contained in:
Knut Sveidqvist
2024-09-27 11:59:05 +02:00
parent 9da6321c4b
commit 1ef4c42bcf

View File

@@ -10,22 +10,34 @@ export const rect_left_inv_arrow = async (
): Promise<SVGAElement> => {
const { labelStyles, nodeStyles } = styles2String(node);
node.labelStyle = labelStyles;
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
const nodePadding = node.padding ?? 0;
const labelPaddingX = node.look === 'neo' ? nodePadding * 3 : node.padding;
const labelPaddingY = node.look === 'neo' ? nodePadding * 1.5 : node.padding;
const labelPaddingX = node.look === 'neo' ? nodePadding * 3 : (node.padding ?? 0);
const labelPaddingY = node.look === 'neo' ? nodePadding * 1.5 : (node.padding ?? 0);
const w = Math.max(bbox.width + labelPaddingY, node?.width ?? 0);
const h = Math.max(bbox.height + labelPaddingX, node?.height ?? 0);
if (node.width || node.height) {
node.width = (node?.width ?? 0) - labelPaddingX * 2;
if (node.width < 50) {
node.width = 50;
}
node.height = (node?.height ?? 0) - labelPaddingY * 2;
if (node.height < 50) {
node.height = 50;
}
}
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
const w = Math.max(bbox.width, node?.width ?? 0) + labelPaddingX * 2;
const h = Math.max(bbox.height, node?.height ?? 0) + labelPaddingY * 2;
const x = -w / 2;
const y = -h / 2;
const notch = y / 2;
const notch = -y / 2;
const points = [
{ x: x + notch, y },
{ x: x, y: 0 },
{ x: x + notch, y: -y },
{ x: x, y },
{ x: x + notch, y: 0 },
{ x: x, y: -y },
{ x: -x, y: -y },
{ x: -x, y },
];
@@ -58,7 +70,7 @@ export const rect_left_inv_arrow = async (
label.attr(
'transform',
`translate(${-notch / 2 - bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${-(bbox.height / 2) - (bbox.y - (bbox.top ?? 0))})`
`translate(${bbox.x - bbox.width / 2}, ${-(bbox.height / 2) - (bbox.y - (bbox.top ?? 0))})`
);
updateNodeBounds(node, polygon);