-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_example_sequential.cpp
More file actions
55 lines (48 loc) · 2 KB
/
test_example_sequential.cpp
File metadata and controls
55 lines (48 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "svg_diagram.h"
#include <cmath>
#include <numbers>
#include <format>
#include <gtest/gtest.h>
using namespace std;
using namespace svg_diagram;
TEST(TestExample, Sequential) {
SVGDiagram diagram;
diagram.defaultNodeAttributes().setShape(SVGNode::SHAPE_POLYGON);
diagram.defaultNodeAttributes().setMargin(10, 20);
diagram.defaultEdgeAttributes().setMargin(4.0);
diagram.defaultEdgeAttributes().setArrowHead(SVGEdge::ARROW_EMPTY);
const auto labels = vector{
"Part the Veil of Snow",
"The Devil's Wall",
"Stranger in the Night",
"Night on Bald Mountain",
"Exile's Shadow",
"Songs and Dances of Death",
};
const auto strokeColors = vector{"darkgrey", "peru", "darkgoldenrod", "limegreen", "dodgerblue", "lightcoral"};
const auto fillColors = vector{"floralwhite", "lightsalmon", "papayawhip", "lightgreen", "deepskyblue", "lightpink"};
const auto textColors = vector{"black", "saddlebrown", "goldenrod", "olivedrab", "royalblue", "indianred", "indigo"};
for (int i = 0; i < 6; ++i) {
constexpr double X_SHIFT = 100.0;
constexpr double Y_SHIFT = 80.0;
const auto& node = diagram.addNode(format("node_{}", i));
node->setSides(5 + i);
node->setCenter(i * X_SHIFT, i * Y_SHIFT);
node->setLabel(labels[i]);
node->setColor(strokeColors[i]);
node->setFillColor(fillColors[i]);
node->setFontColor(textColors[i]);
node->setPenWidth(i + 1);
if (i < 5) {
const auto from = format("node_{}", i);
const auto to = format("node_{}", i + 1);
const auto& edge = diagram.addEdge(from, to);
edge->addConnectionPoint((i - 1.5) * X_SHIFT, (i + 0.75) * Y_SHIFT);
edge->setColor(strokeColors[i]);
edge->setPenWidth(1 + i * 0.25);
edge->setLabel(format("C{}->C{}", i + 1, i + 2));
edge->setFontColor(strokeColors[i]);
}
}
diagram.render("example_sequential.svg");
}