gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot
diff options
context:
space:
mode:
authorfrancesco-ST <francesco.abbate@st.com>2010年07月15日 12:57:00 +0200
committerfrancesco-ST <francesco.abbate@st.com>2010年07月15日 12:57:00 +0200
commitf93eaab58d78528b56710dbdbcf0b0232d1f46ad (patch)
tree0f95ddfbd626276432e5951b2403b1f220b9669f /agg-plot
parentdaf0b9bafe32ec66a132bf6f6faabb821512c4b1 (diff)
downloadgsl-shell-f93eaab58d78528b56710dbdbcf0b0232d1f46ad.tar.gz
pre3d rgba light source rendering plus fixes
rgba8 lua object mathods clean up. Pre3d: added rgba light source rendering. Fixed a bug in plot-window.
Diffstat (limited to 'agg-plot')
-rw-r--r--agg-plot/lua-draw.cpp 62
-rw-r--r--agg-plot/plot-window.cpp 2
2 files changed, 61 insertions, 3 deletions
diff --git a/agg-plot/lua-draw.cpp b/agg-plot/lua-draw.cpp
index 58f63f6e..a26c49de 100644
--- a/agg-plot/lua-draw.cpp
+++ b/agg-plot/lua-draw.cpp
@@ -45,9 +45,14 @@ static int agg_text_set_point (lua_State *L);
static int agg_text_rotate (lua_State *L);
static int agg_rgba_free (lua_State *L);
-static int agg_rgba_set (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);
+#if 0
static int agg_rgba_invert (lua_State *L);
static int agg_rgba_dup (lua_State *L);
+static int agg_rgba_set (lua_State *L);
+#endif
static void path_cmd (my::path *p, int cmd, struct cmd_call_stack *stack);
@@ -77,9 +82,14 @@ static const struct luaL_Reg agg_path_methods[] = {
static const struct luaL_Reg rgba_methods[] = {
{"__gc", agg_rgba_free},
+ {"__add", agg_rgba_add },
+ {"__mul", agg_rgba_mul },
+ {"alpha", agg_rgba_set_alpha },
+#if 0
{"set", agg_rgba_set },
{"invert", agg_rgba_invert },
{"dup", agg_rgba_dup },
+#endif
{NULL, NULL}
};
@@ -327,6 +337,16 @@ agg_rgb_new (lua_State *L)
}
int
+agg_rgba_set_alpha (lua_State *L)
+{
+ agg::rgba8 *c = (agg::rgba8 *) gs_check_userdata (L, 1, GS_RGBA_COLOR);
+ double a = luaL_checknumber (L, 2);
+ c->a = agg::rgba8::base_mask * a;
+ return 0;
+}
+
+#if 0
+int
agg_rgba_set (lua_State *L)
{
agg::rgba8 *c = (agg::rgba8 *) gs_check_userdata (L, 1, GS_RGBA_COLOR);
@@ -362,7 +382,43 @@ int
agg_rgba_dup (lua_State *L)
{
agg::rgba8 *src = (agg::rgba8 *) gs_check_userdata (L, 1, GS_RGBA_COLOR);
- agg::rgba8 *dst = new(L, GS_RGBA_COLOR) agg::rgba8(*src);
+ new(L, GS_RGBA_COLOR) agg::rgba8(*src);
+ return 1;
+}
+#endif
+
+int
+agg_rgba_add (lua_State *L)
+{
+ agg::rgba8 *c1 = (agg::rgba8 *) gs_check_userdata (L, 1, GS_RGBA_COLOR);
+ agg::rgba8 *c2 = (agg::rgba8 *) gs_check_userdata (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 = (agg::rgba8 *) gs_check_userdata (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;
}
@@ -391,6 +447,8 @@ draw_register (lua_State *L)
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);
}
diff --git a/agg-plot/plot-window.cpp b/agg-plot/plot-window.cpp
index 8d747046..70fec188 100644
--- a/agg-plot/plot-window.cpp
+++ b/agg-plot/plot-window.cpp
@@ -195,7 +195,7 @@ plot_window_new (lua_State *L)
plot_window *win = new(L, GS_AGG_WINDOW) plot_window(color);
- win->id = mlua_window_ref(L, 1);
+ win->id = mlua_window_ref(L, lua_gettop (L));
pthread_attr_t attr[1];
pthread_t win_thread[1];
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月17日 19:46:01 +0000

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