Merge branch 'knsv/new-shapes' of https://github.com/mermaid-js/mermaid into knsv/new-shapes

This commit is contained in:
saurabhg772244
2024-09-04 18:54:53 +05:30
4 changed files with 16 additions and 20 deletions

View File

@@ -14,8 +14,8 @@ export const hourglass = async (parent: SVGAElement, node: Node) => {
node.labelStyle = labelStyles;
const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node));
const w = 100;
const h = 100;
const w = Math.max(30, node?.width ?? 0);
const h = Math.max(30, node?.height ?? 0);
const { cssStyles } = node;

View File

@@ -19,9 +19,9 @@ export const lightningBolt = (parent: SVG, node: Node) => {
.attr('class', getNodeClasses(node))
.attr('id', node.domId ?? node.id);
const { cssStyles } = node;
const height = 80;
const width = 80;
const gap = 16;
const width = Math.max(35, node?.width ?? 0);
const height = Math.max(35, node?.height ?? 0);
const gap = 7;
const points = [
{ x: width, y: 0 },

View File

@@ -97,7 +97,7 @@ export const linedCylinder = async (parent: SVGAElement, node: Node) => {
Math.abs(pos.y - (node.y ?? 0)) > (node.height ?? 0) / 2 - ry))
) {
let y = ry * ry * (1 - (x * x) / (rx * rx));
if (y != 0) {
if (y > 0) {
y = Math.sqrt(y);
}
y = ry - y;

View File

@@ -11,9 +11,10 @@ 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 widthMultiplier = bbox.width < 40 ? 3 : 1.25;
const w = (bbox.width + node.padding) * widthMultiplier;
const h = bbox.height + node.padding;
const minWidth = 60,
minHeight = 20;
const w = Math.max(minWidth, bbox.width + (node.padding ?? 0) * 2, node?.width ?? 0);
const h = Math.max(minHeight, bbox.height + (node.padding ?? 0) * 2, node?.height ?? 0);
const { cssStyles } = node;
// @ts-ignore - rough is not typed
@@ -25,16 +26,13 @@ export const trapezoidalPentagon = async (parent: SVGAElement, node: Node) => {
options.fillStyle = 'solid';
}
const topOffset = 30;
const slopeHeight = 15;
const points = [
{ x: topOffset, y: 0 },
{ x: w - topOffset, y: 0 },
{ x: w, y: slopeHeight },
{ x: w, y: h },
{ x: 0, y: h },
{ x: 0, y: slopeHeight },
{ x: (-w / 2) * 0.8, y: -h / 2 },
{ x: (w / 2) * 0.8, y: -h / 2 },
{ x: w / 2, y: (-h / 2) * 0.6 },
{ x: w / 2, y: h / 2 },
{ x: -w / 2, y: h / 2 },
{ x: -w / 2, y: (-h / 2) * 0.6 },
];
const pathData = createPathFromPoints(points);
@@ -51,8 +49,6 @@ export const trapezoidalPentagon = async (parent: SVGAElement, node: Node) => {
polygon.selectChildren('path').attr('style', nodeStyles);
}
polygon.attr('transform', `translate(${-w / 2}, ${-h / 2})`);
updateNodeBounds(node, polygon);
node.intersect = function (point) {