author | francesco-ST <francesco.abbate@st.com> | 2010年07月15日 13:57:44 +0200 |
---|---|---|
committer | francesco-ST <francesco.abbate@st.com> | 2010年07月15日 13:57:44 +0200 |
commit | 426d707efc9845a1230a8f8fa984338719a151a7 (patch) | |
tree | 48a31d20eca434223347dd10bb9fba58df059bc0 /agg-plot | |
parent | f93eaab58d78528b56710dbdbcf0b0232d1f46ad (diff) | |
download | gsl-shell-426d707efc9845a1230a8f8fa984338719a151a7.tar.gz |
-rw-r--r-- | agg-plot/agg-parse-trans.cpp | 16 | ||||
-rw-r--r-- | agg-plot/agg-parse-trans.h | 8 | ||||
-rw-r--r-- | agg-plot/lua-draw.cpp | 54 | ||||
-rw-r--r-- | agg-plot/plot-window.cpp | 11 | ||||
-rw-r--r-- | agg-plot/trans.h | 20 |
diff --git a/agg-plot/agg-parse-trans.cpp b/agg-plot/agg-parse-trans.cpp index 85042409..30657622 100644 --- a/agg-plot/agg-parse-trans.cpp +++ b/agg-plot/agg-parse-trans.cpp @@ -20,6 +20,14 @@ struct builder_reg { vertex_source *(*func)(lua_State *, int, vertex_source *); }; +static vertex_source * build_stroke (lua_State *L, int i, vertex_source *s); +static vertex_source * build_curve (lua_State *L, int i, vertex_source *s); +static vertex_source * build_marker (lua_State *L, int i, vertex_source *s); +static vertex_source * build_dash (lua_State *L, int i, vertex_source *s); +static vertex_source * build_extend (lua_State *L, int i, vertex_source *s); +static vertex_source * build_translate (lua_State *L, int i, vertex_source *s); +static vertex_source * build_rotate (lua_State *L, int i, vertex_source *s); + struct property_reg line_cap_properties[] = { {(int) agg::butt_cap, "butt" }, {(int) agg::square_cap, "square"}, @@ -41,6 +49,7 @@ const builder_reg builder_table[] = { {"dash", build_dash}, {"curve", build_curve}, {"marker", build_marker}, + {"extend", build_extend}, {"translate", build_translate}, {"rotate", build_rotate}, {NULL, NULL} @@ -114,6 +123,13 @@ build_dash (lua_State *L, int specindex, vertex_source *obj) } vertex_source * +build_extend (lua_State *L, int specindex, vertex_source *obj) +{ + double width = mlua_named_optnumber (L, specindex, "width", 1.0); + return (vertex_source *) new trans::extend(obj, width); +} + +vertex_source * build_translate (lua_State *L, int specindex, vertex_source *obj) { double x = mlua_named_number (L, specindex, "x"); diff --git a/agg-plot/agg-parse-trans.h b/agg-plot/agg-parse-trans.h index 02dff4ac..87973582 100644 --- a/agg-plot/agg-parse-trans.h +++ b/agg-plot/agg-parse-trans.h @@ -13,12 +13,4 @@ extern vertex_source * parse_spec (lua_State *L, int specindex, extern vertex_source * parse_spec_pipeline (lua_State *L, int index, vertex_source *obj); - -extern vertex_source * build_stroke (lua_State *L, int i, vertex_source *s); -extern vertex_source * build_curve (lua_State *L, int i, vertex_source *s); -extern vertex_source * build_marker (lua_State *L, int i, vertex_source *s); -extern vertex_source * build_dash (lua_State *L, int i, vertex_source *s); -extern vertex_source * build_translate (lua_State *L, int i, vertex_source *s); -extern vertex_source * build_rotate (lua_State *L, int i, vertex_source *s); - #endif diff --git a/agg-plot/lua-draw.cpp b/agg-plot/lua-draw.cpp index a26c49de..48e9580f 100644 --- a/agg-plot/lua-draw.cpp +++ b/agg-plot/lua-draw.cpp @@ -48,11 +48,6 @@ static int agg_rgba_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); -#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); @@ -85,11 +80,6 @@ static const struct luaL_Reg rgba_methods[] = { {"__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} }; @@ -256,7 +246,7 @@ agg_text_new (lua_State *L) { double size = luaL_optnumber (L, 1, 10.0); double width = luaL_optnumber (L, 2, 1.0); - my::text *txt = new(L, GS_DRAW_TEXT) my::text(size, width); + new(L, GS_DRAW_TEXT) my::text(size, width); return 1; } @@ -345,48 +335,6 @@ agg_rgba_set_alpha (lua_State *L) return 0; } -#if 0 -int -agg_rgba_set (lua_State *L) -{ - agg::rgba8 *c = (agg::rgba8 *) gs_check_userdata (L, 1, GS_RGBA_COLOR); - double r, g, b, a; - - r = luaL_checknumber (L, 2); - g = luaL_checknumber (L, 3); - b = luaL_checknumber (L, 4); - if (lua_gettop (L) > 4) - a = luaL_checknumber (L, 5); - else - a = 1.0; - - c->r = r; - c->g = g; - c->b = b; - c->a = a; - - return 0; -} - -int -agg_rgba_invert (lua_State *L) -{ - agg::rgba8 *c = (agg::rgba8 *) gs_check_userdata (L, 1, GS_RGBA_COLOR); - c->r = 1 - c->r; - c->g = 1 - c->g; - c->b = 1 - c->b; - return 0; -} - -int -agg_rgba_dup (lua_State *L) -{ - agg::rgba8 *src = (agg::rgba8 *) gs_check_userdata (L, 1, GS_RGBA_COLOR); - new(L, GS_RGBA_COLOR) agg::rgba8(*src); - return 1; -} -#endif - int agg_rgba_add (lua_State *L) { diff --git a/agg-plot/plot-window.cpp b/agg-plot/plot-window.cpp index 70fec188..655bb5e7 100644 --- a/agg-plot/plot-window.cpp +++ b/agg-plot/plot-window.cpp @@ -88,7 +88,6 @@ public: delete m_canvas; }; - virtual void on_draw(); virtual void on_init(); virtual void on_resize(int sx, int sy); @@ -122,16 +121,6 @@ plot_window::on_init() } void -plot_window::on_draw() -{ - printf("on draw!\n"); - if (! m_canvas) - return; - - m_canvas->clear(); -}; - -void plot_window::on_resize(int sx, int sy) { if (m_canvas) diff --git a/agg-plot/trans.h b/agg-plot/trans.h index 0649ddaa..35dec2a7 100644 --- a/agg-plot/trans.h +++ b/agg-plot/trans.h @@ -6,6 +6,7 @@ #include "agg_conv_curve.h" #include "agg_conv_dash.h" #include "agg_conv_transform.h" +#include "agg_conv_contour.h" #include "agg_vcgen_markers_term.h" #include "agg_arrowhead.h" #include "agg_bounding_rect.h" @@ -59,6 +60,7 @@ typedef vs_trans_proxy<agg::conv_stroke<vertex_source> > vs_stroke; typedef vs_trans_proxy<agg::conv_curve<vertex_source> > vs_curve; typedef vs_trans_proxy<agg::conv_dash<vertex_source> > vs_dash; typedef vs_trans_proxy<agg::conv_transform<vertex_source> > vs_transform; +typedef vs_trans_proxy<agg::conv_contour<vertex_source> > vs_contour; namespace trans { @@ -127,6 +129,24 @@ namespace trans { m_source->apply_transform(m, as); }; }; + + class extend : public vs_contour { + public: + typedef agg::conv_contour<vertex_source> base_type; + + extend(vertex_source* src, double width): vs_contour(src) + { + base_type& v = self(); + v.width(width); + v.auto_detect_orientation(true); + }; + + virtual void apply_transform(agg::trans_affine& m, double as) + { + m_output.approximation_scale(as); + m_source->apply_transform(m, as); + }; + }; class resize : public vs_transform { agg::trans_affine m_matrix; |