From 2c0d48eef506d19e1312cd1d92de39421b01f76e Mon Sep 17 00:00:00 2001 From: saurabhg772244 Date: Fri, 27 Sep 2024 17:07:53 +0530 Subject: [PATCH] updated shapes --- .../rendering-elements/shapes/crossedCircle.ts | 13 ++++++------- .../rendering-elements/shapes/hourglass.ts | 4 ++-- .../rendering-elements/shapes/lightningBolt.ts | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/crossedCircle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/crossedCircle.ts index 83c4d0beb..ff298c5d3 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/crossedCircle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/crossedCircle.ts @@ -7,14 +7,13 @@ import { userNodeOverrides } from './handDrawnShapeStyles.js'; import { getNodeClasses, updateNodeBounds } from './util.js'; function createLine(r: number) { - const xAxis45 = Math.cos(Math.PI / 4); // cosine of 45 degrees - const yAxis45 = Math.sin(Math.PI / 4); // sine of 45 degrees + const axis45 = Math.SQRT1_2; // cosine of 45 degrees = 1/sqrt(2) const lineLength = r * 2; - const pointQ1 = { x: (lineLength / 2) * xAxis45, y: (lineLength / 2) * yAxis45 }; // Quadrant I - const pointQ2 = { x: -(lineLength / 2) * xAxis45, y: (lineLength / 2) * yAxis45 }; // Quadrant II - const pointQ3 = { x: -(lineLength / 2) * xAxis45, y: -(lineLength / 2) * yAxis45 }; // Quadrant III - const pointQ4 = { x: (lineLength / 2) * xAxis45, y: -(lineLength / 2) * yAxis45 }; // Quadrant IV + const pointQ1 = { x: (lineLength / 2) * axis45, y: (lineLength / 2) * axis45 }; // Quadrant I + const pointQ2 = { x: -(lineLength / 2) * axis45, y: (lineLength / 2) * axis45 }; // Quadrant II + const pointQ3 = { x: -(lineLength / 2) * axis45, y: -(lineLength / 2) * axis45 }; // Quadrant III + const pointQ4 = { x: (lineLength / 2) * axis45, y: -(lineLength / 2) * axis45 }; // Quadrant IV return `M ${pointQ2.x},${pointQ2.y} L ${pointQ4.x},${pointQ4.y} M ${pointQ1.x},${pointQ1.y} L ${pointQ3.x},${pointQ3.y}`; @@ -26,7 +25,7 @@ export const crossedCircle = (parent: SVG, node: Node) => { .insert('g') .attr('class', getNodeClasses(node)) .attr('id', node.domId ?? node.id); - const radius = Math.max(30, node?.width ?? 0); + const radius = Math.max(25, (node?.width ?? 0) / 2, (node?.height ?? 0) / 2); const { cssStyles } = node; // @ts-ignore - rough is not typed diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/hourglass.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/hourglass.ts index 2c14f8a43..cdaab2e88 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/hourglass.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/hourglass.ts @@ -9,8 +9,8 @@ export const hourglass = async (parent: SVGAElement, node: Node) => { node.label = ''; const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node)); - const w = Math.max(30, node?.width ?? 0); - const h = Math.max(30, node?.height ?? 0); + const w = Math.max(50, node?.width ?? 0); + const h = Math.max(50, node?.height ?? 0); const { cssStyles } = node; // @ts-ignore - rough is not typed diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/lightningBolt.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/lightningBolt.ts index bb82cf2c3..f3691fc98 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/lightningBolt.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/lightningBolt.ts @@ -16,8 +16,8 @@ export const lightningBolt = (parent: SVG, node: Node) => { const gapX = Math.max(5, (node.width ?? 0) * 0.1); const gapY = Math.max(5, (node.height ?? 0) * 0.1); - const width = Math.max(50, node?.width ?? 0 - gapX); - const height = Math.max(50, node?.height ?? 0 - gapY); + const width = Math.max(50, node?.width ?? 0); + const height = Math.max(50, node?.height ?? 0); const points = [ { x: width, y: 0 },