mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
#5237 Adding support for decision
This commit is contained in:
parent
7fe4a2ce6c
commit
b22ae106b2
@ -1,7 +1,8 @@
|
||||
import intersect from '../intersect/index.js';
|
||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||
import type { SVG } from '$root/diagram-api/types.js';
|
||||
|
||||
import rough from 'roughjs';
|
||||
import solidFillOptions from './solidFillOptions.js';
|
||||
export const choice = (parent: SVG, node: Node) => {
|
||||
const shapeSvg = parent
|
||||
.insert('g')
|
||||
@ -16,14 +17,25 @@ export const choice = (parent: SVG, node: Node) => {
|
||||
{ x: -s / 2, y: 0 },
|
||||
];
|
||||
|
||||
const choice = shapeSvg.insert('polygon', ':first-child').attr(
|
||||
'points',
|
||||
points
|
||||
.map(function (d) {
|
||||
return d.x + ',' + d.y;
|
||||
})
|
||||
.join(' ')
|
||||
);
|
||||
let choice;
|
||||
if (node.useRough) {
|
||||
const rc = rough.svg(shapeSvg);
|
||||
const pointArr = points.map(function (d) {
|
||||
return [d.x, d.y];
|
||||
});
|
||||
const roughNode = rc.polygon(pointArr, solidFillOptions);
|
||||
choice = shapeSvg.insert(() => roughNode);
|
||||
} else {
|
||||
choice = shapeSvg.insert('polygon', ':first-child').attr(
|
||||
'points',
|
||||
points
|
||||
.map(function (d) {
|
||||
return d.x + ',' + d.y;
|
||||
})
|
||||
.join(' ')
|
||||
);
|
||||
}
|
||||
|
||||
// center the circle around its coordinate
|
||||
choice.attr('class', 'state-start').attr('r', 7).attr('width', 28).attr('height', 28);
|
||||
node.width = 28;
|
||||
|
Loading…
x
Reference in New Issue
Block a user