From 658ed523ec7f26aca179b294f0c5971d0c050c6e Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: 2012年2月15日 23:18:38 +0100 Subject: Modify the function to create text objects to take the coordinates --- agg-plot/lua-text.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'agg-plot/lua-text.cpp') diff --git a/agg-plot/lua-text.cpp b/agg-plot/lua-text.cpp index 04129c78..cb5dd7c4 100644 --- a/agg-plot/lua-text.cpp +++ b/agg-plot/lua-text.cpp @@ -25,6 +25,8 @@ static int agg_text_angle_get (lua_State *L); static draw::text* check_agg_text (lua_State *L, int index); +static const double text_line_width = 1.7; + static const struct luaL_Reg text_functions[] = { {"text", agg_text_new}, {NULL, NULL} @@ -63,10 +65,12 @@ check_agg_text (lua_State *L, int index) int agg_text_new (lua_State *L) { - const char *text = luaL_checkstring (L, 1); - double size = luaL_optnumber (L, 2, 10.0); - double width = luaL_optnumber (L, 3, 1.0) + 0.7; - new(L, GS_DRAW_TEXT) draw::text(text, size, width); + double x = luaL_checknumber (L, 1); + double y = luaL_checknumber (L, 2); + const char *text = luaL_checkstring (L, 3); + double size = luaL_optnumber (L, 4, 10.0); + draw::text* t = new(L, GS_DRAW_TEXT) draw::text(text, size, text_line_width); + t->set_point(x, y); return 1; } -- cgit v1.2.3

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