mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 07:19:41 +02:00
Merge branch 'knsv/new-shapes' of https://github.com/mermaid-js/mermaid into knsv/new-shapes
This commit is contained in:
@@ -14,8 +14,8 @@ export const hourglass = async (parent: SVGAElement, node: Node) => {
|
|||||||
node.labelStyle = labelStyles;
|
node.labelStyle = labelStyles;
|
||||||
const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node));
|
const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node));
|
||||||
|
|
||||||
const w = 100;
|
const w = Math.max(30, node?.width ?? 0);
|
||||||
const h = 100;
|
const h = Math.max(30, node?.height ?? 0);
|
||||||
|
|
||||||
const { cssStyles } = node;
|
const { cssStyles } = node;
|
||||||
|
|
||||||
|
@@ -19,9 +19,9 @@ export const lightningBolt = (parent: SVG, node: Node) => {
|
|||||||
.attr('class', getNodeClasses(node))
|
.attr('class', getNodeClasses(node))
|
||||||
.attr('id', node.domId ?? node.id);
|
.attr('id', node.domId ?? node.id);
|
||||||
const { cssStyles } = node;
|
const { cssStyles } = node;
|
||||||
const height = 80;
|
const width = Math.max(35, node?.width ?? 0);
|
||||||
const width = 80;
|
const height = Math.max(35, node?.height ?? 0);
|
||||||
const gap = 16;
|
const gap = 7;
|
||||||
|
|
||||||
const points = [
|
const points = [
|
||||||
{ x: width, y: 0 },
|
{ x: width, y: 0 },
|
||||||
|
@@ -97,7 +97,7 @@ export const linedCylinder = async (parent: SVGAElement, node: Node) => {
|
|||||||
Math.abs(pos.y - (node.y ?? 0)) > (node.height ?? 0) / 2 - ry))
|
Math.abs(pos.y - (node.y ?? 0)) > (node.height ?? 0) / 2 - ry))
|
||||||
) {
|
) {
|
||||||
let y = ry * ry * (1 - (x * x) / (rx * rx));
|
let y = ry * ry * (1 - (x * x) / (rx * rx));
|
||||||
if (y != 0) {
|
if (y > 0) {
|
||||||
y = Math.sqrt(y);
|
y = Math.sqrt(y);
|
||||||
}
|
}
|
||||||
y = ry - y;
|
y = ry - y;
|
||||||
|
@@ -11,9 +11,10 @@ export const trapezoidalPentagon = async (parent: SVGAElement, node: Node) => {
|
|||||||
const { labelStyles, nodeStyles } = styles2String(node);
|
const { labelStyles, nodeStyles } = styles2String(node);
|
||||||
node.labelStyle = labelStyles;
|
node.labelStyle = labelStyles;
|
||||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
||||||
const widthMultiplier = bbox.width < 40 ? 3 : 1.25;
|
const minWidth = 60,
|
||||||
const w = (bbox.width + node.padding) * widthMultiplier;
|
minHeight = 20;
|
||||||
const h = bbox.height + node.padding;
|
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;
|
const { cssStyles } = node;
|
||||||
// @ts-ignore - rough is not typed
|
// @ts-ignore - rough is not typed
|
||||||
@@ -25,16 +26,13 @@ export const trapezoidalPentagon = async (parent: SVGAElement, node: Node) => {
|
|||||||
options.fillStyle = 'solid';
|
options.fillStyle = 'solid';
|
||||||
}
|
}
|
||||||
|
|
||||||
const topOffset = 30;
|
|
||||||
const slopeHeight = 15;
|
|
||||||
|
|
||||||
const points = [
|
const points = [
|
||||||
{ x: topOffset, y: 0 },
|
{ x: (-w / 2) * 0.8, y: -h / 2 },
|
||||||
{ x: w - topOffset, y: 0 },
|
{ x: (w / 2) * 0.8, y: -h / 2 },
|
||||||
{ x: w, y: slopeHeight },
|
{ x: w / 2, y: (-h / 2) * 0.6 },
|
||||||
{ x: w, y: h },
|
{ x: w / 2, y: h / 2 },
|
||||||
{ x: 0, y: h },
|
{ x: -w / 2, y: h / 2 },
|
||||||
{ x: 0, y: slopeHeight },
|
{ x: -w / 2, y: (-h / 2) * 0.6 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const pathData = createPathFromPoints(points);
|
const pathData = createPathFromPoints(points);
|
||||||
@@ -51,8 +49,6 @@ export const trapezoidalPentagon = async (parent: SVGAElement, node: Node) => {
|
|||||||
polygon.selectChildren('path').attr('style', nodeStyles);
|
polygon.selectChildren('path').attr('style', nodeStyles);
|
||||||
}
|
}
|
||||||
|
|
||||||
polygon.attr('transform', `translate(${-w / 2}, ${-h / 2})`);
|
|
||||||
|
|
||||||
updateNodeBounds(node, polygon);
|
updateNodeBounds(node, polygon);
|
||||||
|
|
||||||
node.intersect = function (point) {
|
node.intersect = function (point) {
|
||||||
|
Reference in New Issue
Block a user