[seed] cairo: More cairo.context, more enums, more breakfast
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed] cairo: More cairo.context, more enums, more breakfast
- Date: Thu, 14 May 2009 06:55:15 -0400 (EDT)
commit bdfba213a6cb4529fe30de772aeb7980240c3acf
Author: Robert Carr <racarr svn gnome org>
Date: Thu May 14 06:55:00 2009 -0400
cairo: More cairo.context, more enums, more breakfast
---
modules/cairo/seed-cairo-enums.c | 41 +++++++++++++++++-
modules/cairo/seed-cairo.c | 90 ++++++++++++++++++++++++++++++++++++++
2 files changed, 130 insertions(+), 1 deletions(-)
diff --git a/modules/cairo/seed-cairo-enums.c b/modules/cairo/seed-cairo-enums.c
index e002c8c..16b7339 100644
--- a/modules/cairo/seed-cairo-enums.c
+++ b/modules/cairo/seed-cairo-enums.c
@@ -8,7 +8,8 @@ void
seed_define_cairo_enums (SeedContext ctx,
SeedObject namespace_ref)
{
- SeedObject content_holder, format_holder, antialias_holder;
+ SeedObject content_holder, format_holder, antialias_holder, fillrule_holder,
+ linecap_holder, linejoin_holder, operator_holder;
content_holder = seed_make_object (ctx, NULL, NULL);
seed_object_set_property (ctx, namespace_ref, "Content", content_holder);
@@ -29,4 +30,42 @@ seed_define_cairo_enums (SeedContext ctx,
ENUM_MEMBER(antialias_holder, "NONE", CAIRO_ANTIALIAS_NONE);
ENUM_MEMBER(antialias_holder, "GRAY", CAIRO_ANTIALIAS_GRAY);
ENUM_MEMBER(antialias_holder, "SUBPIXEL", CAIRO_ANTIALIAS_SUBPIXEL);
+
+ fillrule_holder = seed_make_object (ctx, NULL, NULL);
+ seed_object_set_property (ctx, namespace_ref, "Fillrule", fillrule_holder);
+ ENUM_MEMBER(fillrule_holder, "WINDING", CAIRO_FILL_RULE_WINDING);
+ ENUM_MEMBER(fillrule_holder, "EVEN_ODD", CAIRO_FILL_RULE_EVEN_ODD);
+
+ linecap_holder = seed_make_object (ctx, NULL, NULL);
+ seed_object_set_property (ctx, namespace_ref, "Linecap", linecap_holder);
+ ENUM_MEMBER(linecap_holder, "BUTT", CAIRO_LINE_CAP_BUTT);
+ ENUM_MEMBER(linecap_holder, "ROUND", CAIRO_LINE_CAP_ROUND);
+ ENUM_MEMBER(linecap_holder, "SQUARE", CAIRO_LINE_CAP_SQUARE);
+
+ linejoin_holder = seed_make_object (ctx, NULL, NULL);
+ seed_object_set_property (ctx, namespace_ref, "Linejoin", linejoin_holder);
+ ENUM_MEMBER(linejoin_holder, "MITER", CAIRO_LINE_JOIN_MITER);
+ ENUM_MEMBER(linejoin_holder, "ROUND", CAIRO_LINE_JOIN_ROUND);
+ ENUM_MEMBER(linejoin_holder, "BEVEL", CAIRO_LINE_JOIN_BEVEL);
+
+
+ operator_holder = seed_make_object (ctx, NULL, NULL);
+ seed_object_set_property (ctx, namespace_ref, "Operator", operator_holder);
+ ENUM_MEMBER(operator_holder, "CLEAR", CAIRO_OPERATOR_CLEAR);
+ ENUM_MEMBER(operator_holder, "SOURCE", CAIRO_OPERATOR_SOURCE);
+ ENUM_MEMBER(operator_holder, "OVER", CAIRO_OPERATOR_OVER);
+ ENUM_MEMBER(operator_holder, "IN", CAIRO_OPERATOR_IN);
+ ENUM_MEMBER(operator_holder, "OUT", CAIRO_OPERATOR_OUT);
+ ENUM_MEMBER(operator_holder, "ATOP", CAIRO_OPERATOR_ATOP);
+ ENUM_MEMBER(operator_holder, "DEST", CAIRO_OPERATOR_DEST);
+ ENUM_MEMBER(operator_holder, "DEST_OVER", CAIRO_OPERATOR_DEST_OVER);
+ ENUM_MEMBER(operator_holder, "DEST_IN", CAIRO_OPERATOR_DEST_IN);
+ ENUM_MEMBER(operator_holder, "DEST_OUT", CAIRO_OPERATOR_DEST_OUT);
+ ENUM_MEMBER(operator_holder, "DEST_ATOP", CAIRO_OPERATOR_DEST_ATOP);
+ ENUM_MEMBER(operator_holder, "XOR", CAIRO_OPERATOR_XOR);
+ ENUM_MEMBER(operator_holder, "ADD", CAIRO_OPERATOR_ADD);
+ ENUM_MEMBER(operator_holder, "SATURATE", CAIRO_OPERATOR_SATURATE);
+
+
+
}
diff --git a/modules/cairo/seed-cairo.c b/modules/cairo/seed-cairo.c
index b31a23e..9c1c141 100644
--- a/modules/cairo/seed-cairo.c
+++ b/modules/cairo/seed-cairo.c
@@ -322,6 +322,93 @@ seed_cairo_get_antialias (SeedContext ctx,
return seed_value_from_long (ctx, antialias, exception);
}
+
+static SeedValue
+seed_cairo_set_dash(SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException *exception)
+{
+ SeedValue length;
+ cairo_t *cr;
+ gdouble *dashes, offset;
+ gint num_dashes, i;
+
+ CHECK_THIS();
+ cr = seed_object_get_private (this_object);
+
+ if (argument_count != 2)
+ {
+ EXPECTED_EXCEPTION("set_dash", "2 arguments");
+ }
+ length = seed_object_get_property (ctx, arguments[0], "length");
+ num_dashes = seed_value_to_int (ctx, length, exception);
+ dashes = g_alloca (num_dashes * sizeof(gdouble));
+ for (i = 0; i < num_dashes; i++)
+ {
+ dashes[i] = seed_value_to_double(ctx,
+ seed_object_get_property_at_index (ctx,
+ arguments[0],
+ i,
+ exception),
+ exception);
+
+ }
+ offset = seed_value_to_double (ctx, arguments[1], exception);
+ cairo_set_dash (cr, dashes, num_dashes, offset);
+
+ return seed_make_undefined (ctx);
+}
+
+static SeedValue
+seed_cairo_get_dash_count (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException *exception)
+{
+ cairo_t *cr;
+ gint dash_count;
+ CHECK_THIS();
+
+ cr = seed_object_get_private (this_object);
+ dash_count = cairo_get_dash_count (cr);
+
+ return seed_value_from_int (ctx, dash_count, exception);
+}
+
+static SeedValue
+seed_cairo_get_dash (SeedContext ctx,
+ SeedObject function,
+ SeedObject this_object,
+ gsize argument_count,
+ const SeedValue arguments[],
+ SeedException *exception)
+{
+ SeedValue ret[2], *jsdashes;
+ cairo_t *cr;
+ gint dash_count, i;
+ gdouble *dashes, offset;
+
+ CHECK_THIS();
+ cr = seed_object_get_private (this_object);
+ dash_count = cairo_get_dash_count (cr);
+ dashes = g_alloca (dash_count * sizeof(gdouble));
+ jsdashes = g_alloca (dash_count * sizeof(SeedValue));
+
+ cairo_get_dash (cr, dashes, &offset);
+ for (i = 0; i < dash_count; i++)
+ {
+ jsdashes[i] = seed_value_from_double (ctx, dashes[i], exception);
+ }
+ ret[0] = seed_make_array (ctx, jsdashes, dash_count, exception);
+ ret[1] = seed_value_from_double (ctx, offset, exception);
+
+ return seed_make_array (ctx, ret, 2, exception);
+}
seed_static_function cairo_funcs[] = {
{"save", seed_cairo_save, 0},
@@ -339,6 +426,9 @@ seed_static_function cairo_funcs[] = {
// {"get_source", seed_cairo_get_source, 0},
{"set_antialias", seed_cairo_set_antialias, 0},
{"get_antialias", seed_cairo_get_antialias, 0},
+ {"set_dash", seed_cairo_set_dash, 0},
+ {"get_dash_count", seed_cairo_get_dash_count, 0},
+ {"get_dash", seed_cairo_get_dash, 0},
{0, 0, 0}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]