This repository was archived by the owner on Nov 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cpp
More file actions
44 lines (38 loc) · 1.28 KB
/
test.cpp
File metadata and controls
44 lines (38 loc) · 1.28 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
#include <vector>
#include <tuple>
#include "geometry.h"
#include "simple_svg.hpp"
#include "voronoi.h"
int main()
{
const size_t POINT_RADIUS = 5;
std::vector<Point> points{
{460, 430},
{490, 450},
{450, 410},
// {100, 300},
{500, 420},
};
Voronoi graph(points);
//auto vpoints = result.getPoints();
//result.getLines();
svg::Dimensions dimensions(1200, 1200);
svg::Document doc("my_svg.svg", svg::Layout(dimensions, svg::Layout::BottomLeft));
for(const auto& pt: points) {
std::cerr << "(" << pt.x << ", " << pt.y << ")" << std::endl;
doc << svg::Circle(svg::Point(pt.x, pt.y), 5, svg::Fill(svg::Color::Black));
}
// Condensed notation, parenthesis isolate temporaries that are inserted into parents.
//doc << svg::LineChart(svg::Dimensions(1000, 1000));
for(const auto& edge: graph.getEdges()) {
const auto& pt0 = *edge->nodes[0];
const auto& pt1 = *edge->nodes[1];
std::cerr << "(" << pt0.x << ", " << pt0.y << ")"
<< " -- (" << pt1.x << ", " << pt1.y << ")" << std::endl;
doc << svg::Line(
svg::Point(pt0.x, pt0.y),
svg::Point(pt1.x, pt1.y),
svg::Stroke(2, svg::Color::Black));
}
doc.save();
}