Updated triangle and slopedRect

This commit is contained in:
saurabhg772244
2024-08-16 16:47:49 +05:30
parent c983c0605e
commit d30444dae7
2 changed files with 11 additions and 6 deletions

View File

@@ -49,7 +49,10 @@ export const slopedRect = async (parent: SVGAElement, node: Node) => {
}
polygon.attr('transform', `translate(0, ${h / 4})`);
label.attr('transform', `translate(${-w / 2 + (node.padding ?? 0)}, ${-(node.padding ?? 0)})`);
label.attr(
'transform',
`translate(${-w / 2 + (node.padding ?? 0)}, ${-h / 4 + (node.padding ?? 0)})`
);
updateNodeBounds(node, polygon);

View File

@@ -14,12 +14,14 @@ export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAEle
node.labelStyle = labelStyles;
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
const w = bbox.width + node.padding + 20;
const h = (Math.sqrt(3) / 2) * w + (node.padding ?? 0);
const w = bbox.width + (node.padding ?? 0);
const h = w + bbox.height;
const tw = w + bbox.height;
const points = [
{ x: 0, y: 0 },
{ x: w, y: 0 },
{ x: w / 2, y: -h },
{ x: tw, y: 0 },
{ x: tw / 2, y: -h },
];
const { cssStyles } = node;
@@ -36,7 +38,7 @@ export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAEle
const polygon = shapeSvg
.insert(() => roughNode, ':first-child')
.attr('transform', `translate(${-w / 2}, ${h / 2})`);
.attr('transform', `translate(${-h / 2}, ${h / 2})`);
if (cssStyles) {
polygon.attr('style', cssStyles);