diff options
author | sanine-a <sanine.not@pm.me> | 2020-12-19 01:16:29 -0600 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2020-12-19 01:16:29 -0600 |
commit | 34603bb6d538ab1b0edbe10feeef27b80b1b7f7a (patch) | |
tree | 44c53074c732ce69f479d40eceb865fb6843b885 | |
parent | 86e562d59eb26f305cb183d29b82123f944dd328 (diff) |
add curveTo function
-rw-r--r-- | demo/main.lua | 5 | ||||
-rw-r--r-- | src/cairo_bindings.c | 19 | ||||
-rw-r--r-- | src/cairo_bindings.h | 2 |
3 files changed, 24 insertions, 2 deletions
diff --git a/demo/main.lua b/demo/main.lua index 2ab1441..0482e04 100644 --- a/demo/main.lua +++ b/demo/main.lua @@ -23,11 +23,14 @@ local cairo = honey.cairo() cairo:setLinecap('butt') cairo:setLineWidth(50) cairo:setColor(0,0,0) -cairo:arc(512, 512, 256) cairo:moveTo(256,256) cairo:lineTo(1024-256,1024-256) cairo:stroke() +cairo:setColor(1,1,1,0.5) +cairo:arc(512,512,256,0, 2*math.pi) +cairo:fill() + cairo:updateTexture() local sceneRoot = Node.new() diff --git a/src/cairo_bindings.c b/src/cairo_bindings.c index 3b7bacb..3a4893b 100644 --- a/src/cairo_bindings.c +++ b/src/cairo_bindings.c @@ -9,7 +9,7 @@ int honey_setup_cairo(lua_State* L) { honey_lua_create_table (L, 2, - HONEY_TABLE, "__index", 17, + HONEY_TABLE, "__index", 18, HONEY_FUNCTION, "getTexture", honey_cairo_get_texture, HONEY_FUNCTION, "updateTexture", honey_cairo_update_texture, @@ -28,6 +28,7 @@ int honey_setup_cairo(lua_State* L) /* drawing functions */ HONEY_FUNCTION, "moveTo", honey_cairo_move_to, HONEY_FUNCTION, "lineTo", honey_cairo_line_to, + HONEY_FUNCTION, "curveTo", honey_cairo_curve_to, HONEY_FUNCTION, "arc", honey_cairo_arc, HONEY_FUNCTION, "stroke", honey_cairo_stroke, HONEY_FUNCTION, "fill", honey_cairo_fill, @@ -431,6 +432,22 @@ int honey_cairo_line_to(lua_State* L) /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +int honey_cairo_curve_to(lua_State* L) +{ + cairo_t** cr; + float x1, y1, x2, y2, x3, y3; + honey_lua_parse_arguments + (L, 1, 7, HONEY_USERDATA, &cr, + HONEY_NUMBER, x1, HONEY_NUMBER, y1, + HONEY_NUMBER, x2, HONEY_NUMBER, y2, + HONEY_NUMBER, x3, HONEY_NUMBER, y3); + + cairo_curve_to(*cr, x1, y1, x2, y2, x3, y3); + return 0; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + int honey_cairo_arc(lua_State* L) { cairo_t** cr; diff --git a/src/cairo_bindings.h b/src/cairo_bindings.h index b2eaa69..8f23bb6 100644 --- a/src/cairo_bindings.h +++ b/src/cairo_bindings.h @@ -48,6 +48,8 @@ int honey_cairo_move_to(lua_State* L); int honey_cairo_line_to(lua_State* L); +int honey_cairo_curve_to(lua_State* L); + int honey_cairo_arc(lua_State* L); int honey_cairo_stroke(lua_State* L); |