fixed X11_softare_info changing
[ego.git] / src / lib / transform.c
blobc18c0b8315f7b000b44199ca64f13c2b33269be9
1 #include "class.h"
2 #include "transform.h"
3 #include <Evas.h>
5 static int
6 ltransform_get_matrix (lua_State *L)
8 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
9 Evas_Transform *trans = (Evas_Transform *) obj->data;
10 lua_newtable (L);
11 lua_newtable (L);
12 lua_pushnumber (L, trans->mxx); lua_rawseti (L, -2, 1);
13 lua_pushnumber (L, trans->mxy); lua_rawseti (L, -2, 2);
14 lua_pushnumber (L, trans->mxz); lua_rawseti (L, -2, 3);
15 lua_rawseti (L, -2, 1);
16 lua_newtable (L);
17 lua_pushnumber (L, trans->myx); lua_rawseti (L, -2, 1);
18 lua_pushnumber (L, trans->myy); lua_rawseti (L, -2, 2);
19 lua_pushnumber (L, trans->myz); lua_rawseti (L, -2, 3);
20 lua_rawseti (L, -2, 2);
21 lua_newtable (L);
22 lua_pushnumber (L, trans->mzx); lua_rawseti (L, -2, 1);
23 lua_pushnumber (L, trans->mzy); lua_rawseti (L, -2, 2);
24 lua_pushnumber (L, trans->mzz); lua_rawseti (L, -2, 3);
25 lua_rawseti (L, -2, 3);
26 return 1;
29 static int
30 ltransform_set_matrix (lua_State *L)
32 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
33 Evas_Transform *trans = (Evas_Transform *) obj->data;
34 lua_rawgeti (L, 2, 1);
35 lua_rawgeti (L, -1, 1); trans->mxx = luaL_checknumber (L, -1);
36 lua_rawgeti (L, -2, 2); trans->mxy = luaL_checknumber (L, -1);
37 lua_rawgeti (L, -3, 3); trans->mxz = luaL_checknumber (L, -1);
38 lua_pop (L, 4);
39 lua_rawgeti (L, 2, 2);
40 lua_rawgeti (L, -1, 1); trans->myx = luaL_checknumber (L, -1);
41 lua_rawgeti (L, -2, 2); trans->myy = luaL_checknumber (L, -1);
42 lua_rawgeti (L, -3, 3); trans->myz = luaL_checknumber (L, -1);
43 lua_pop (L, 4);
44 lua_rawgeti (L, 2, 2);
45 lua_rawgeti (L, -1, 1); trans->mzx = luaL_checknumber (L, -1);
46 lua_rawgeti (L, -2, 2); trans->mzy = luaL_checknumber (L, -1);
47 lua_rawgeti (L, -3, 3); trans->mzz = luaL_checknumber (L, -1);
48 lua_pop (L, 4);
49 return 0;
53 * transform function methods
56 static int
57 ltransform_fn_rotate (lua_State * L)
59 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
60 evas_transform_rotate (
61 luaL_checknumber (L, 2),
62 obj->data);
63 return 0;
66 static int
67 ltransform_fn_translate (lua_State * L)
69 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
70 evas_transform_translate (
71 luaL_checknumber (L, 2),
72 luaL_checknumber (L, 3),
73 obj->data);
74 return 0;
77 static int
78 ltransform_fn_scale (lua_State * L)
80 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
81 evas_transform_scale (
82 luaL_checknumber (L, 2),
83 luaL_checknumber (L, 3),
84 obj->data);
85 return 0;
88 static int
89 ltransform_fn_shear (lua_State * L)
91 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
92 evas_transform_shear (
93 luaL_checknumber (L, 2),
94 luaL_checknumber (L, 3),
95 obj->data);
96 return 0;
99 static int
100 ltransform_fn_compose (lua_State * L)
102 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
103 luaobj_Object *lef = (luaobj_Object *) lua_touserdata (L, 2);
104 evas_transform_compose (
105 lef->data,
106 obj->data);
107 return 0;
110 static int
111 ltransform_fn_identity (lua_State * L)
113 luaobj_Object *obj = (luaobj_Object *) lua_touserdata (L, 1);
114 evas_transform_identity_set (obj->data);
115 return 0;
118 const luaL_Reg lTransform_get [] = {
119 {"matrix", ltransform_get_matrix},
120 {NULL, NULL} // sentinel
123 const luaL_Reg lTransform_set [] = {
124 {"matrix", ltransform_set_matrix},
125 {NULL, NULL} // sentinel
128 const luaL_Reg lTransform_fn [] = {
129 {"rotate", ltransform_fn_rotate},
130 {"translate", ltransform_fn_translate},
131 {"scale", ltransform_fn_scale},
132 {"shear", ltransform_fn_shear},
133 {"compose", ltransform_fn_compose},
134 {"identity", ltransform_fn_identity},
135 {NULL, NULL} // sentinel
138 const luaL_Reg lTransform_nil [] = {
139 {NULL, NULL} // sentinel
142 const luaobj_Reg mTransform = {
143 lTransform_nil,
144 lTransform_get,
145 lTransform_set,
146 lTransform_fn
149 const luaobj_Reg *cTransform[] = {
150 &mClass,
151 &mTransform,
152 NULL // sentinel