mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
#5237 Updating configuration otions and adding handdrawnSeed
This commit is contained in:
parent
2f80c3a2c4
commit
ab077992f5
@ -9,6 +9,7 @@ elems
|
|||||||
gantt
|
gantt
|
||||||
gitgraph
|
gitgraph
|
||||||
gzipped
|
gzipped
|
||||||
|
handdrawn
|
||||||
knsv
|
knsv
|
||||||
Knut
|
Knut
|
||||||
marginx
|
marginx
|
||||||
|
@ -1 +1,2 @@
|
|||||||
|
handdrawnSeed
|
||||||
newbranch
|
newbranch
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
/* background: rgb(221, 208, 208); */
|
/* background: rgb(221, 208, 208); */
|
||||||
/* background: #333; */
|
background: #333;
|
||||||
font-family: 'Arial';
|
font-family: 'Arial';
|
||||||
/* font-size: 18px !important; */
|
/* font-size: 18px !important; */
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ stateDiagram-v2
|
|||||||
</pre
|
</pre
|
||||||
>
|
>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
%%{init: {"handdrawn": false} }%%
|
%%{init: {"look": "classic"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
TN3: The state with a note
|
TN3: The state with a note
|
||||||
note right of TN3
|
note right of TN3
|
||||||
@ -522,8 +522,9 @@ mindmap
|
|||||||
// useMaxWidth: false,
|
// useMaxWidth: false,
|
||||||
// });
|
// });
|
||||||
mermaid.initialize({
|
mermaid.initialize({
|
||||||
theme: 'base',
|
theme: 'dark',
|
||||||
handdrawn: true,
|
handdrawnSeed: 12,
|
||||||
|
look: 'handdrawn',
|
||||||
// layout: 'dagre',
|
// layout: 'dagre',
|
||||||
layout: 'elk',
|
layout: 'elk',
|
||||||
flowchart: { titleTopMargin: 10 },
|
flowchart: { titleTopMargin: 10 },
|
||||||
|
@ -114,7 +114,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
stateId
|
stateId
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
stateId
|
stateId
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
state "This is a state description" as s3
|
state "This is a state description" as s3
|
||||||
</pre>
|
</pre>
|
||||||
@ -175,7 +175,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
state "This is a state description" as s5
|
state "This is a state description" as s5
|
||||||
</pre>
|
</pre>
|
||||||
@ -205,7 +205,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
s22 : This is a state description
|
s22 : This is a state description
|
||||||
|
|
||||||
@ -221,7 +221,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
s24 : This is a state description
|
s24 : This is a state description
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
|
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
s41 --> s42
|
s41 --> s42
|
||||||
@ -276,7 +276,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
s61 --> s62
|
s61 --> s62
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
|
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
a3 --> a4: A transition
|
a3 --> a4: A transition
|
||||||
@ -334,7 +334,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
a7 --> a8: A transition
|
a7 --> a8: A transition
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
|
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> test
|
[*] --> test
|
||||||
@ -396,7 +396,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> test
|
[*] --> test
|
||||||
test --> [*]
|
test --> [*]
|
||||||
@ -444,7 +444,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
|
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> First
|
[*] --> First
|
||||||
@ -471,7 +471,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> First
|
[*] --> First
|
||||||
state First {
|
state First {
|
||||||
@ -540,13 +540,13 @@ stateDiagram-v2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
|
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> Level1
|
[*] --> Level1
|
||||||
@ -564,7 +564,7 @@ stateDiagram-v2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
@ -588,13 +588,13 @@ stateDiagram-v2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> Level1
|
[*] --> Level1
|
||||||
|
|
||||||
@ -611,7 +611,7 @@ stateDiagram-v2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -675,7 +675,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
|
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> B1
|
[*] --> B1
|
||||||
@ -721,7 +721,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> B1
|
[*] --> B1
|
||||||
B1 --> B2
|
B1 --> B2
|
||||||
@ -783,7 +783,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
|
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
state if_state <<choice>>
|
state if_state <<choice>>
|
||||||
@ -806,7 +806,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
state if_state <<choice>>
|
state if_state <<choice>>
|
||||||
[*] --> IsPositive
|
[*] --> IsPositive
|
||||||
@ -864,7 +864,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
state fork_state <<fork>>
|
state fork_state <<fork>>
|
||||||
[*] --> fork_state
|
[*] --> fork_state
|
||||||
@ -898,7 +898,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
state fork_state <<fork>>
|
state fork_state <<fork>>
|
||||||
[*] --> fork_state
|
[*] --> fork_state
|
||||||
@ -954,7 +954,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
TN3: The state with a note
|
TN3: The state with a note
|
||||||
note right of TN3
|
note right of TN3
|
||||||
@ -981,7 +981,7 @@ stateDiagram-v2
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
TN7: The state with a note
|
TN7: The state with a note
|
||||||
note right of TN7
|
note right of TN7
|
||||||
@ -1051,7 +1051,7 @@ state Active {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> Active
|
[*] --> Active
|
||||||
|
|
||||||
@ -1094,7 +1094,7 @@ state Active {
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
[*] --> Active
|
[*] --> Active
|
||||||
|
|
||||||
@ -1158,7 +1158,7 @@ direction LR
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram2" class="mermaid">
|
<pre id="diagram2" class="mermaid">
|
||||||
%%{init: {"handdrawn": true} }%%
|
%%{init: {"look": "handdrawn"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
direction LR
|
direction LR
|
||||||
[*] --> D1
|
[*] --> D1
|
||||||
@ -1188,7 +1188,7 @@ direction LR
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre id="diagram4" class="mermaid">
|
<pre id="diagram4" class="mermaid">
|
||||||
%%{init: {"handdrawn": true, "layout": "elk"} }%%
|
%%{init: {"look": "handdrawn", "layout": "elk"} }%%
|
||||||
stateDiagram-v2
|
stateDiagram-v2
|
||||||
direction LR
|
direction LR
|
||||||
[*] --> D1
|
[*] --> D1
|
||||||
@ -1248,11 +1248,11 @@ direction LR
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var coll = document.getElementsByClassName("collapsible");
|
let coll = document.getElementsByClassName("collapsible");
|
||||||
for (var i = 0; i < coll.length; i++) {
|
for (let i = 0; i < coll.length; i++) {
|
||||||
coll[i].addEventListener("click", function () {
|
coll[i].addEventListener("click", function () {
|
||||||
this.classList.toggle("active");
|
this.classList.toggle("active");
|
||||||
var content = this.nextElementSibling;
|
let content = this.nextElementSibling;
|
||||||
if (content.style.maxHeight) {
|
if (content.style.maxHeight) {
|
||||||
content.style.maxHeight = null;
|
content.style.maxHeight = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -852,7 +852,7 @@ export const getData = () => {
|
|||||||
extract(getRootDocV2());
|
extract(getRootDocV2());
|
||||||
const diagramStates = getStates();
|
const diagramStates = getStates();
|
||||||
|
|
||||||
const useRough = getConfig().handdrawn;
|
const useRough = getConfig().look === 'handdrawn';
|
||||||
dataFetcher(undefined, getRootDocV2(), diagramStates, nodes, edges, true, useRough);
|
dataFetcher(undefined, getRootDocV2(), diagramStates, nodes, edges, true, useRough);
|
||||||
|
|
||||||
return { nodes, edges, other: {} };
|
return { nodes, edges, other: {} };
|
||||||
|
@ -149,7 +149,7 @@ const noteGroup = (parent, node) => {
|
|||||||
const roundedWithTitle = (parent, node) => {
|
const roundedWithTitle = (parent, node) => {
|
||||||
const siteConfig = getConfig();
|
const siteConfig = getConfig();
|
||||||
|
|
||||||
const { themeVariables } = siteConfig;
|
const { themeVariables, handdrawnSeed } = siteConfig;
|
||||||
const { altBackground, compositeBackground, compositeTitleBackground, nodeBorder } =
|
const { altBackground, compositeBackground, compositeTitleBackground, nodeBorder } =
|
||||||
themeVariables;
|
themeVariables;
|
||||||
|
|
||||||
@ -206,14 +206,16 @@ const roundedWithTitle = (parent, node) => {
|
|||||||
fill: compositeTitleBackground,
|
fill: compositeTitleBackground,
|
||||||
fillStyle: 'solid',
|
fillStyle: 'solid',
|
||||||
stroke: nodeBorder,
|
stroke: nodeBorder,
|
||||||
|
seed: handdrawnSeed,
|
||||||
})
|
})
|
||||||
: rc.rectangle(x, y, width, height);
|
: rc.rectangle(x, y, width, height, { seed: handdrawnSeed });
|
||||||
|
|
||||||
rect = shapeSvg.insert(() => roughOuterNode, ':first-child');
|
rect = shapeSvg.insert(() => roughOuterNode, ':first-child');
|
||||||
const roughInnerNode = rc.rectangle(x, innerY, width, innerHeight, {
|
const roughInnerNode = rc.rectangle(x, innerY, width, innerHeight, {
|
||||||
fill: isAlt ? altBackground : compositeBackground,
|
fill: isAlt ? altBackground : compositeBackground,
|
||||||
fillStyle: isAlt ? 'hachure' : 'solid',
|
fillStyle: isAlt ? 'hachure' : 'solid',
|
||||||
stroke: nodeBorder,
|
stroke: nodeBorder,
|
||||||
|
seed: handdrawnSeed,
|
||||||
});
|
});
|
||||||
|
|
||||||
rect = shapeSvg.insert(() => roughOuterNode, ':first-child');
|
rect = shapeSvg.insert(() => roughOuterNode, ':first-child');
|
||||||
@ -259,6 +261,7 @@ const roundedWithTitle = (parent, node) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const divider = (parent, node) => {
|
const divider = (parent, node) => {
|
||||||
|
const { handdrawnSeed } = getConfig();
|
||||||
// Add outer g element
|
// Add outer g element
|
||||||
const shapeSvg = parent.insert('g').attr('class', node.classes).attr('id', node.id);
|
const shapeSvg = parent.insert('g').attr('class', node.classes).attr('id', node.id);
|
||||||
|
|
||||||
@ -278,6 +281,7 @@ const divider = (parent, node) => {
|
|||||||
fill: 'lightgrey',
|
fill: 'lightgrey',
|
||||||
roughness: 0.5,
|
roughness: 0.5,
|
||||||
strokeLineDash: [5],
|
strokeLineDash: [5],
|
||||||
|
seed: handdrawnSeed,
|
||||||
});
|
});
|
||||||
|
|
||||||
rect = shapeSvg.insert(() => roughNode);
|
rect = shapeSvg.insert(() => roughNode);
|
||||||
|
@ -386,6 +386,7 @@ const calcOffset = function (src, dest, parentLookupDb) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const insertEdge = function (elem, edge, clusterDb, diagramType, graph, id) {
|
export const insertEdge = function (elem, edge, clusterDb, diagramType, graph, id) {
|
||||||
|
const { handdrawnSeed } = getConfig();
|
||||||
console.log('abc88 InsertEdge - edge: ', edge);
|
console.log('abc88 InsertEdge - edge: ', edge);
|
||||||
let points = edge.points;
|
let points = edge.points;
|
||||||
let pointsHasChanged = false;
|
let pointsHasChanged = false;
|
||||||
@ -478,17 +479,9 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, graph, i
|
|||||||
|
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
const rc = rough.svg(elem);
|
const rc = rough.svg(elem);
|
||||||
const svgPathNode = rc.curve(pointArr, { roughness: 0.5, stroke: 'green' });
|
const svgPathNode = rc.curve(pointArr, { roughness: 0.5, seed: handdrawnSeed });
|
||||||
console.log('svgPathNode abc88', svgPathNode);
|
|
||||||
strokeClasses += ' transition';
|
strokeClasses += ' transition';
|
||||||
// const svgPath2 = elem
|
|
||||||
// .append('path')
|
|
||||||
// .attr('d', lineFunction(lineData))
|
|
||||||
// .attr('id', edge.id)
|
|
||||||
// .attr('class', ' ' + strokeClasses + (edge.classes ? ' ' + edge.classes : ''))
|
|
||||||
// .attr('style', edge.style);
|
|
||||||
|
|
||||||
console.log('svgPath2 abc88', strokeClasses + (edge.classes ? ' ' + edge.classes : ''));
|
|
||||||
svgPath = select(svgPathNode)
|
svgPath = select(svgPathNode)
|
||||||
.select('path')
|
.select('path')
|
||||||
.attr('id', edge.id)
|
.attr('id', edge.id)
|
||||||
|
@ -4,7 +4,7 @@ import { stateStart } from './shapes/stateStart.ts';
|
|||||||
import { stateEnd } from './shapes/stateEnd.ts';
|
import { stateEnd } from './shapes/stateEnd.ts';
|
||||||
import { forkJoin } from './shapes/forkJoin.ts';
|
import { forkJoin } from './shapes/forkJoin.ts';
|
||||||
import { choice } from './shapes/choice.ts';
|
import { choice } from './shapes/choice.ts';
|
||||||
import {note} from './shapes/note.ts';
|
import { note } from './shapes/note.ts';
|
||||||
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||||
|
|
||||||
const formatClass = (str) => {
|
const formatClass = (str) => {
|
||||||
@ -32,7 +32,6 @@ export const insertNode = async (elem, node, dir) => {
|
|||||||
|
|
||||||
// debugger;
|
// debugger;
|
||||||
// Add link when appropriate
|
// Add link when appropriate
|
||||||
console.log('node.link', node.link);
|
|
||||||
if (node.link) {
|
if (node.link) {
|
||||||
let target;
|
let target;
|
||||||
if (getConfig().securityLevel === 'sandbox') {
|
if (getConfig().securityLevel === 'sandbox') {
|
||||||
|
@ -3,6 +3,7 @@ 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 rough from 'roughjs';
|
||||||
import { solidStateFill } from './handdrawnStyles.js';
|
import { solidStateFill } from './handdrawnStyles.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')
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
|
import { getConfig } from '$root/diagram-api/diagramAPI.js';
|
||||||
|
|
||||||
// Striped fill like start or fork nodes in state diagrams
|
// Striped fill like start or fork nodes in state diagrams
|
||||||
export const solidStateFill = (color: string) => {
|
export const solidStateFill = (color: string) => {
|
||||||
|
const { handdrawnSeed } = getConfig();
|
||||||
return {
|
return {
|
||||||
fill: color,
|
fill: color,
|
||||||
// fillStyle: 'solid',
|
|
||||||
hachureAngle: 120, // angle of hachure,
|
hachureAngle: 120, // angle of hachure,
|
||||||
hachureGap: 4,
|
hachureGap: 4,
|
||||||
fillWeight: 2,
|
fillWeight: 2,
|
||||||
roughness: 0.7,
|
roughness: 0.7,
|
||||||
|
seed: handdrawnSeed,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -6,7 +6,7 @@ import type { Node } from '$root/rendering-util/types.d.ts';
|
|||||||
import rough from 'roughjs';
|
import rough from 'roughjs';
|
||||||
|
|
||||||
export const note = async (parent: SVGAElement, node: Node) => {
|
export const note = async (parent: SVGAElement, node: Node) => {
|
||||||
const { themeVariables } = getConfig();
|
const { themeVariables, handdrawnSeed } = getConfig();
|
||||||
const { noteBorderColor, noteBkgColor } = themeVariables;
|
const { noteBorderColor, noteBkgColor } = themeVariables;
|
||||||
|
|
||||||
const useHtmlLabels = node.useHtmlLabels;
|
const useHtmlLabels = node.useHtmlLabels;
|
||||||
@ -34,7 +34,9 @@ export const note = async (parent: SVGAElement, node: Node) => {
|
|||||||
const roughNode = rc.rectangle(x, y, totalWidth, totalHeight, {
|
const roughNode = rc.rectangle(x, y, totalWidth, totalHeight, {
|
||||||
roughness: 0.7,
|
roughness: 0.7,
|
||||||
fill: noteBkgColor,
|
fill: noteBkgColor,
|
||||||
fillStyle: 'solid', // solid fill'
|
fillWeight: 3,
|
||||||
|
seed: handdrawnSeed,
|
||||||
|
// fillStyle: 'solid', // solid fill'
|
||||||
stroke: noteBorderColor,
|
stroke: noteBorderColor,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -58,20 +58,8 @@ function applyNodePropertyBorders(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const rect = async (parent: SVGAElement, node: Node) => {
|
export const rect = async (parent: SVGAElement, node: Node) => {
|
||||||
const { themeVariables } = getConfig();
|
const { themeVariables, handdrawnSeed } = getConfig();
|
||||||
const {
|
const { nodeBorder, mainBkg } = themeVariables;
|
||||||
textColor,
|
|
||||||
clusterTextColor,
|
|
||||||
altBackground,
|
|
||||||
compositeBackground,
|
|
||||||
compositeTitleBackground,
|
|
||||||
compositeBorder,
|
|
||||||
noteBorderColor,
|
|
||||||
noteBkgColor,
|
|
||||||
nodeBorder,
|
|
||||||
mainBkg,
|
|
||||||
stateBorder,
|
|
||||||
} = themeVariables;
|
|
||||||
|
|
||||||
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
const { shapeSvg, bbox, halfPadding } = await labelHelper(
|
||||||
parent,
|
parent,
|
||||||
@ -89,15 +77,17 @@ export const rect = async (parent: SVGAElement, node: Node) => {
|
|||||||
const { rx, ry, style, useRough } = node;
|
const { rx, ry, style, useRough } = node;
|
||||||
if (useRough) {
|
if (useRough) {
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
|
const options = {
|
||||||
|
roughness: 0.7,
|
||||||
|
fill: mainBkg,
|
||||||
|
fillStyle: 'solid', // solid fill'
|
||||||
|
stroke: nodeBorder,
|
||||||
|
seed: handdrawnSeed,
|
||||||
|
};
|
||||||
const roughNode =
|
const roughNode =
|
||||||
rx || ry
|
rx || ry
|
||||||
? rc.path(createRoundedRectPathD(x, y, totalWidth, totalHeight, rx || 0), {
|
? rc.path(createRoundedRectPathD(x, y, totalWidth, totalHeight, rx || 0), options)
|
||||||
roughness: 0.7,
|
: rc.rectangle(x, y, totalWidth, totalHeight, options);
|
||||||
fill: mainBkg,
|
|
||||||
fillStyle: 'solid', // solid fill'
|
|
||||||
stroke: nodeBorder,
|
|
||||||
})
|
|
||||||
: rc.rectangle(x, y, totalWidth, totalHeight);
|
|
||||||
|
|
||||||
rect = shapeSvg.insert(() => roughNode, ':first-child');
|
rect = shapeSvg.insert(() => roughNode, ':first-child');
|
||||||
rect.attr('class', 'basic label-container').attr('style', style);
|
rect.attr('class', 'basic label-container').attr('style', style);
|
||||||
|
@ -25,7 +25,7 @@ export const stateEnd = (parent: SVG, node: Node) => {
|
|||||||
let innerCircle;
|
let innerCircle;
|
||||||
if (node.useRough) {
|
if (node.useRough) {
|
||||||
const rc = rough.svg(shapeSvg);
|
const rc = rough.svg(shapeSvg);
|
||||||
const roughNode = rc.circle(0, 0, 14, { roughness: 0.5 });
|
const roughNode = rc.circle(0, 0, 14, { ...solidStateFill('black'), roughness: 0.5 });
|
||||||
const roughInnerNode = rc.circle(0, 0, 5, { ...solidStateFill('black'), fillStyle: 'solid' });
|
const roughInnerNode = rc.circle(0, 0, 5, { ...solidStateFill('black'), fillStyle: 'solid' });
|
||||||
circle = shapeSvg.insert(() => roughNode);
|
circle = shapeSvg.insert(() => roughNode);
|
||||||
innerCircle = shapeSvg.insert(() => roughInnerNode);
|
innerCircle = shapeSvg.insert(() => roughInnerNode);
|
||||||
|
@ -71,11 +71,20 @@ properties:
|
|||||||
tsType: any
|
tsType: any
|
||||||
themeCSS:
|
themeCSS:
|
||||||
type: string
|
type: string
|
||||||
handdrawn:
|
look:
|
||||||
description: |
|
description: |
|
||||||
Defines whether or not to use the handdrawn effect in the diagram.
|
Defines which main look to use for the diagram.
|
||||||
type: boolean
|
type: string
|
||||||
default: false
|
enum:
|
||||||
|
- classic
|
||||||
|
- handdrawn
|
||||||
|
- slick
|
||||||
|
default: 'classic'
|
||||||
|
handdrawnSeed:
|
||||||
|
description: |
|
||||||
|
Defines the seed to be used when using handdrawn look. This is important for the automated tests as they will always find differentces without the seed. The default value is 0 which gives a random seed.
|
||||||
|
type: number
|
||||||
|
default: 0
|
||||||
layout:
|
layout:
|
||||||
description: |
|
description: |
|
||||||
Defines which layout algorithm to use for rendering the diagram.
|
Defines which layout algorithm to use for rendering the diagram.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user