-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDraw.cpp
More file actions
111 lines (80 loc) · 2.25 KB
/
Copy pathDraw.cpp
File metadata and controls
111 lines (80 loc) · 2.25 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include "../graphics.h"
#include "../utils.h"
#include "../template/args.h"
class LuaCell {
af_cell mCell;
public:
af_cell * GetCell (void) { return &mCell; }
LuaCell (lua_State * L)
{
lua_getfield(L, -1, "row"); // ..., row
lua_getfield(L, -2, "col"); // ..., row, col
lua_getfield(L, -3, "title"); // ..., row, col, title
lua_getfield(L, -4, "cmap");// ..., row, col, title, cmap
mCell.row = I(L, -4);
mCell.col = I(L, -3);
mCell.title = !lua_isnil(L, -1) ? lua_tostring(L, -2) : nullptr;
mCell.cmap = Arg<af_colormap>(L, -1);
lua_pop(L, 4); // ...
}
};
static const struct luaL_Reg draw_funcs[] = {
{
"af_draw_hist", [](lua_State * L)
{
lua_settop(L, 5); // window, arr, min, max, props
LuaCell cell(L);
af_err err = af_draw_hist(Arg<af_window>(L, 1), GetArray(L, 2), D(L, 3), D(L, 4), cell.GetCell());
lua_pushinteger(L, err);// window, arr, min, max, props, err
return 1;
}
}, {
"af_draw_image", [](lua_State * L)
{
lua_settop(L, 3); // window, arr, props
LuaCell cell(L);
af_err err = af_draw_image(Arg<af_window>(L, 1), GetArray(L, 2), cell.GetCell());
lua_pushinteger(L, err);// window, arr, props, err
return 1;
}
}, {
"af_draw_plot", [](lua_State * L)
{
lua_settop(L, 4); // window, x, y, props
LuaCell cell(L);
af_err err = af_draw_plot(Arg<af_window>(L, 1), GetArray(L, 2), GetArray(L, 3), cell.GetCell());
lua_pushinteger(L, err);// window, x, y, props, err
return 1;
}
},
#if AF_API_VERSION >= 32
{
"af_draw_plot3", [](lua_State * L)
{
lua_settop(L, 3); // window, P, props
LuaCell cell(L);
af_err err = af_draw_plot3(Arg<af_window>(L, 1), GetArray(L, 2), cell.GetCell());
lua_pushinteger(L, err);// window, x, y, props, err
return 1;
}
},
#endif
#if AF_API_VERSION > 32 || (AF_API_VERSION == 32 && AF_VERSION_PATCH >= 1)
{
"af_draw_surface", [](lua_State * L)
{
lua_settop(L, 5); // window, xvals, yvals, S, props
LuaCell cell(L);
af_err err = af_draw_surface(Arg<af_window>(L, 1), GetArray(L, 2), GetArray(L, 3), GetArray(L, 4), cell.GetCell());
lua_pushinteger(L, err);// window, x, y, props, err
return 1;
}
},
#endif
{ NULL, NULL }
};
int Draw (lua_State * L)
{
luaL_register(L, NULL, draw_funcs);
return 0;
}