fix for trapezoidal pentagon

This commit is contained in:
Ashish Jain
2024-09-29 20:42:01 +02:00
parent 9957d3101f
commit 9b269ecf3b

View File

@@ -7,15 +7,27 @@ import rough from 'roughjs';
export const trapezoidalPentagon = async (parent: SVGAElement, node: Node) => {
const { labelStyles, nodeStyles } = styles2String(node);
node.labelStyle = labelStyles;
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
const nodePadding = node.padding ?? 0;
const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
const labelPaddingY = node.look === 'neo' ? nodePadding * 1 : nodePadding;
const minWidth = 60,
minHeight = 20;
const w = Math.max(minWidth, bbox.width + (labelPaddingX ?? 0) * 2, node?.width ?? 0);
const h = Math.max(minHeight, bbox.height + (labelPaddingY ?? 0) * 2, node?.height ?? 0);
if (node.width || node.height) {
node.height = (node.height ?? 0) - labelPaddingY * 2;
if (node.height < minHeight) {
node.height = minHeight;
}
node.width = (node.width ?? 0) - labelPaddingX * 2;
if (node.width < minWidth) {
node.width = minWidth;
}
}
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
const w = Math.max(minWidth, bbox.width, node?.width ?? 0) + (labelPaddingX ?? 0) * 2;
const h = Math.max(minHeight, bbox.height, node?.height ?? 0) + (labelPaddingY ?? 0) * 2;
const { cssStyles } = node;
// @ts-ignore - rough is not typed