#5237 Adding support for decision

This commit is contained in:
Knut Sveidqvist
2024-04-26 15:00:19 +02:00
parent 7fe4a2ce6c
commit b22ae106b2

View File

@@ -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,14 +17,25 @@ 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;
'points', if (node.useRough) {
points const rc = rough.svg(shapeSvg);
.map(function (d) { const pointArr = points.map(function (d) {
return d.x + ',' + d.y; return [d.x, d.y];
}) });
.join(' ') 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 // 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;