summaryrefslogtreecommitdiff
path: root/src/cairo_bindings.c
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2020-12-17 23:44:26 -0600
committersanine-a <sanine.not@pm.me>2020-12-17 23:44:26 -0600
commit1b7a7a0d83353c9d4e67387d864011b1556330eb (patch)
treea799ad0f7b84fb82ab2b512f318200b4d08291a5 /src/cairo_bindings.c
parentac16a4e0ae9fcc272cf5f8a9c1350f27817df7d0 (diff)
add setLineWidth and arc functions to cairo bindings
Diffstat (limited to 'src/cairo_bindings.c')
-rw-r--r--src/cairo_bindings.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/src/cairo_bindings.c b/src/cairo_bindings.c
index 1c4c57b..d72597c 100644
--- a/src/cairo_bindings.c
+++ b/src/cairo_bindings.c
@@ -9,13 +9,15 @@ int honey_setup_cairo(lua_State* L)
{
honey_lua_create_table
(L, 2,
- HONEY_TABLE, "__index", 6,
+ HONEY_TABLE, "__index", 8,
HONEY_FUNCTION, "getTexture", honey_cairo_get_texture,
HONEY_FUNCTION, "updateTexture", honey_cairo_update_texture,
HONEY_FUNCTION, "moveTo", honey_cairo_move_to,
HONEY_FUNCTION, "lineTo", honey_cairo_line_to,
+ HONEY_FUNCTION, "arc", honey_cairo_arc,
HONEY_FUNCTION, "stroke", honey_cairo_stroke,
HONEY_FUNCTION, "setColor", honey_cairo_set_color,
+ HONEY_FUNCTION, "setLineWidth", honey_cairo_set_line_width,
HONEY_FUNCTION, "__gc", honey_cairo_destroy);
honey_cairo_mt_ref = luaL_ref(L, LUA_REGISTRYINDEX);
@@ -188,6 +190,31 @@ int honey_cairo_line_to(lua_State* L)
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+int honey_cairo_arc(lua_State* L)
+{
+ cairo_t** cr;
+ float cx, cy, radius, angle1, angle2;
+ int choice = honey_lua_parse_arguments
+ (L, 2,
+ 4,
+ HONEY_USERDATA, &cr,
+ HONEY_NUMBER, &cx, HONEY_NUMBER, &cy, HONEY_NUMBER, &radius,
+ 6,
+ HONEY_USERDATA, &cr,
+ HONEY_NUMBER, &cx, HONEY_NUMBER, &cy, HONEY_NUMBER, &radius,
+ HONEY_NUMBER, &angle1, HONEY_NUMBER, &angle2);
+
+ if (choice == 0) {
+ angle1 = 0;
+ angle2 = 6.2831;
+ }
+
+ cairo_arc(*cr, cx, cy, radius, angle1, angle2);
+ return 0;
+}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
int honey_cairo_stroke(lua_State* L)
{
cairo_t** cr;
@@ -218,3 +245,16 @@ int honey_cairo_set_color(lua_State* L)
return 0;
}
+
+/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+
+int honey_cairo_set_line_width(lua_State* L)
+{
+ cairo_t** cr;
+ float width;
+ honey_lua_parse_arguments(L, 1, 2, HONEY_USERDATA, &cr, HONEY_NUMBER, &width);
+
+ cairo_set_line_width(*cr, width);
+ return 0;
+}
+