Files
mermaid/cypress/platform/knsv-pos.html
2024-09-16 15:38:05 +02:00

199 lines
8.0 KiB
HTML

<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet" />
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
<link
href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap"
rel="stylesheet"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&family=Kalam:wght@300;400;700&family=Rubik+Mono+One&display=swap"
rel="stylesheet"
/>
<link
href="https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&family=Rubik+Mono+One&display=swap"
rel="stylesheet"
/>
<style>
body {
/* background: rgb(221, 208, 208); */
/* background: #333; */
font-family: 'Arial';
/* font-size: 18px !important; */
}
h1 {
color: grey;
}
.mermaid2 {
display: none;
}
.mermaid svg {
/* font-size: 18px !important; */
/* background-color: #efefef;
background-image: radial-gradient(#fff 51%, transparent 91%),
radial-gradient(#fff 51%, transparent 91%);
background-size: 20px 20px;
background-position:
0 0,
10px 10px;
background-repeat: repeat; */
}
.malware {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 150px;
background: red;
color: black;
display: flex;
display: flex;
justify-content: center;
align-items: center;
font-family: monospace;
font-size: 72px;
}
/* tspan {
font-size: 6px !important;
} */
</style>
</head>
<body>
<pre id="diagram" class="mermaid"></pre>
<script type="module">
import mermaid from './mermaid.esm.mjs';
import layouts from './mermaid-layout-elk.esm.mjs';
mermaid.registerLayoutLoaders(layouts);
mermaid.parseError = function (err, hash) {
console.error('Mermaid error: ', err);
};
mermaid.initialize({
startOnLoad: false,
// look: 'handdrawn',
layout: 'fixed',
fontFamily: 'Kalam',
sequence: {
actorFontFamily: 'courier',
noteFontFamily: 'courier',
messageFontFamily: 'courier',
},
logLevel: 0,
});
mermaid.parseError = function (err, hash) {
console.error('In parse error:');
console.error(err);
};
let code = `
stateDiagram
S:S
T:T
U:U
state Z {
state X {
Y:Ypsilon
}
}
A
S --> T: angrepp
T --> U
T --> V
C
D
E
`;
code = `
flowchart
T --> V@{ shape: odd }@
`;
let positions = {
nodes: {
S: { x: 0, y: 0 },
T: { x: 100, y: 100, width: 100, height: 100 },
U: { x: 250, y: 260 },
V: { x: 300, y: 120 },
Z: { x: 300, y: 10, width: 160, height: 100 },
X: { x: 300, y: 20, width: 80, height: 60 },
Y: { x: 300, y: 30, width: 50, height: 20 },
A: { x: 300, y: 75, width: 20, height: 20 },
},
edges: {
edge0: {
points: [
{ x: 0, y: 0 },
{ x: 50, y: 0 },
{ x: 100, y: 100 },
],
},
edge1: {
// points: [
// { x: 100, y: 100 },
// { x: 200, y: 200 },
// ],
points: [
{ x: 100, y: 100 },
{ x: 150, y: 120 },
{ x: 190.19453144073486, y: 120 },
{ x: 190.19453144073486, y: 152.1556251525879 },
{ x: 250, y: 152.1556251525879 },
{ x: 250, y: 160 },
],
},
edge2: {
points: [
{ x: 100, y: 100 },
{ x: 175, y: 80 },
{ x: 200, y: 120 },
{ x: 300, y: 100 },
],
},
},
};
positions = JSON.parse(
'{"edges":{"edge0":{"points":[{"x":0,"y":20},{"x":37.5,"y":20},{"x":75,"y":20}]},"edge1":{"points":[{"x":75,"y":20},{"x":112.5,"y":20},{"x":150,"y":20}]},"edge2":{"points":[{"x":75,"y":20},{"x":150,"y":20},{"x":225,"y":20}]},"edge3":{"points":[{"x":225,"y":20},{"x":150,"y":20},{"x":75,"y":20}]},"edge4":{"points":[{"x":225,"y":20},{"x":262.5,"y":20},{"x":300,"y":20}]},"edge5":{"points":[{"x":300,"y":20},{"x":225,"y":20},{"x":150,"y":20}]},"L_T_U_0":{"end":"U","start":"T","points":[{"x":104.38350598538668,"y":35.05980396270752},{"x":104.38350598538668,"y":66.67100191116333},{"x":28.860682588672134,"y":66.67100191116333},{"x":28.860682588672134,"y":98.28219985961914}]},"L_T_V_1":{"end":"V","start":"T","points":[{"x":164.31731414794922,"y":25.08638346762546},{"x":219.38338541984558,"y":25.08638346762546},{"x":219.38338541984558,"y":66.82066899427501},{"x":274.44945669174194,"y":66.82066899427501}]},"L_A_AV_0":{"end":"AV","start":"A","points":[{"x":99.65645053250867,"y":142.4039154052734},{"x":99.65645053250867,"y":159.3222198486328},{"x":105.4496819748155,"y":159.3222198486328},{"x":105.4496819748155,"y":176.2405242919922}]},"L_A_n1_1":{"end":"n1","start":"A","points":[{"x":101.4458357684995,"y":97.09012603759766},{"x":101.4458357684995,"y":122.0281257629395},{"x":150.3651923903006,"y":122.0281257629395},{"x":150.3651923903006,"y":146.9661254882812}]},"L_T_V_0":{"points":[{"x":64.84303604535387,"y":9.04546070098877},{"x":64.84303604535387,"y":53.79048013687114},{"x":111.32122039794909,"y":53.79048013687114},{"x":111.32122039794909,"y":98.53549957275351}],"start":"T","end":"V"},"L_T_n4_1":{"points":[{"x":53.70423344777099,"y":9.04546070098877},{"x":53.70423344777099,"y":219.2719521522522},{"x":62.78969536879233,"y":219.2719521522522},{"x":62.78969536879233,"y":429.4984436035156}],"start":"T","end":"n4"}},"nodes":{"A":{"x":95.37615203857422,"y":117.4039154052734,"width":86.6796875,"height":50},"T":{"x":53.21803665161133,"y":-13.45453929901123,"width":66.11250305175781,"height":45},"U":{"x":1.983121395111084,"y":120.7822036743164,"width":67.22499990463257,"height":45.00000762939453},"V":{"x":110.82122039794922,"y":98.0354995727539,"width":0,"height":0},"AV":{"x":109.72998046875,"y":201.2405242919922,"width":78.1640625,"height":50},"n1":{"x":351.1719665527344,"y":308.9921875,"width":126.15625,"height":60},"n2":{"x":-117.0737686157227,"y":-76.22648620605469,"width":110,"height":60},"n3":{"x":-103.8790435791016,"y":382.8584594726562,"width":110,"height":60},"Crash":{"x":300,"y":20},"Still":{"x":75,"y":20},"Moving":{"x":225,"y":20},"Stilla":{"x":0,"y":40},"root_end":{"x":150,"y":20},"root_start":{"x":0,"y":20},"n4":{"x":63.437957763671875,"y":459.4984436035156,"height":60,"width":110}}}'
);
// console.log('positions:', positions);
const { svg } = await mermaid.render('the-id-of-the-svg', code, undefined, positions);
if (window?.calcIntersections2) {
const int = await calcIntersections2(
{ id: 'a', shape: 'rect', x: 100, y: 100, width: 100, height: 100 },
{ id: 'a', shape: 'rect', x: 300, y: 100, width: 100, height: 100 }
);
console.log('Intersections', int);
} else {
console.error('calcIntersections not found');
}
// console.log(JSON.stringify(positions));
const elem = document.querySelector('#diagram');
elem.innerHTML = svg;
</script>
</body>
</html>