blob: 0c810d2570981013916bf9fe02d1b00750a3313d (
plain)
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
|
#include <pgf/gd/interface/c/InterfaceFromC++.h>
#include <pgf/gd/interface/c/InterfaceFromC.h>
#include <math.h>
struct FastLayout : scripting::declarations, scripting::runner {
void run () {
pgfgd_SyntacticDigraph* graph = parameters->syntactic_digraph;
double angle = 6.28318530718 / graph->vertices.length;
double radius = parameters->option<double>("fast simple demo radius c++");
for (int i = 0; i < graph->vertices.length; i++) {
pgfgd_Vertex* v = graph->vertices.array[i];
v->pos.x = cos(angle*i) * radius;
v->pos.y = sin(angle*i) * radius;
}
}
void declare(scripting::script s) {
using namespace scripting;
s.declare(key ("fast simple demo layout c++")
.summary ("The C++ version of the hello world of graph drawing")
.precondition ("connected")
.precondition ("tree")
.algorithm (this));
s.declare(key ("fast simple demo radius c++")
.summary ("A radius value for the hello world of graph drawing")
.type ("length")
.initial ("1cm"));
}
};
extern "C" int luaopen_pgf_gd_examples_c_SimpleDemoCPlusPlus (struct lua_State *state) {
scripting::script s (state);
s.declare (new FastLayout);
return 0;
}
|