gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/lua-draw.cpp
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2011年11月06日 18:04:21 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2011年11月06日 18:04:21 +0100
commit65ceb0cae23f9ade2f5d7b51e94286e10b525852 (patch)
tree104af7f29cefac8c460e2d3df34c13f20eb2a85d /agg-plot/lua-draw.cpp
parent394be1a7f6b20470ff89ef1c2988146fcac6957c (diff)
downloadgsl-shell-65ceb0cae23f9ade2f5d7b51e94286e10b525852.tar.gz
Change rgba color implementation to use integer number encoding
Diffstat (limited to 'agg-plot/lua-draw.cpp')
-rw-r--r--agg-plot/lua-draw.cpp 104
1 files changed, 0 insertions, 104 deletions
diff --git a/agg-plot/lua-draw.cpp b/agg-plot/lua-draw.cpp
index 4b9d83ff..d533e745 100644
--- a/agg-plot/lua-draw.cpp
+++ b/agg-plot/lua-draw.cpp
@@ -62,11 +62,6 @@ static int agg_ellipse_new (lua_State *L);
static int agg_circle_new (lua_State *L);
static int agg_ellipse_free (lua_State *L);
-
-static int agg_rgba_add (lua_State *L);
-static int agg_rgba_mul (lua_State *L);
-static int agg_rgba_set_alpha (lua_State *L);
-
static void path_cmd (draw::path *p, int cmd, struct cmd_call_stack *stack);
static struct path_cmd_reg cmd_table[] = {
@@ -83,8 +78,6 @@ static const struct luaL_Reg draw_functions[] = {
{"path", agg_path_new},
{"ellipse", agg_ellipse_new},
{"circle", agg_circle_new},
- {"rgba", agg_rgba_new},
- {"rgb", agg_rgb_new},
{NULL, NULL}
};
@@ -100,14 +93,6 @@ static const struct luaL_Reg agg_ellipse_methods[] = {
{NULL, NULL}
};
-// no finalizer is needed because rgba does not allocate memory
-static const struct luaL_Reg rgba_methods[] = {
- {"__add", agg_rgba_add },
- {"__mul", agg_rgba_mul },
- {"alpha", agg_rgba_set_alpha },
- {NULL, NULL}
-};
-
int
agg_path_new (lua_State *L)
{
@@ -267,89 +252,6 @@ agg_ellipse_free (lua_State *L)
return object_free<draw::ellipse>(L, 1, GS_DRAW_ELLIPSE);
}
-static unsigned int double2uint8 (double x)
-{
- int u = x * 255.0;
- if (u > 255)
- u = 255;
- else if (u < 0)
- u = 0;
- return (unsigned int) u;
-}
-
-agg::rgba8 *
-check_agg_rgba8 (lua_State *L, int index)
-{
- return (agg::rgba8 *) gs_check_userdata (L, index, GS_RGBA_COLOR);
-}
-
-int
-agg_rgba_new (lua_State *L)
-{
- unsigned int r = double2uint8 (luaL_checknumber (L, 1));
- unsigned int g = double2uint8 (luaL_checknumber (L, 2));
- unsigned int b = double2uint8 (luaL_checknumber (L, 3));
- unsigned int a = double2uint8 (luaL_checknumber (L, 4));
-
- new(L, GS_RGBA_COLOR) agg::rgba8(r, g, b, a);
- return 1;
-}
-
-int
-agg_rgb_new (lua_State *L)
-{
- unsigned int r = double2uint8 (luaL_checknumber (L, 1));
- unsigned int g = double2uint8 (luaL_checknumber (L, 2));
- unsigned int b = double2uint8 (luaL_checknumber (L, 3));
-
- new(L, GS_RGBA_COLOR) agg::rgba8(r, g, b, 255);
- return 1;
-}
-
-int
-agg_rgba_set_alpha (lua_State *L)
-{
- agg::rgba8 *c = object_check<agg::rgba8> (L, 1, GS_RGBA_COLOR);
- double a = luaL_checknumber (L, 2);
- c->a = agg::rgba8::base_mask * a;
- return 0;
-}
-
-int
-agg_rgba_add (lua_State *L)
-{
- agg::rgba8 *c1 = object_check<agg::rgba8> (L, 1, GS_RGBA_COLOR);
- agg::rgba8 *c2 = object_check<agg::rgba8> (L, 2, GS_RGBA_COLOR);
-
- unsigned int r = c1->r + c2->r;
- unsigned int g = c1->g + c2->g;
- unsigned int b = c1->b + c2->b;
-
- new(L, GS_RGBA_COLOR) agg::rgba8(r, g, b);
-
- return 1;
-}
-
-int
-agg_rgba_mul (lua_State *L)
-{
- int is = 1, ic = 2;
-
- if (gs_is_userdata (L, 1, GS_RGBA_COLOR))
- {
- ic = 1;
- is = 2;
- }
-
- double f = luaL_checknumber (L, is);
- agg::rgba8 *c = object_check<agg::rgba8> (L, ic, GS_RGBA_COLOR);
-
- unsigned int r = f * c->r, g = f * c->g, b = f * c->b;
-
- new(L, GS_RGBA_COLOR) agg::rgba8(r, g, b);
- return 1;
-}
-
void
draw_register (lua_State *L)
{
@@ -363,12 +265,6 @@ draw_register (lua_State *L)
luaL_register (L, NULL, agg_ellipse_methods);
lua_pop (L, 1);
- luaL_newmetatable (L, GS_METATABLE(GS_RGBA_COLOR));
- lua_pushvalue (L, -1);
- lua_setfield (L, -2, "__index");
- luaL_register (L, NULL, rgba_methods);
- lua_pop (L, 1);
-
/* gsl module registration */
luaL_register (L, NULL, draw_functions);
}
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月14日 19:22:44 +0000

AltStyle によって変換されたページ (->オリジナル) /