#5237 Adding support for decision

This commit is contained in:
Knut Sveidqvist 2024-04-26 15:00:19 +02:00
parent 7fe4a2ce6c
commit b22ae106b2
1 changed files with 21 additions and 9 deletions

View File

@ -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;