mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-12 11:59:39 +02:00
#5237 Adding support for decision
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
import intersect from '../intersect/index.js';
|
import intersect from '../intersect/index.js';
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import type { SVG } from '$root/diagram-api/types.js';
|
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) => {
|
export const choice = (parent: SVG, node: Node) => {
|
||||||
const shapeSvg = parent
|
const shapeSvg = parent
|
||||||
.insert('g')
|
.insert('g')
|
||||||
@@ -16,7 +17,16 @@ export const choice = (parent: SVG, node: Node) => {
|
|||||||
{ x: -s / 2, y: 0 },
|
{ x: -s / 2, y: 0 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const choice = shapeSvg.insert('polygon', ':first-child').attr(
|
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',
|
||||||
points
|
points
|
||||||
.map(function (d) {
|
.map(function (d) {
|
||||||
@@ -24,6 +34,8 @@ export const choice = (parent: SVG, node: Node) => {
|
|||||||
})
|
})
|
||||||
.join(' ')
|
.join(' ')
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// center the circle around its coordinate
|
// center the circle around its coordinate
|
||||||
choice.attr('class', 'state-start').attr('r', 7).attr('width', 28).attr('height', 28);
|
choice.attr('class', 'state-start').attr('r', 7).attr('width', 28).attr('height', 28);
|
||||||
node.width = 28;
|
node.width = 28;
|
||||||
|
Reference in New Issue
Block a user