diff --git a/cypress/platform/flowchart-sate.html b/cypress/platform/flowchart-sate.html
index 83e46363a..61c3c167d 100644
--- a/cypress/platform/flowchart-sate.html
+++ b/cypress/platform/flowchart-sate.html
@@ -91,10 +91,8 @@
|
- Dagre |
- Dagre with rough |
- ELK |
- ELK with rough |
+ State rough |
+ Flowchart rough |
%%{init: {"look": "handdrawn"} }%%
-stateDiagram-v2
+stateDiagram-v2
stateA
@@ -120,14 +118,14 @@ stateDiagram-v2
%%{init: {"look": "handdrawn"} }%%
flowchart LR
- id1([This is the text in the box])
+ id1[[This is the text in the box]]
|
-
+
-
+
diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts
index 0574ab6cb..48054cce3 100644
--- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts
+++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts
@@ -1,19 +1,15 @@
import { log } from '$root/logger.js';
-import { labelHelper, updateNodeBounds } from './util.js';
+import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
import intersect from '../intersect/index.js';
-import { getConfig } from '$root/diagram-api/diagramAPI.js';
import type { Node } from '$root/rendering-util/types.d.ts';
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
import rough from 'roughjs';
export const circle = async (parent: SVGAElement, node: Node): Promise => {
- const { themeVariables, handdrawnSeed } = getConfig();
- const { nodeBorder, mainBkg } = themeVariables;
-
const { shapeSvg, bbox, halfPadding } = await labelHelper(
parent,
node,
- 'node ' + node.cssClasses,
+ getNodeClasses(node),
true
);
@@ -22,17 +18,9 @@ export const circle = async (parent: SVGAElement, node: Node): Promise roughNode, ':first-child');
diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts
index cd12792c6..f8e849382 100644
--- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts
+++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts
@@ -1,7 +1,6 @@
import { log } from '$root/logger.js';
-import { labelHelper, updateNodeBounds } from './util.js';
+import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
import intersect from '../intersect/index.js';
-import { getConfig } from '$root/diagram-api/diagramAPI.js';
import type { Node } from '$root/rendering-util/types.d.ts';
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
import rough from 'roughjs';
@@ -33,17 +32,35 @@ export const createCylinderPathD = (
`l0,${-height}`,
].join(' ');
};
-
+export const createOuterCylinderPathD = (
+ x: number,
+ y: number,
+ width: number,
+ height: number,
+ rx: number,
+ ry: number
+): string => {
+ return [
+ `M${x},${y + ry}`,
+ `M${x + width},${y + ry}`,
+ `a${rx},${ry} 0,0,0 ${-width},0`,
+ `l0,${height}`,
+ `a${rx},${ry} 0,0,0 ${width},0`,
+ `l0,${-height}`,
+ ].join(' ');
+};
+export const createInnerCylinderPathD = (
+ x: number,
+ y: number,
+ width: number,
+ height: number,
+ rx: number,
+ ry: number
+): string => {
+ return [`M${x - width / 2},${-height / 2}`, `a${rx},${ry} 0,0,0 ${width},0`].join(' ');
+};
export const cylinder = async (parent: SVGAElement, node: Node) => {
- const { themeVariables, handdrawnSeed } = getConfig();
- const { nodeBorder, mainBkg } = themeVariables;
-
- const { shapeSvg, bbox, halfPadding } = await labelHelper(
- parent,
- node,
- 'node ' + node.cssClasses, // + ' ' + node.class,
- true
- );
+ const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
const w = bbox.width + node.padding;
const rx = w / 2;
@@ -54,21 +71,15 @@ export const cylinder = async (parent: SVGAElement, node: Node) => {
const { cssStyles, useRough } = node;
if (useRough) {
- console.log('Cylinder: Inside use useRough');
+ // @ts-ignore
const rc = rough.svg(shapeSvg);
- const options = userNodeOverrides(node, {
- roughness: 0.7,
- fill: mainBkg,
- fillStyle: 'hachure',
- fillWeight: 1.5,
- stroke: nodeBorder,
- seed: handdrawnSeed,
- strokeWidth: 1,
- });
- const pathData = createCylinderPathD(0, 0, w, h, rx, ry);
- const roughNode = rc.path(pathData, options);
+ const outerPathData = createOuterCylinderPathD(0, 0, w, h, rx, ry);
+ const innerPathData = createInnerCylinderPathD(0, ry, w, h, rx, ry);
+ const outerNode = rc.path(outerPathData, userNodeOverrides(node, {}));
+ const innerLine = rc.path(innerPathData, userNodeOverrides(node, { fill: 'none' }));
- cylinder = shapeSvg.insert(() => roughNode, ':first-child');
+ cylinder = shapeSvg.insert(() => innerLine, ':first-child');
+ cylinder = shapeSvg.insert(() => outerNode, ':first-child');
cylinder.attr('class', 'basic label-container');
if (cssStyles) {
cylinder.attr('style', cssStyles);
diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts
index 49e4051c3..b32420cc0 100644
--- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts
+++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts
@@ -1,5 +1,5 @@
import { log } from '$root/logger.js';
-import { labelHelper, updateNodeBounds } from './util.js';
+import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
import intersect from '../intersect/index.js';
import { getConfig } from '$root/diagram-api/diagramAPI.js';
import type { Node } from '$root/rendering-util/types.d.ts';
@@ -8,8 +8,8 @@ import rough from 'roughjs';
//import d3 from 'd3';
export const doublecircle = async (parent: SVGAElement, node: Node): Promise => {
- const { themeVariables, handdrawnSeed } = getConfig();
- const { nodeBorder, mainBkg } = themeVariables;
+ const { themeVariables } = getConfig();
+ const { mainBkg } = themeVariables;
const { shapeSvg, bbox, halfPadding } = await labelHelper(
parent,
@@ -25,17 +25,9 @@ export const doublecircle = async (parent: SVGAElement, node: Node): Promise