mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-14 17:54:13 +01:00
#5237 Finishing the roughup of the nodes
This commit is contained in:
@@ -91,10 +91,8 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th> <!-- Placeholder for the top left corner -->
|
<th></th> <!-- Placeholder for the top left corner -->
|
||||||
<th>Dagre</th>
|
<th>State rough</th>
|
||||||
<th>Dagre with rough</th>
|
<th>Flowchart rough</th>
|
||||||
<th>ELK</th>
|
|
||||||
<th>ELK with rough</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="vertical-header">
|
<th class="vertical-header">
|
||||||
@@ -111,7 +109,7 @@
|
|||||||
<td>
|
<td>
|
||||||
<pre id="diagram1" class="mermaid">
|
<pre id="diagram1" class="mermaid">
|
||||||
%%{init: {"look": "handdrawn"} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
stateA
|
stateA
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
@@ -120,14 +118,14 @@ stateDiagram-v2
|
|||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"look": "handdrawn"} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
flowchart LR
|
flowchart LR
|
||||||
id1([This is the text in the box])
|
id1[[This is the text in the box]]
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
|
|
||||||
export const circle = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
export const circle = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||||
parent,
|
parent,
|
||||||
node,
|
node,
|
||||||
'node ' + node.cssClasses,
|
getNodeClasses(node),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -22,17 +18,9 @@ export const circle = async (parent: SVGAElement, node: Node): Promise<SVGAEleme
|
|||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('Circle: Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.9,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure',
|
|
||||||
fillWeight: 1.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
strokeWidth: 1,
|
|
||||||
});
|
|
||||||
const roughNode = rc.circle(0, 0, radius * 2, options);
|
const roughNode = rc.circle(0, 0, radius * 2, options);
|
||||||
|
|
||||||
circleElem = shapeSvg.insert(() => roughNode, ':first-child');
|
circleElem = shapeSvg.insert(() => roughNode, ':first-child');
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
@@ -33,17 +32,35 @@ export const createCylinderPathD = (
|
|||||||
`l0,${-height}`,
|
`l0,${-height}`,
|
||||||
].join(' ');
|
].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) => {
|
export const cylinder = async (parent: SVGAElement, node: Node) => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
|
||||||
parent,
|
|
||||||
node,
|
|
||||||
'node ' + node.cssClasses, // + ' ' + node.class,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const rx = w / 2;
|
const rx = w / 2;
|
||||||
@@ -54,21 +71,15 @@ export const cylinder = async (parent: SVGAElement, node: Node) => {
|
|||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('Cylinder: Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const outerPathData = createOuterCylinderPathD(0, 0, w, h, rx, ry);
|
||||||
roughness: 0.7,
|
const innerPathData = createInnerCylinderPathD(0, ry, w, h, rx, ry);
|
||||||
fill: mainBkg,
|
const outerNode = rc.path(outerPathData, userNodeOverrides(node, {}));
|
||||||
fillStyle: 'hachure',
|
const innerLine = rc.path(innerPathData, userNodeOverrides(node, { fill: 'none' }));
|
||||||
fillWeight: 1.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
strokeWidth: 1,
|
|
||||||
});
|
|
||||||
const pathData = createCylinderPathD(0, 0, w, h, rx, ry);
|
|
||||||
const roughNode = rc.path(pathData, options);
|
|
||||||
|
|
||||||
cylinder = shapeSvg.insert(() => roughNode, ':first-child');
|
cylinder = shapeSvg.insert(() => innerLine, ':first-child');
|
||||||
|
cylinder = shapeSvg.insert(() => outerNode, ':first-child');
|
||||||
cylinder.attr('class', 'basic label-container');
|
cylinder.attr('class', 'basic label-container');
|
||||||
if (cssStyles) {
|
if (cssStyles) {
|
||||||
cylinder.attr('style', cssStyles);
|
cylinder.attr('style', cssStyles);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
@@ -8,8 +8,8 @@ import rough from 'roughjs';
|
|||||||
//import d3 from 'd3';
|
//import d3 from 'd3';
|
||||||
|
|
||||||
export const doublecircle = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
export const doublecircle = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { themeVariables } = getConfig();
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
const { mainBkg } = themeVariables;
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||||
parent,
|
parent,
|
||||||
@@ -25,17 +25,9 @@ export const doublecircle = async (parent: SVGAElement, node: Node): Promise<SVG
|
|||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('DoubleCircle: Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const outerOptions = userNodeOverrides(node, {
|
const outerOptions = userNodeOverrides(node, {});
|
||||||
roughness: 0.9,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure',
|
|
||||||
fillWeight: 1.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
strokeWidth: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
const innerOptions = { ...outerOptions, fill: mainBkg };
|
const innerOptions = { ...outerOptions, fill: mainBkg };
|
||||||
const outerRoughNode = rc.circle(0, 0, outerRadius * 2, outerOptions);
|
const outerRoughNode = rc.circle(0, 0, outerRadius * 2, outerOptions);
|
||||||
@@ -43,8 +35,6 @@ export const doublecircle = async (parent: SVGAElement, node: Node): Promise<SVG
|
|||||||
|
|
||||||
circleGroup = shapeSvg.insert('g', ':first-child');
|
circleGroup = shapeSvg.insert('g', ':first-child');
|
||||||
circleGroup.attr('class', node.cssClasses).attr('style', cssStyles);
|
circleGroup.attr('class', node.cssClasses).attr('style', cssStyles);
|
||||||
// d3.select(outerRoughNode).attr('class', 'outer-circle').attr('style', cssStyles);
|
|
||||||
// d3.select(innerRoughNode).attr('class', 'inner-circle').attr('style', cssStyles);
|
|
||||||
|
|
||||||
circleGroup.node()?.appendChild(outerRoughNode);
|
circleGroup.node()?.appendChild(outerRoughNode);
|
||||||
circleGroup.node()?.appendChild(innerRoughNode);
|
circleGroup.node()?.appendChild(innerRoughNode);
|
||||||
|
|||||||
@@ -1,64 +1,16 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
|
||||||
import { createRoundedRectPathD } from './roundedRectPath.js';
|
import { createRoundedRectPathD } from './roundedRectPath.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
|
|
||||||
// function applyNodePropertyBorders(
|
|
||||||
// rect: d3.Selection<SVGRectElement, unknown, null, undefined>,
|
|
||||||
// borders: string | undefined,
|
|
||||||
// totalWidth: number,
|
|
||||||
// totalHeight: number
|
|
||||||
// ) {
|
|
||||||
// if (!borders) {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// const strokeDashArray: number[] = [];
|
|
||||||
// const addBorder = (length: number) => {
|
|
||||||
// strokeDashArray.push(length, 0);
|
|
||||||
// };
|
|
||||||
// const skipBorder = (length: number) => {
|
|
||||||
// strokeDashArray.push(0, length);
|
|
||||||
// };
|
|
||||||
// if (borders.includes('t')) {
|
|
||||||
// log.debug('add top border');
|
|
||||||
// addBorder(totalWidth);
|
|
||||||
// } else {
|
|
||||||
// skipBorder(totalWidth);
|
|
||||||
// }
|
|
||||||
// if (borders.includes('r')) {
|
|
||||||
// log.debug('add right border');
|
|
||||||
// addBorder(totalHeight);
|
|
||||||
// } else {
|
|
||||||
// skipBorder(totalHeight);
|
|
||||||
// }
|
|
||||||
// if (borders.includes('b')) {
|
|
||||||
// log.debug('add bottom border');
|
|
||||||
// addBorder(totalWidth);
|
|
||||||
// } else {
|
|
||||||
// skipBorder(totalWidth);
|
|
||||||
// }
|
|
||||||
// if (borders.includes('l')) {
|
|
||||||
// log.debug('add left border');
|
|
||||||
// addBorder(totalHeight);
|
|
||||||
// } else {
|
|
||||||
// skipBorder(totalHeight);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// rect.attr('stroke-dasharray', strokeDashArray.join(' '));
|
|
||||||
// }
|
|
||||||
|
|
||||||
export const drawRect = async (parent: SVGAElement, node: Node, options: RectOptions) => {
|
export const drawRect = async (parent: SVGAElement, node: Node, options: RectOptions) => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||||
parent,
|
parent,
|
||||||
node,
|
node,
|
||||||
'node ' + node.cssClasses, // + ' ' + node.class,
|
getNodeClasses(node),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -79,15 +31,7 @@ export const drawRect = async (parent: SVGAElement, node: Node, options: RectOpt
|
|||||||
if (useRough) {
|
if (useRough) {
|
||||||
// @ts-ignore TODO: Fix rough typings
|
// @ts-ignore TODO: Fix rough typings
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.7,
|
|
||||||
fill: mainBkg,
|
|
||||||
// fillStyle: 'solid', // solid fill'
|
|
||||||
fillStyle: 'hachure', // solid fill'
|
|
||||||
fillWeight: 3.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('rect options: ', options);
|
console.log('rect options: ', options);
|
||||||
const roughNode =
|
const roughNode =
|
||||||
|
|||||||
@@ -18,8 +18,25 @@ export const solidStateFill = (color: string) => {
|
|||||||
// Striped fill like start or fork nodes in state diagrams
|
// Striped fill like start or fork nodes in state diagrams
|
||||||
// TODO remove any
|
// TODO remove any
|
||||||
export const userNodeOverrides = (node: Node, options: any) => {
|
export const userNodeOverrides = (node: Node, options: any) => {
|
||||||
const result = Object.assign({}, options);
|
const { themeVariables, handdrawnSeed } = getConfig();
|
||||||
result.fill = node.backgroundColor || options.fill;
|
const { nodeBorder, mainBkg } = themeVariables;
|
||||||
result.stroke = node.borderColor || options.stroke;
|
const result = Object.assign(
|
||||||
|
{
|
||||||
|
roughness: 0.7,
|
||||||
|
fill: mainBkg,
|
||||||
|
fillStyle: 'hachure', // solid fill
|
||||||
|
fillWeight: 3.5,
|
||||||
|
stroke: nodeBorder,
|
||||||
|
seed: handdrawnSeed,
|
||||||
|
strokeWidth: 1,
|
||||||
|
},
|
||||||
|
options
|
||||||
|
);
|
||||||
|
if (node.backgroundColor) {
|
||||||
|
result.fill = node.backgroundColor;
|
||||||
|
}
|
||||||
|
if (node.borderColor) {
|
||||||
|
result.stroke = node.borderColor;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
@@ -36,13 +35,10 @@ export const createHexagonPathD = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const hexagon = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
export const hexagon = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||||
parent,
|
parent,
|
||||||
node,
|
node,
|
||||||
'node ' + node.cssClasses,
|
getNodeClasses(node),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -63,17 +59,9 @@ export const hexagon = async (parent: SVGAElement, node: Node): Promise<SVGAElem
|
|||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('Hexagon: Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.7,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure',
|
|
||||||
fillWeight: 1.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
strokeWidth: 1,
|
|
||||||
});
|
|
||||||
const pathData = createHexagonPathD(0, 0, w, h, m);
|
const pathData = createHexagonPathD(0, 0, w, h, m);
|
||||||
const roughNode = rc.path(pathData, options);
|
const roughNode = rc.path(pathData, options);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
@@ -31,15 +31,7 @@ export const createInvertedTrapezoidPathD = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const inv_trapezoid = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
export const inv_trapezoid = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
|
||||||
parent,
|
|
||||||
node,
|
|
||||||
'node ' + node.cssClasses,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@@ -54,17 +46,9 @@ export const inv_trapezoid = async (parent: SVGAElement, node: Node): Promise<SV
|
|||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('Inverted Trapezoid: Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.7,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure',
|
|
||||||
fillWeight: 1.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
strokeWidth: 1,
|
|
||||||
});
|
|
||||||
const pathData = createInvertedTrapezoidPathD(0, 0, w, h);
|
const pathData = createInvertedTrapezoidPathD(0, 0, w, h);
|
||||||
const roughNode = rc.path(pathData, options);
|
const roughNode = rc.path(pathData, options);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
@@ -31,15 +30,7 @@ export const createLeanLeftPathD = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const lean_left = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
export const lean_left = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
|
||||||
parent,
|
|
||||||
node,
|
|
||||||
'node ' + node.cssClasses,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@@ -54,17 +45,9 @@ export const lean_left = async (parent: SVGAElement, node: Node): Promise<SVGAEl
|
|||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('Lean Left: Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.7,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure',
|
|
||||||
fillWeight: 1.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
strokeWidth: 1,
|
|
||||||
});
|
|
||||||
const pathData = createLeanLeftPathD(0, 0, w, h);
|
const pathData = createLeanLeftPathD(0, 0, w, h);
|
||||||
const roughNode = rc.path(pathData, options);
|
const roughNode = rc.path(pathData, options);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
@@ -31,15 +30,7 @@ export const createLeanRightPathD = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const lean_right = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
export const lean_right = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
|
||||||
parent,
|
|
||||||
node,
|
|
||||||
'node ' + node.cssClasses,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@@ -54,17 +45,9 @@ export const lean_right = async (parent: SVGAElement, node: Node): Promise<SVGAE
|
|||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('Lean Right: Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.7,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure',
|
|
||||||
fillWeight: 1.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
strokeWidth: 1,
|
|
||||||
});
|
|
||||||
const pathData = createLeanRightPathD(0, 0, w, h);
|
const pathData = createLeanRightPathD(0, 0, w, h);
|
||||||
const roughNode = rc.path(pathData, options);
|
const roughNode = rc.path(pathData, options);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
@@ -25,15 +24,7 @@ export const createDecisionBoxPathD = (x: number, y: number, size: number): stri
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const question = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
export const question = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
|
||||||
parent,
|
|
||||||
node,
|
|
||||||
'node ' + node.cssClasses,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@@ -50,17 +41,9 @@ export const question = async (parent: SVGAElement, node: Node): Promise<SVGAEle
|
|||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('DecisionBox: Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.7,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure',
|
|
||||||
fillWeight: 1.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
strokeWidth: 1,
|
|
||||||
});
|
|
||||||
const pathData = createDecisionBoxPathD(0, 0, s);
|
const pathData = createDecisionBoxPathD(0, 0, s);
|
||||||
const roughNode = rc.path(pathData, options);
|
const roughNode = rc.path(pathData, options);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
@@ -30,15 +29,7 @@ export const rect_left_inv_arrow = async (
|
|||||||
parent: SVGAElement,
|
parent: SVGAElement,
|
||||||
node: Node
|
node: Node
|
||||||
): Promise<SVGAElement> => {
|
): Promise<SVGAElement> => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
|
||||||
parent,
|
|
||||||
node,
|
|
||||||
'node ' + node.cssClasses,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@@ -54,17 +45,9 @@ export const rect_left_inv_arrow = async (
|
|||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('Polygon: Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.7,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure',
|
|
||||||
fillWeight: 1.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
strokeWidth: 1,
|
|
||||||
});
|
|
||||||
const pathData = createPolygonPathD(0, 0, w, h);
|
const pathData = createPolygonPathD(0, 0, w, h);
|
||||||
const roughNode = rc.path(pathData, options);
|
const roughNode = rc.path(pathData, options);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
@@ -53,15 +52,7 @@ export const createStadiumPathD = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const stadium = async (parent: SVGAElement, node: Node) => {
|
export const stadium = async (parent: SVGAElement, node: Node) => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
|
||||||
parent,
|
|
||||||
node,
|
|
||||||
'node ' + node.cssClasses, // + ' ' + node.class,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
const w = bbox.width + h / 4 + node.padding;
|
const w = bbox.width + h / 4 + node.padding;
|
||||||
@@ -69,20 +60,11 @@ export const stadium = async (parent: SVGAElement, node: Node) => {
|
|||||||
let rect;
|
let rect;
|
||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('Stadium:Inside use useRough');
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.7,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure', // solid fill
|
|
||||||
fillWeight: 3.5,
|
|
||||||
stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
// strokeWidth: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log('Stadium options: ', options);
|
const pathData = createRoundedRectPathD(-w / 2, -h / 2, w, h, h / 2);
|
||||||
const pathData = createRoundedRectPathD(-w / 2, -h / 2, w, h, h / 3);
|
|
||||||
const roughNode = rc.path(pathData, options);
|
const roughNode = rc.path(pathData, options);
|
||||||
|
|
||||||
rect = shapeSvg.insert(() => roughNode, ':first-child');
|
rect = shapeSvg.insert(() => roughNode, ':first-child');
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
@@ -34,39 +33,14 @@ export const createSubroutinePathD = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const subroutine = async (parent: SVGAElement, node: Node) => {
|
export const subroutine = async (parent: SVGAElement, node: Node) => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
const halfPadding = (node?.padding || 0) / 2;
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
|
||||||
parent,
|
|
||||||
node,
|
|
||||||
'node ' + node.cssClasses, // + ' ' + node.class,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
|
const x = -bbox.width / 2 - halfPadding;
|
||||||
|
const y = -bbox.height / 2 - halfPadding;
|
||||||
let rect;
|
let rect;
|
||||||
const { cssStyles, useRough } = node;
|
const { cssStyles, useRough } = node;
|
||||||
if (useRough) {
|
|
||||||
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 = createSubroutinePathD(-w / 2, -h / 2, w, h);
|
|
||||||
const roughNode = rc.path(pathData, options);
|
|
||||||
|
|
||||||
rect = shapeSvg.insert(() => roughNode, ':first-child');
|
|
||||||
rect.attr('class', 'basic label-container').attr('style', cssStyles);
|
|
||||||
}
|
|
||||||
|
|
||||||
const points = [
|
const points = [
|
||||||
{ x: 0, y: 0 },
|
{ x: 0, y: 0 },
|
||||||
{ x: w, y: 0 },
|
{ x: w, y: 0 },
|
||||||
@@ -80,12 +54,28 @@ export const subroutine = async (parent: SVGAElement, node: Node) => {
|
|||||||
{ x: -8, y: 0 },
|
{ x: -8, y: 0 },
|
||||||
];
|
];
|
||||||
|
|
||||||
const el = insertPolygonShape(shapeSvg, w, h, points);
|
if (useRough) {
|
||||||
if (cssStyles) {
|
// @ts-ignore
|
||||||
el.attr('style', cssStyles);
|
const rc = rough.svg(shapeSvg);
|
||||||
}
|
const options = userNodeOverrides(node, {});
|
||||||
|
const pathData = createSubroutinePathD(-w / 2, -h / 2, w, h);
|
||||||
|
|
||||||
updateNodeBounds(node, el);
|
const roughNode = rc.rectangle(x - 8, y, w + 16, h, options);
|
||||||
|
const l1 = rc.line(x, y, x, y + h, options);
|
||||||
|
const l2 = rc.line(x + w, y, x + w, y + h, options);
|
||||||
|
|
||||||
|
shapeSvg.insert(() => l1, ':first-child');
|
||||||
|
shapeSvg.insert(() => l2, ':first-child');
|
||||||
|
rect = shapeSvg.insert(() => roughNode, ':first-child');
|
||||||
|
|
||||||
|
rect.attr('class', 'basic label-container').attr('style', cssStyles);
|
||||||
|
} else {
|
||||||
|
const el = insertPolygonShape(shapeSvg, w, h, points);
|
||||||
|
if (cssStyles) {
|
||||||
|
el.attr('style', cssStyles);
|
||||||
|
}
|
||||||
|
updateNodeBounds(node, el);
|
||||||
|
}
|
||||||
|
|
||||||
node.intersect = function (point) {
|
node.intersect = function (point) {
|
||||||
return intersect.polygon(node, points, point);
|
return intersect.polygon(node, points, point);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { log } from '$root/logger.js';
|
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 intersect from '../intersect/index.js';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
|
||||||
import type { Node } from '$root/rendering-util/types.d.ts';
|
import type { Node } from '$root/rendering-util/types.d.ts';
|
||||||
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
import { userNodeOverrides } from '$root/rendering-util/rendering-elements/shapes/handdrawnStyles.js';
|
||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
@@ -31,15 +30,7 @@ export const createTrapezoidPathD = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const trapezoid = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
export const trapezoid = async (parent: SVGAElement, node: Node): Promise<SVGAElement> => {
|
||||||
const { themeVariables, handdrawnSeed } = getConfig();
|
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node), true);
|
||||||
const { nodeBorder, mainBkg } = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
|
||||||
parent,
|
|
||||||
node,
|
|
||||||
'node ' + node.cssClasses,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
const w = bbox.width + node.padding;
|
const w = bbox.width + node.padding;
|
||||||
const h = bbox.height + node.padding;
|
const h = bbox.height + node.padding;
|
||||||
@@ -55,16 +46,9 @@ export const trapezoid = async (parent: SVGAElement, node: Node): Promise<SVGAEl
|
|||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
console.log('Trapezoid: Inside use useRough');
|
console.log('Trapezoid: Inside use useRough');
|
||||||
|
// @ts-ignore
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const options = userNodeOverrides(node, {
|
const options = userNodeOverrides(node, {});
|
||||||
roughness: 0.7,
|
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'hachure',
|
|
||||||
fillWeight: 1.5,
|
|
||||||
//stroke: nodeBorder,
|
|
||||||
seed: handdrawnSeed,
|
|
||||||
//strokeWidth: 1,
|
|
||||||
});
|
|
||||||
const pathData = createTrapezoidPathD(0, 0, w, h);
|
const pathData = createTrapezoidPathD(0, 0, w, h);
|
||||||
const roughNode = rc.path(pathData, options);
|
const roughNode = rc.path(pathData, options);
|
||||||
|
|
||||||
|
|||||||
@@ -139,3 +139,6 @@ export function insertPolygonShape(parent, w, h, points) {
|
|||||||
.attr('class', 'label-container')
|
.attr('class', 'label-container')
|
||||||
.attr('transform', 'translate(' + -w / 2 + ',' + h / 2 + ')');
|
.attr('transform', 'translate(' + -w / 2 + ',' + h / 2 + ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getNodeClasses = (node, extra) =>
|
||||||
|
(node.useRough ? 'rough-node' : 'node') + ' ' + node.cssClasses + ' ' + (extra || '');
|
||||||
|
|||||||
Reference in New Issue
Block a user