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
|
#include <lua.h>
#include <lauxlib.h>
#include <nanovg.h>
#include <nanovg_gl.h>
#include "nvg.h"
int nvgResetTransform_bind(lua_State *L)
{
NVGcontext **ctx = lua_checkudata(L, 1, nvg_ctx_tname);
nvgResetTransform(*ctx);
return 0;
}
int nvgTransform_bind(lua_State *L)
{
NVGcontext **ctx = lua_checkudata(L, 1, nvg_ctx_tname);
float a = luaL_checknumber(L, 2);
float b = luaL_checknumber(L, 3);
float c = luaL_checknumber(L, 4);
float d = luaL_checknumber(L, 5);
float e = luaL_checknumber(L, 6);
float f = luaL_checknumber(L, 7);
nvgTransform(ctx, a, b, c, d, e, f);
return 0;
}
int nvgTranslate_bind(lua_State *L)
{
NVGcontext **ctx = lua_checkudata(L, 1, nvg_ctx_tname);
float x = luaL_checknumber(L, 2);
float y = luaL_checknumber(L, 3);
nvgTranslate(*ctx, x, y);
return 0;
}
int nvgRotate_bind(lua_State *L)
{
NVGcontext **ctx = lua_checkudata(L, 1, nvg_ctx_tname);
float angle = luaL_checknumber(L, 2);
nvgRotate(*ctx, angle);
return 0;
}
int nvgSkewX_bind(lua_State *L)
{
NVGcontext **ctx = lua_checkudata(L, 1, nvg_ctx_tname);
float angle = luaL_checknumber(L, 2);
nvgSkewX(*ctx, angle);
return 0;
}
int nvgSkewY_bind(lua_State *L)
{
NVGcontext **ctx = lua_checkudata(L, 1, nvg_ctx_tname);
float angle = luaL_checknumber(L, 2);
nvgSkewY(*ctx, angle);
return 0;
}
int nvgScale_bind(lua_State *L)
{
NVGcontext **ctx = lua_checkudata(L, 1, nvg_ctx_tname);
float x = luaL_checknumber(L, 2);
float y = luaL_checknumber(L, 3);
nvgScale(*ctx, x, y);
return 0;
}
int nvgCurrentTransform_bind(lua_State *L)
{
NVGcontext **ctx = luaL_checkudate(L, 1, nvg_ctx_tname);
float xform[6];
nvgCurrentTransform(*ctx, xform);
for (int i=0; i<6; i++) {
lua_pushnumber(L, xform[i]);
}
return 6;
}
|