Merge branch 'neo-new-shapes' of github.com:Mermaid-Chart/alana-mermaid into neo-new-shapes

This commit is contained in:
Knut Sveidqvist
2024-09-10 13:43:38 +02:00
2 changed files with 11 additions and 5 deletions

View File

@@ -34,8 +34,11 @@ export const curvedTrapezoid = async (parent: SVGAElement, node: Node) => {
node.labelStyle = labelStyles;
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
const widthMultiplier = bbox.width < 15 ? 2 : 1.25;
const w = (bbox.width + node.padding) * widthMultiplier;
const h = bbox.height + node.padding;
const nodePadding = node.padding ?? 0;
const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
const labelPaddingY = node.look === 'neo' ? nodePadding * 1 : nodePadding;
const w = Math.max((bbox.width + labelPaddingX) * widthMultiplier, node?.width ?? 500);
const h = Math.max(bbox.height + labelPaddingY, node?.height ?? 100);
const radius = h / 2;
const { cssStyles } = node;

View File

@@ -37,10 +37,13 @@ export const linedCylinder = async (parent: SVGAElement, node: Node) => {
const { labelStyles, nodeStyles } = styles2String(node);
node.labelStyle = labelStyles;
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
const w = bbox.width + node.padding;
const nodePadding = node.padding ?? 0;
const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
const labelPaddingY = node.look === 'neo' ? nodePadding * 1 : nodePadding;
const w = Math.max(bbox.width + labelPaddingX, node?.width ?? 0);
const rx = w / 2;
const ry = rx / (2.5 + w / 50);
const h = bbox.height + ry + node.padding;
const h = Math.max(bbox.height + ry + labelPaddingY, node?.height ?? 0);
const outerOffset = h * 0.1; // 10% of height
const { cssStyles } = node;
@@ -83,7 +86,7 @@ export const linedCylinder = async (parent: SVGAElement, node: Node) => {
label.attr(
'transform',
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${h / 2 - bbox.height})`
`translate(${-(bbox.width / 2) - (bbox.x - (bbox.left ?? 0))}, ${-(bbox.height / 2) + ry - (bbox.y - (bbox.top ?? 0))})`
);
node.intersect = function (point) {