[cairo-commit] rcairo/packages/cairo/ext extconf.rb, 1.4,
1.5 rb_cairo.c, 1.2, 1.3 rb_cairo.h, 1.1,
1.2 rb_cairo_constants.c, 1.2, 1.3 rb_cairo_context.c, 1.5,
1.6 rb_cairo_exception.c, 1.2, 1.3 rb_cairo_matrix.c, 1.3,
1.4 rb_cairo_pattern.c, 1.2, 1.3 rb_cairo_surface.c, 1.2, 1.3
Oeyvind Kolaas
commit at pdx.freedesktop.org
Thu Jun 23 02:30:50 PDT 2005
- Previous message: [cairo-commit] rcairo/packages/cairo/lib cairo.rb,1.7,1.8
- Next message: [cairo-commit] rcairo/packages/cairo/ext rb_cairo_font.c, 1.1,
NONE rb_cairo_font.h, 1.1, NONE rb_cairo_font_face.c, NONE,
1.1 rb_cairo_font_face.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: pippin
Update of /cvs/cairo/rcairo/packages/cairo/ext
In directory gabe:/tmp/cvs-serv3877/packages/cairo/ext
Modified Files:
extconf.rb rb_cairo.c rb_cairo.h rb_cairo_constants.c
rb_cairo_context.c rb_cairo_exception.c rb_cairo_matrix.c
rb_cairo_pattern.c rb_cairo_surface.c
Log Message:
API shakeup, watch out for falling pieces
Index: extconf.rb
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/extconf.rb,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- extconf.rb 8 Feb 2005 01:28:21 -0000 1.4
+++ extconf.rb 23 Jun 2005 09:30:48 -0000 1.5
@@ -3,7 +3,7 @@
require 'mkmf'
-$CFLAGS = `pkg-config --cflags cairo`
+$CFLAGS = "-Wall "+`pkg-config --cflags cairo`
$LDFLAGS = `pkg-config --libs cairo`
create_makefile("cairo")
Index: rb_cairo.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rb_cairo.c 14 Feb 2005 23:51:54 -0000 1.2
+++ rb_cairo.c 23 Jun 2005 09:30:48 -0000 1.3
@@ -28,5 +28,4 @@
Init_cairo_font_extents ();
Init_cairo_pattern ();
Init_cairo_glyph ();
-
}
Index: rb_cairo.h
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- rb_cairo.h 8 Feb 2005 01:28:21 -0000 1.1
+++ rb_cairo.h 23 Jun 2005 09:30:48 -0000 1.2
@@ -24,7 +24,7 @@
#include "rb_cairo_exception.h"
#include "rb_cairo_matrix.h"
#include "rb_cairo_pattern.h"
-#include "rb_cairo_font.h"
+#include "rb_cairo_font_face.h"
#include "rb_cairo_font_extents.h"
#include "rb_cairo_text_extents.h"
#include "rb_cairo_glyph.h"
Index: rb_cairo_constants.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_constants.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rb_cairo_constants.c 14 Feb 2005 23:51:54 -0000 1.2
+++ rb_cairo_constants.c 23 Jun 2005 09:30:48 -0000 1.3
@@ -55,26 +55,26 @@
rb_define_const (rb_mCairo, "OPERATOR_CLEAR",
INT2FIX (CAIRO_OPERATOR_CLEAR));
- rb_define_const (rb_mCairo, "OPERATOR_SRC",
- INT2FIX (CAIRO_OPERATOR_SRC));
- rb_define_const (rb_mCairo, "OPERATOR_DST",
- INT2FIX (CAIRO_OPERATOR_DST));
+ rb_define_const (rb_mCairo, "OPERATOR_SOURCE",
+ INT2FIX (CAIRO_OPERATOR_SOURCE));
+ rb_define_const (rb_mCairo, "OPERATOR_DEST",
+ INT2FIX (CAIRO_OPERATOR_DEST));
rb_define_const (rb_mCairo, "OPERATOR_OVER",
INT2FIX (CAIRO_OPERATOR_OVER));
- rb_define_const (rb_mCairo, "OPERATOR_OVER_REVERSE",
- INT2FIX (CAIRO_OPERATOR_OVER_REVERSE));
+ rb_define_const (rb_mCairo, "OPERATOR_DEST_OVER",
+ INT2FIX (CAIRO_OPERATOR_DEST_OVER));
rb_define_const (rb_mCairo, "OPERATOR_IN",
INT2FIX (CAIRO_OPERATOR_IN));
- rb_define_const (rb_mCairo, "OPERATOR_IN_REVERSE",
- INT2FIX (CAIRO_OPERATOR_IN_REVERSE));
+ rb_define_const (rb_mCairo, "OPERATOR_DEST_IN",
+ INT2FIX (CAIRO_OPERATOR_DEST_IN));
rb_define_const (rb_mCairo, "OPERATOR_OUT",
INT2FIX (CAIRO_OPERATOR_OUT));
- rb_define_const (rb_mCairo, "OPERATOR_OUT_REVERSE",
- INT2FIX (CAIRO_OPERATOR_OUT_REVERSE));
+ rb_define_const (rb_mCairo, "OPERATOR_DEST_OUT",
+ INT2FIX (CAIRO_OPERATOR_DEST_OUT));
rb_define_const (rb_mCairo, "OPERATOR_ATOP",
INT2FIX (CAIRO_OPERATOR_ATOP));
- rb_define_const (rb_mCairo, "OPERATOR_ATOP_REVERSE",
- INT2FIX (CAIRO_OPERATOR_ATOP_REVERSE));
+ rb_define_const (rb_mCairo, "OPERATOR_DEST_ATOP",
+ INT2FIX (CAIRO_OPERATOR_DEST_ATOP));
rb_define_const (rb_mCairo, "OPERATOR_XOR",
INT2FIX (CAIRO_OPERATOR_XOR));
rb_define_const (rb_mCairo, "OPERATOR_ADD",
Index: rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_context.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- rb_cairo_context.c 21 Mar 2005 13:11:05 -0000 1.5
+++ rb_cairo_context.c 23 Jun 2005 09:30:48 -0000 1.6
@@ -62,10 +62,15 @@
}
static VALUE
-rb_cairo_new (VALUE klass)
+rb_cairo_new (VALUE klass,
+ VALUE target_v)
{
- cairo_t *cr;
- cr = cairo_create ();
+ cairo_surface_t *target;
+ cairo_t *cr;
+
+ target = rb_v_to_cairo_surface_t (target_v);
+ cr = cairo_create (target);
+
if (cr)
{
return Data_Wrap_Struct (rb_cCairo_Context, NULL, rb_free_context, cr);
@@ -100,24 +105,6 @@
return self;
}
-static VALUE
-rb_cairo_copy (VALUE self,
- VALUE other)
-{
- cairo_copy (_SELF, rb_v_to_cairo_t (other));
- check_context_status (_SELF);
- return self;
-}
-
-static VALUE
-rb_cairo_set_target_surface (VALUE self,
- VALUE surface)
-{
- cairo_set_target_surface (_SELF, rb_v_to_cairo_surface_t (surface));
- check_context_status (_SELF);
- return self;
-}
-
#if 0
NYI
rb_cairo_set_target_image (VALUE self,
@@ -140,38 +127,66 @@
}
static VALUE
-rb_cairo_set_rgb_color (VALUE self,
- VALUE red,
- VALUE green,
- VALUE blue)
+rb_cairo_set_source_rgb (VALUE self,
+ VALUE red,
+ VALUE green,
+ VALUE blue)
{
- cairo_set_rgb_color (_SELF,
- NUM2DBL (red),
- NUM2DBL (green),
- NUM2DBL (blue));
+ cairo_set_source_rgb (_SELF,
+ NUM2DBL (red),
+ NUM2DBL (green),
+ NUM2DBL (blue));
return self;
}
static VALUE
-rb_cairo_set_pattern (VALUE self,
- VALUE pattern_v)
+rb_cairo_set_source_rgba (VALUE self,
+ VALUE red_v,
+ VALUE green_v,
+ VALUE blue_v,
+ VALUE alpha_v)
+{
+ cairo_set_source_rgba (_SELF,
+ NUM2DBL (red_v),
+ NUM2DBL (green_v),
+ NUM2DBL (blue_v),
+ NUM2DBL (alpha_v));
+ return self;
+}
+
+static VALUE
+rb_cairo_set_source_surface (VALUE self,
+ VALUE surface_v,
+ VALUE width_v,
+ VALUE height_v)
+{
+ cairo_surface_t *surface = rb_v_to_cairo_surface_t (surface_v);
+ int width = NUM2INT (width_v);
+ int height = NUM2INT (height_v);
+ cairo_set_source_surface (_SELF, surface, width, height);
+ check_context_status (_SELF);
+ return self;
+}
+
+static VALUE
+rb_cairo_set_source (VALUE self,
+ VALUE pattern_v)
{
cairo_pattern_t *pattern;
pattern = rb_v_to_cairo_pattern_t (pattern_v);
- cairo_set_pattern (_SELF, pattern);
+ cairo_set_source (_SELF, pattern);
check_context_status (_SELF);
return self;
}
static VALUE
-rb_cairo_set_alpha (VALUE self,
- VALUE alpha)
+rb_cairo_get_source (VALUE self)
{
- cairo_set_alpha (_SELF, NUM2DBL (alpha));
- check_context_status (_SELF);
- return self;
+ cairo_pattern_t *pattern;
+ pattern = cairo_get_source (_SELF);
+ return rb_cairo_pattern_wrap (pattern);
}
static VALUE
@@ -331,13 +346,6 @@
}
static VALUE
-rb_cairo_default_matrix (VALUE self)
-{
- cairo_default_matrix (_SELF);
- return self;
-}
-
-static VALUE
rb_cairo_identity_matrix (VALUE self)
{
cairo_identity_matrix (_SELF);
@@ -384,7 +392,7 @@
double pair[2];
pair[0] = NUM2DBL (dx);
pair[1] = NUM2DBL (dy);
- cairo_inverse_device_to_user_distance (_SELF, pair, pair + 1);
+ cairo_device_to_user_distance (_SELF, pair, pair + 1);
return float_array (pair, 2);
}
@@ -503,9 +511,6 @@
return self;
}
-
-
-
static VALUE
rb_cairo_stroke (VALUE self)
{
@@ -519,6 +524,20 @@
return self;
}
+
+static VALUE
+rb_cairo_stroke_preserve (VALUE self)
+{
+ if (rb_block_given_p ())
+ {
+ cairo_new_path (_SELF);
+ rb_yield (Qnil);
+ }
+ cairo_stroke_preserve (_SELF);
+ check_context_status (_SELF);
+ return self;
+}
+
static VALUE
rb_cairo_fill (VALUE self)
{
@@ -532,6 +551,28 @@
return self;
}
+
+static VALUE
+rb_cairo_fill_preserve (VALUE self)
+{
+ if (rb_block_given_p ())
+ {
+ cairo_new_path (_SELF);
+ rb_yield (Qnil);
+ }
+ cairo_fill_preserve (_SELF);
+ check_context_status (_SELF);
+ return self;
+}
+
+static VALUE
+rb_cairo_paint (VALUE self)
+{
+ cairo_paint (_SELF);
+ check_context_status (_SELF);
+ return self;
+}
+
static VALUE
rb_cairo_copy_page (VALUE self)
{
@@ -632,10 +673,10 @@
/* The "toy" text api */
static VALUE
-rb_cairo_select_font (VALUE self,
- VALUE familiy,
- VALUE slant_v,
- VALUE weight_v)
+rb_cairo_select_font_face (VALUE self,
+ VALUE family,
+ VALUE slant_v,
+ VALUE weight_v)
{
int slant = NUM2INT (slant_v);
int weight = NUM2INT (weight_v);
@@ -653,28 +694,28 @@
}
- cairo_select_font (_SELF,
- STR2CSTR (familiy),
- slant,
- weight);
+ cairo_select_font_face (_SELF,
+ STR2CSTR (family),
+ slant,
+ weight);
return self;
}
static VALUE
-rb_cairo_scale_font (VALUE self,
- VALUE scale)
+rb_cairo_set_font_size (VALUE self,
+ VALUE scale)
{
- cairo_scale_font (_SELF,
- NUM2DBL (scale));
+ cairo_set_font_size (_SELF,
+ NUM2DBL (scale));
return self;
}
static VALUE
-rb_cairo_transform_font (VALUE self,
+rb_cairo_set_font_matrix (VALUE self,
VALUE matrix)
{
- cairo_transform_font (_SELF,
- rb_v_to_cairo_matrix_t (matrix));
+ cairo_set_font_matrix (_SELF,
+ rb_v_to_cairo_matrix_t (matrix));
return self;
}
@@ -720,116 +761,38 @@
}
static VALUE
-rb_cairo_get_font (VALUE self)
+rb_cairo_get_font_face (VALUE self)
{
- cairo_font_t *xform;
- xform = cairo_get_font (_SELF);
+ cairo_font_face_t *xform;
+ xform = cairo_get_font_face (_SELF);
if (xform)
{
if (cairo_status (_SELF))
{
- rb_free_font (xform);
+ rb_free_font_face (xform);
rb_cairo_raise_exception (cairo_status (_SELF),
cairo_status_string (_SELF));
}
- return Data_Wrap_Struct (rb_cCairo_Font, NULL, rb_free_font, xform);
+ return Data_Wrap_Struct (rb_cCairo_FontFace, NULL, rb_free_font_face, xform);
}
else
{
- rb_raise (rb_eNoMemError, "unable to get current font");
+ rb_raise (rb_eNoMemError, "unable to get current font face");
return Qundef;
}
}
static VALUE
-rb_cairo_get_font_extents (VALUE self)
-{
- return Qnil;
-}
-
-static VALUE
-rb_cairo_set_font (VALUE self,
- VALUE xform)
+rb_cairo_set_font_face (VALUE self,
+ VALUE xform)
{
- cairo_set_font (_SELF, value_to_font (xform));
+ cairo_set_font_face (_SELF,
+ value_to_font_face (xform));
check_context_status (_SELF);
return self;
}
static VALUE
-rb_cairo_text_extents (VALUE self,
- VALUE utf8)
-{
- cairo_text_extents_t *xform;
-
- xform = ALLOC (cairo_text_extents_t);
- if (xform)
- {
- cairo_text_extents (_SELF, STR2CSTR(utf8),xform);
- if (cairo_status (_SELF))
- {
- rb_free_font (xform);
- rb_cairo_raise_exception (cairo_status (_SELF),
- cairo_status_string (_SELF));
- }
- return Data_Wrap_Struct (rb_cCairo_TextExtents, NULL, rb_free_text_extents, xform);
- }
- else
- {
- rb_raise (rb_eNoMemError, "unable to allocate memory for text extents");
- return Qundef;
- }
-}
-
-static VALUE
-rb_cairo_glyph_extents (VALUE self,
- VALUE glyphs_v)
-{
- int i;
- int count;
- cairo_glyph_t *glyphs;
- cairo_text_extents_t *xform;
-
- if (!rb_obj_is_kind_of (glyphs_v, rb_cArray))
- rb_raise (rb_eTypeError, "expected array");
-
-
- count = RARRAY(glyphs_v)->len;
- glyphs = malloc (sizeof (cairo_glyph_t) * count);
-
- if (!glyphs)
- rb_raise (rb_eNoMemError, "unable to allocate memory for text extents");
-
- for (i=0; i< count; i++)
- {
- memcpy ( (char *) &glyphs[i],
- (char *) DATA_PTR (rb_ary_entry (glyphs_v, i)),
- sizeof (cairo_glyph_t));
- }
-
- xform = ALLOC (cairo_text_extents_t);
-
- if (xform)
- {
- cairo_glyph_extents (_SELF, glyphs, count, xform);
- if (cairo_status (_SELF))
- {
- rb_free_font (xform);
- rb_cairo_raise_exception (cairo_status (_SELF),
- cairo_status_string (_SELF));
- }
- free (glyphs);
- return Data_Wrap_Struct (rb_cCairo_TextExtents, NULL, rb_free_text_extents, xform);
- }
- else
- {
- rb_raise (rb_eNoMemError, "unable to allocate memory for text extents");
- free (glyphs);
- return Qundef;
- }
-}
-
-static VALUE
rb_cairo_text_path (VALUE self,
VALUE utf8)
{
@@ -870,19 +833,6 @@
}
-/* Image functions */
-
-static VALUE
-rb_cairo_show_surface (VALUE self,
- VALUE surface,
- VALUE width, VALUE height)
-{
- cairo_show_surface (_SELF, rb_v_to_cairo_surface_t (surface),
- NUM2INT (width), NUM2INT (height));
- check_context_status (_SELF);
- return self;
-}
-
/* Query functions */
static VALUE
@@ -893,28 +843,6 @@
return INT2FIX (op);
}
-static VALUE
-rb_cairo_get_rgb_color (VALUE self)
-{
- double rgb[3];
- cairo_get_rgb_color (_SELF,
- rgb, rgb + 1, rgb + 2);
- return float_array (rgb, 3);
-}
-
-static VALUE
-rb_cairo_get_pattern (VALUE self)
-{
- return rb_cairo_pattern_wrap (cairo_get_pattern (_SELF));
-}
-
-static VALUE
-rb_cairo_get_alpha (VALUE self)
-{
- double alpha;
- alpha = cairo_get_alpha (_SELF);
- return rb_float_new (alpha);
-}
static VALUE
rb_cairo_get_tolerance (VALUE self)
@@ -925,10 +853,10 @@
}
static VALUE
-rb_cairo_get_point (VALUE self)
+rb_cairo_get_current_point (VALUE self)
{
double point[2];
- cairo_get_point (_SELF, point, point + 1);
+ cairo_get_current_point (_SELF, point, point + 1);
return float_array (point, 2);
}
@@ -975,7 +903,7 @@
static VALUE
rb_cairo_get_matrix (VALUE self)
{
- cairo_matrix_t *matrix = cairo_matrix_create ();
+ cairo_matrix_t *matrix = malloc (sizeof (cairo_matrix_t));
if (matrix)
{
cairo_get_matrix (_SELF, matrix);
@@ -996,10 +924,10 @@
static VALUE
-rb_cairo_get_target_surface (VALUE self)
+rb_cairo_get_target (VALUE self)
{
cairo_surface_t *surface;
- surface = cairo_get_target_surface (_SELF);
+ surface = cairo_get_target (_SELF);
if (surface)
{
cairo_surface_reference (surface);
@@ -1012,92 +940,6 @@
}
}
-static VALUE
-symbol (const char *name,
- VALUE *cache)
-{
- if (NIL_P (*cache))
- {
- *cache = ID2SYM (rb_intern (name));
- }
- return *cache;
-}
-
-static void
-push_move_to (void *closure,
- double x, double y)
-{
- static VALUE move_to = Qnil;
- VALUE array = (VALUE) closure;
- rb_ary_push (array,
- rb_ary_new3 (3,
- symbol ("move_to", &move_to),
- rb_float_new (x), rb_float_new (y)));
-}
-
-static void
-push_line_to (void *closure,
- double x, double y)
-{
- static VALUE line_to = Qnil;
- VALUE array = (VALUE) closure;
- rb_ary_push (array,
- rb_ary_new3 (3,
- symbol ("line_to", &line_to),
- rb_float_new (x), rb_float_new (y)));
-}
-
-static void
-push_curve_to (void *closure,
- double x1, double y1,
- double x2, double y2,
- double x3, double y3)
-{
- static VALUE curve_to = Qnil;
- VALUE array = (VALUE) closure;
- rb_ary_push (array,
- rb_ary_new3 (7,
- symbol ("curve_to", &curve_to),
- rb_float_new (x1), rb_float_new (y1),
- rb_float_new (x2), rb_float_new (y2),
- rb_float_new (x3), rb_float_new (y3)));
-}
-
-static void
-push_close_path (void *closure)
-{
- static VALUE close_path = Qnil;
- VALUE array = (VALUE) closure;
- rb_ary_push (array, rb_ary_new3 (1, symbol ("close_path", &close_path)));
-}
-
-static VALUE
-rb_cairo_get_path_array (VALUE self)
-{
- VALUE array;
- array = rb_ary_new ();
-
- cairo_get_path (_SELF,
- &push_move_to,
- &push_line_to,
- &push_curve_to, &push_close_path, (void *) array);
-
- return array;
-}
-
-static VALUE
-rb_cairo_get_path_flat_array (VALUE self)
-{
- VALUE array;
- array = rb_ary_new ();
-
- cairo_get_path_flat (_SELF,
- &push_move_to,
- &push_line_to, &push_close_path, (void *) array);
-
- return array;
-}
-
void
Init_cairo_context (void)
{
@@ -1105,25 +947,23 @@
rb_define_class_under (rb_mCairo, "Context", rb_cObject);
rb_define_singleton_method (rb_cCairo_Context, "new",
- RUBY_METHOD_FUNC (rb_cairo_new), 0);
+ RUBY_METHOD_FUNC (rb_cairo_new), 1);
rb_define_method (rb_cCairo_Context, "save",
RUBY_METHOD_FUNC (rb_cairo_save), 0);
rb_define_method (rb_cCairo_Context, "restore",
RUBY_METHOD_FUNC (rb_cairo_restore), 0);
- rb_define_method (rb_cCairo_Context, "copy",
- RUBY_METHOD_FUNC (rb_cairo_copy), 1);
- rb_define_method (rb_cCairo_Context, "set_target_surface",
- RUBY_METHOD_FUNC (rb_cairo_set_target_surface), 1);
rb_define_method (rb_cCairo_Context, "set_operator",
RUBY_METHOD_FUNC (rb_cairo_set_operator), 1);
- rb_define_method (rb_cCairo_Context, "set_rgb_color",
- RUBY_METHOD_FUNC (rb_cairo_set_rgb_color), 3);
- rb_define_method (rb_cCairo_Context, "set_pattern",
- RUBY_METHOD_FUNC (rb_cairo_set_pattern), 1);
- rb_define_method (rb_cCairo_Context, "set_alpha",
- RUBY_METHOD_FUNC (rb_cairo_set_alpha), 1);
+ rb_define_method (rb_cCairo_Context, "set_source_rgb",
+ RUBY_METHOD_FUNC (rb_cairo_set_source_rgb), 3);
+ rb_define_method (rb_cCairo_Context, "set_source_rgba",
+ RUBY_METHOD_FUNC (rb_cairo_set_source_rgba), 4);
+ rb_define_method (rb_cCairo_Context, "set_source",
+ RUBY_METHOD_FUNC (rb_cairo_set_source), 1);
+ rb_define_method (rb_cCairo_Context, "set_source_surface",
+ RUBY_METHOD_FUNC (rb_cairo_set_source_surface), 3);
rb_define_method (rb_cCairo_Context, "set_tolerance",
RUBY_METHOD_FUNC (rb_cairo_set_tolerance), 1);
rb_define_method (rb_cCairo_Context, "set_fill_rule",
@@ -1148,8 +988,6 @@
RUBY_METHOD_FUNC (rb_cairo_transform), 1);
rb_define_method (rb_cCairo_Context, "set_matrix",
RUBY_METHOD_FUNC (rb_cairo_set_matrix), 1);
- rb_define_method (rb_cCairo_Context, "default_matrix",
- RUBY_METHOD_FUNC (rb_cairo_default_matrix), 1);
rb_define_method (rb_cCairo_Context, "identity_matrix",
RUBY_METHOD_FUNC (rb_cairo_identity_matrix), 1);
rb_define_method (rb_cCairo_Context, "user_to_device",
@@ -1187,12 +1025,18 @@
RUBY_METHOD_FUNC (rb_cairo_close_path), 0);
+ rb_define_method (rb_cCairo_Context, "paint",
+ RUBY_METHOD_FUNC (rb_cairo_paint), 0);
rb_define_method (rb_cCairo_Context, "stroke",
RUBY_METHOD_FUNC (rb_cairo_stroke), 0);
rb_define_method (rb_cCairo_Context, "fill",
RUBY_METHOD_FUNC (rb_cairo_fill), 0);
+ rb_define_method (rb_cCairo_Context, "stroke_preserve",
+ RUBY_METHOD_FUNC (rb_cairo_stroke_preserve), 0);
+ rb_define_method (rb_cCairo_Context, "fill_preserve",
+ RUBY_METHOD_FUNC (rb_cairo_fill_preserve), 0);
rb_define_method (rb_cCairo_Context, "copy_page",
RUBY_METHOD_FUNC (rb_cairo_copy_page), 0);
@@ -1212,21 +1056,15 @@
rb_define_method (rb_cCairo_Context, "clip",
RUBY_METHOD_FUNC (rb_cairo_clip), 0);
- rb_define_method (rb_cCairo_Context, "show_surface",
- RUBY_METHOD_FUNC (rb_cairo_show_surface), 3);
rb_define_method (rb_cCairo_Context, "get_operator",
RUBY_METHOD_FUNC (rb_cairo_get_operator), 0);
- rb_define_method (rb_cCairo_Context, "get_rgb_color",
- RUBY_METHOD_FUNC (rb_cairo_get_rgb_color), 0);
- rb_define_method (rb_cCairo_Context, "get_pattern",
- RUBY_METHOD_FUNC (rb_cairo_get_pattern), 0);
- rb_define_method (rb_cCairo_Context, "get_alpha",
- RUBY_METHOD_FUNC (rb_cairo_get_alpha), 0);
+ rb_define_method (rb_cCairo_Context, "get_source",
+ RUBY_METHOD_FUNC (rb_cairo_get_source), 0);
rb_define_method (rb_cCairo_Context, "get_tolerance",
RUBY_METHOD_FUNC (rb_cairo_get_tolerance), 0);
- rb_define_method (rb_cCairo_Context, "get_point",
- RUBY_METHOD_FUNC (rb_cairo_get_point), 0);
+ rb_define_method (rb_cCairo_Context, "get_current_point",
+ RUBY_METHOD_FUNC (rb_cairo_get_current_point), 0);
rb_define_method (rb_cCairo_Context, "get_fill_rule",
RUBY_METHOD_FUNC (rb_cairo_get_fill_rule), 0);
rb_define_method (rb_cCairo_Context, "get_line_width",
@@ -1241,36 +1079,26 @@
RUBY_METHOD_FUNC (rb_cairo_get_matrix), 0);
- rb_define_method (rb_cCairo_Context, "select_font",
- RUBY_METHOD_FUNC (rb_cairo_select_font), 3);
- rb_define_method (rb_cCairo_Context, "scale_font",
- RUBY_METHOD_FUNC (rb_cairo_scale_font), 1);
- rb_define_method (rb_cCairo_Context, "transform_font",
- RUBY_METHOD_FUNC (rb_cairo_transform_font), 1);
+ rb_define_method (rb_cCairo_Context, "get_font_face",
+ RUBY_METHOD_FUNC (rb_cairo_get_font_face), 0);
+ rb_define_method (rb_cCairo_Context, "select_font_face",
+ RUBY_METHOD_FUNC (rb_cairo_select_font_face), 3);
+ rb_define_method (rb_cCairo_Context, "set_font_face",
+ RUBY_METHOD_FUNC (rb_cairo_set_font_face), 1);
+ rb_define_method (rb_cCairo_Context, "set_font_size",
+ RUBY_METHOD_FUNC (rb_cairo_set_font_size), 1);
+ rb_define_method (rb_cCairo_Context, "set_font_matrix",
+ RUBY_METHOD_FUNC (rb_cairo_set_font_matrix), 1);
rb_define_method (rb_cCairo_Context, "show_text",
RUBY_METHOD_FUNC (rb_cairo_show_text), 1);
rb_define_method (rb_cCairo_Context, "show_glyphs",
RUBY_METHOD_FUNC (rb_cairo_show_glyphs), 1);
- rb_define_method (rb_cCairo_Context, "get_font",
- RUBY_METHOD_FUNC (rb_cairo_get_font), 0);
- rb_define_method (rb_cCairo_Context, "get_font_extents",
- RUBY_METHOD_FUNC (rb_cairo_get_font_extents), 0);
- rb_define_method (rb_cCairo_Context, "set_font",
- RUBY_METHOD_FUNC (rb_cairo_set_font), 1);
- rb_define_method (rb_cCairo_Context, "text_extents",
- RUBY_METHOD_FUNC (rb_cairo_text_extents), 1);
- rb_define_method (rb_cCairo_Context, "glpyh_extents",
- RUBY_METHOD_FUNC (rb_cairo_glyph_extents), 1);
rb_define_method (rb_cCairo_Context, "text_path",
RUBY_METHOD_FUNC (rb_cairo_text_path), 1);
rb_define_method (rb_cCairo_Context, "glyph_path",
RUBY_METHOD_FUNC (rb_cairo_glyph_path), 1);
- rb_define_method (rb_cCairo_Context, "get_target_surface",
- RUBY_METHOD_FUNC (rb_cairo_get_target_surface), 0);
- rb_define_method (rb_cCairo_Context, "get_path_array",
- RUBY_METHOD_FUNC (rb_cairo_get_path_array), 0);
- rb_define_method (rb_cCairo_Context, "get_path_flat_array",
- RUBY_METHOD_FUNC (rb_cairo_get_path_flat_array), 0);
+ rb_define_method (rb_cCairo_Context, "get_target",
+ RUBY_METHOD_FUNC (rb_cairo_get_target), 0);
}
Index: rb_cairo_exception.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_exception.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rb_cairo_exception.c 17 Mar 2005 16:02:57 -0000 1.2
+++ rb_cairo_exception.c 23 Jun 2005 09:30:48 -0000 1.3
@@ -18,6 +18,11 @@
static VALUE rb_eCairo_NullPointerError;
static VALUE rb_eCairo_WriteError;
static VALUE rb_eCairo_SurfaceFinishedError;
+static VALUE rb_eCairo_InvalidStringError;
+static VALUE rb_eCairo_InvalidPathDataError;
+static VALUE rb_eCairo_ReadError;
+static VALUE rb_eCairo_SurfaceTypeMismatchError;
+static VALUE rb_eCairo_PatternTypeMismatchError;
void
rb_cairo_raise_exception (cairo_status_t status,
@@ -51,6 +56,24 @@
break;
case CAIRO_STATUS_SURFACE_FINISHED:
rb_raise (rb_eCairo_SurfaceFinishedError, string);
+ break;
+ case CAIRO_STATUS_INVALID_STRING:
+ rb_raise (rb_eCairo_InvalidStringError, string);
+ break;
+ case CAIRO_STATUS_INVALID_PATH_DATA:
+ rb_raise (rb_eCairo_InvalidPathDataError, string);
+ break;
+ case CAIRO_STATUS_READ_ERROR:
+ rb_raise (rb_eCairo_ReadError, string);
+ break;
+ case CAIRO_STATUS_SURFACE_TYPE_MISMATCH:
+ rb_raise (rb_eCairo_SurfaceTypeMismatchError, string);
+ break;
+ case CAIRO_STATUS_PATTERN_TYPE_MISMATCH:
+ rb_raise (rb_eCairo_PatternTypeMismatchError, string);
+ break;
+ case CAIRO_STATUS_SUCCESS:
+ break;
}
}
@@ -81,4 +104,19 @@
rb_eCairo_SurfaceFinishedError =
rb_define_class_under (rb_mCairo, "SurfaceFinishedError",
rb_eRuntimeError);
+ rb_eCairo_InvalidStringError =
+ rb_define_class_under (rb_mCairo, "InvalidStringError",
+ rb_eArgError);
+ rb_eCairo_InvalidPathDataError =
+ rb_define_class_under (rb_mCairo, "InvalidPathDataError",
+ rb_eArgError);
+ rb_eCairo_ReadError =
+ rb_define_class_under (rb_mCairo, "ReadError",
+ rb_eRuntimeError);
+ rb_eCairo_SurfaceTypeMismatchError =
+ rb_define_class_under (rb_mCairo, "SurfaceTypeMismatch",
+ rb_eTypeError);
+ rb_eCairo_PatternTypeMismatchError =
+ rb_define_class_under (rb_mCairo, "PatternTypeMismatch",
+ rb_eTypeError);
}
Index: rb_cairo_matrix.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_matrix.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- rb_cairo_matrix.c 17 Mar 2005 16:02:57 -0000 1.3
+++ rb_cairo_matrix.c 23 Jun 2005 09:30:48 -0000 1.4
@@ -32,7 +32,7 @@
{
if (ptr)
{
- cairo_matrix_destroy ((cairo_matrix_t *) ptr);
+ free (ptr);
}
}
@@ -46,12 +46,28 @@
}
else
{
- rb_raise (rb_eNoMemError, "unable to wrap matrix");
+ rb_raise (rb_eArgError, "unable to wrap matrix");
return Qundef;
}
}
+static VALUE
+float_array (double *values,
+ unsigned count)
+{
+ VALUE result;
+ unsigned i;
+
+ result = rb_ary_new2 (count);
+ for (i = 0; i < count; i++)
+ {
+ rb_ary_push (result, rb_float_new (values[i]));
+ }
+ return result;
+}
+
+
/*
* methods
*/
@@ -61,9 +77,13 @@
static VALUE
rb_cairo_matrix_new (VALUE klass)
{
- cairo_matrix_t *matrix = cairo_matrix_create ();
+ cairo_matrix_t *matrix;
+
+ matrix = malloc (sizeof (cairo_matrix_t));
+
if (matrix)
{
+ cairo_matrix_init_identity (matrix);
return rb_cairo_matrix_wrap (matrix);
}
else
@@ -76,60 +96,42 @@
static VALUE
rb_cairo_matrix_copy (VALUE self, VALUE other)
{
- cairo_status_t status;
- status =
- cairo_matrix_copy (_SELF,
- rb_v_to_cairo_matrix_t (other));
- if (status)
- {
- rb_cairo_raise_exception (status, "error copying matrix");
- }
+ cairo_matrix_copy (_SELF,
+ rb_v_to_cairo_matrix_t (other));
return self;
}
static VALUE
-rb_cairo_matrix_set_identity (VALUE self)
+rb_cairo_matrix_init_identity (VALUE self)
{
- cairo_status_t status;
- status = cairo_matrix_set_identity (_SELF);
- if (status)
- {
- rb_cairo_raise_exception (status, "error resetting matrix");
- }
+ cairo_matrix_init_identity (_SELF);
return self;
}
static VALUE
-rb_cairo_matrix_set_affine (VALUE self,
- VALUE a, VALUE b,
- VALUE c, VALUE d,
- VALUE tx, VALUE ty)
+rb_cairo_matrix_set (VALUE self,
+ VALUE a, VALUE b,
+ VALUE c, VALUE d,
+ VALUE tx, VALUE ty)
{
- cairo_status_t status;
- status = cairo_matrix_set_affine (_SELF,
- NUM2DBL (a), NUM2DBL (b),
- NUM2DBL (c), NUM2DBL (d),
- NUM2DBL (tx), NUM2DBL (ty));
- if (status)
- {
- rb_cairo_raise_exception (status, "error setting matrix components");
- }
+ cairo_matrix_init (_SELF,
+ NUM2DBL (a), NUM2DBL (b),
+ NUM2DBL (c), NUM2DBL (d),
+ NUM2DBL (tx), NUM2DBL (ty));
return self;
}
static VALUE
-rb_cairo_matrix_get_affine (VALUE self)
+rb_cairo_matrix_get (VALUE self)
{
- cairo_status_t status;
+ cairo_matrix_t *matrix = _SELF;
double affine[6];
- status = cairo_matrix_get_affine (_SELF,
- affine, affine + 1,
- affine + 2, affine + 3,
- affine + 4, affine + 5);
- if (status)
- {
- rb_cairo_raise_exception (status, "error getting matrix components");
- }
+ affine[0] = matrix->xx;
+ affine[1] = matrix->yx;
+ affine[2] = matrix->xy;
+ affine[3] = matrix->yy;
+ affine[4] = matrix->x0;
+ affine[5] = matrix->y0;
return float_array (affine, 6);
}
@@ -137,13 +139,8 @@
rb_cairo_matrix_translate (VALUE self,
VALUE tx, VALUE ty)
{
- cairo_status_t status;
- status = cairo_matrix_translate (_SELF,
- NUM2DBL (tx), NUM2DBL (ty));
- if (status)
- {
- rb_cairo_raise_exception (status, "error translating matrix");
- }
+ cairo_matrix_translate (_SELF,
+ NUM2DBL (tx), NUM2DBL (ty));
return self;
}
@@ -151,13 +148,8 @@
rb_cairo_matrix_scale (VALUE self,
VALUE sx, VALUE sy)
{
- cairo_status_t status;
- status = cairo_matrix_scale (_SELF,
- NUM2DBL (sx), NUM2DBL (sy));
- if (status)
- {
- rb_cairo_raise_exception (status, "error scaling matrix");
- }
+ cairo_matrix_scale (_SELF,
+ NUM2DBL (sx), NUM2DBL (sy));
return self;
}
@@ -165,74 +157,50 @@
rb_cairo_matrix_rotate (VALUE self,
VALUE radians)
{
- cairo_status_t status;
- status = cairo_matrix_rotate (_SELF,
- NUM2DBL (radians));
- if (status)
- {
- rb_cairo_raise_exception (status, "error rotating matrix");
- }
+ cairo_matrix_rotate (_SELF,
+ NUM2DBL (radians));
return self;
}
static VALUE
rb_cairo_matrix_invert (VALUE self)
{
- cairo_status_t status;
- status = cairo_matrix_invert (_SELF);
- if (status)
- {
- rb_cairo_raise_exception (status, "error inverting matrix");
- }
+ cairo_matrix_invert (_SELF);
return self;
}
static VALUE
-rb_cairo_matrix_set_product (VALUE self,
- VALUE a,
- VALUE b)
+rb_cairo_matrix_multiply (VALUE self,
+ VALUE a,
+ VALUE b)
{
- cairo_status_t status;
- status = cairo_matrix_multiply (_SELF,
- rb_v_to_cairo_matrix_t (a), rb_v_to_cairo_matrix_t (b));
- if (status)
- {
- rb_cairo_raise_exception (status, "error multiplying matrices");
- }
+ cairo_matrix_multiply (_SELF,
+ rb_v_to_cairo_matrix_t (a),
+ rb_v_to_cairo_matrix_t (b));
return self;
}
static VALUE
rb_cairo_matrix_transform_distance (VALUE self,
- VALUE dx, VALUE dy)
+ VALUE dx, VALUE dy)
{
- cairo_status_t status;
double pair[2];
pair[0] = NUM2DBL (dx);
pair[1] = NUM2DBL (dy);
- status = cairo_matrix_transform_distance (_SELF,
- pair, pair + 1);
- if (status)
- {
- rb_cairo_raise_exception (status, "error transforming distance");
- }
+ cairo_matrix_transform_distance (_SELF,
+ pair, pair + 1);
return float_array (pair, 2);
}
static VALUE
rb_cairo_matrix_transform_point (VALUE self,
- VALUE x, VALUE y)
+ VALUE x, VALUE y)
{
- cairo_status_t status;
double pair[2];
pair[0] = NUM2DBL (x);
pair[1] = NUM2DBL (y);
- status = cairo_matrix_transform_point (_SELF,
- pair, pair + 1);
- if (status)
- {
- rb_cairo_raise_exception (status, "error transforming point");
- }
+ cairo_matrix_transform_point (_SELF,
+ pair, pair + 1);
return float_array (pair, 2);
}
@@ -246,22 +214,22 @@
RUBY_METHOD_FUNC (rb_cairo_matrix_new), 0);
rb_define_method (rb_cCairo_Matrix, "copy",
RUBY_METHOD_FUNC (rb_cairo_matrix_copy), 1);
- rb_define_method (rb_cCairo_Matrix, "set_identity",
- RUBY_METHOD_FUNC (rb_cairo_matrix_set_identity), 6);
- rb_define_method (rb_cCairo_Matrix, "set_affine",
- RUBY_METHOD_FUNC (rb_cairo_matrix_set_affine), 6);
+ rb_define_method (rb_cCairo_Matrix, "set",
+ RUBY_METHOD_FUNC (rb_cairo_matrix_set), 6);
+ rb_define_method (rb_cCairo_Matrix, "get",
+ RUBY_METHOD_FUNC (rb_cairo_matrix_get), 0);
+ rb_define_method (rb_cCairo_Matrix, "init_identity",
+ RUBY_METHOD_FUNC (rb_cairo_matrix_init_identity), 1);
rb_define_method (rb_cCairo_Matrix, "translate!",
RUBY_METHOD_FUNC (rb_cairo_matrix_translate), 2);
rb_define_method (rb_cCairo_Matrix, "scale!",
RUBY_METHOD_FUNC (rb_cairo_matrix_scale), 2);
rb_define_method (rb_cCairo_Matrix, "rotate!",
RUBY_METHOD_FUNC (rb_cairo_matrix_rotate), 2);
- rb_define_method (rb_cCairo_Matrix, "set_product",
- RUBY_METHOD_FUNC (rb_cairo_matrix_set_product), 3);
+ rb_define_method (rb_cCairo_Matrix, "multiply!",
+ RUBY_METHOD_FUNC (rb_cairo_matrix_multiply), 3);
+ rb_define_method (rb_cCairo_Matrix, "transform_point",
+ RUBY_METHOD_FUNC (rb_cairo_matrix_transform_point), 2);
rb_define_method (rb_cCairo_Matrix, "matrix_distance",
- RUBY_METHOD_FUNC (rb_cairo_matrix_translate), 2);
- rb_define_method (rb_cCairo_Matrix, "matrix_point",
- RUBY_METHOD_FUNC (rb_cairo_matrix_translate), 2);
- rb_define_method (rb_cCairo_Matrix, "get_affine",
- RUBY_METHOD_FUNC (rb_cairo_matrix_get_affine), 0);
+ RUBY_METHOD_FUNC (rb_cairo_matrix_transform_distance), 2);
}
Index: rb_cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_pattern.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rb_cairo_pattern.c 14 Feb 2005 23:51:54 -0000 1.2
+++ rb_cairo_pattern.c 23 Jun 2005 09:30:48 -0000 1.3
@@ -35,6 +35,7 @@
}
}
+#if 0
VALUE
rb_cairo_pattern_wrap (cairo_pattern_t *pat)
{
@@ -170,14 +171,14 @@
return INT2FIX (filter);
}
-
+#endif
void
Init_cairo_pattern (void)
{
rb_cCairo_Pattern =
rb_define_class_under (rb_mCairo, "Pattern", rb_cObject);
-
+#if 0
rb_define_singleton_method (rb_cCairo_Pattern, "create_linear",
RUBY_METHOD_FUNC (rb_cairo_pattern_create_linear), 4);
rb_define_singleton_method (rb_cCairo_Pattern, "create_radial",
@@ -200,4 +201,5 @@
RUBY_METHOD_FUNC (rb_cairo_pattern_set_filter), 1);
rb_define_method (rb_cCairo_Pattern, "get_filter",
RUBY_METHOD_FUNC (rb_cairo_pattern_get_filter), 0);
+#endif
}
Index: rb_cairo_surface.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_surface.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rb_cairo_surface.c 17 Mar 2005 16:02:57 -0000 1.2
+++ rb_cairo_surface.c 23 Jun 2005 09:30:48 -0000 1.3
@@ -114,7 +114,8 @@
}
}
-#ifdef CAIRO_HAS_PDF_SURFACE
+
+#if XXXCAIRO_HAS_PDF_SURFACE
static VALUE
rb_cairo_surface_new_pdf (VALUE klass,
VALUE port,
@@ -222,7 +223,7 @@
}
#endif
-#ifdef CAIRO_HAS_PS_SURFACE
+#ifdef XXXCAIRO_HAS_PS_SURFACE
static VALUE
rb_cairo_surface_new_ps (VALUE klass,
VALUE port,
@@ -268,6 +269,14 @@
}
#endif
+static VALUE
+rb_cairo_surface_write_to_png (VALUE self,
+ VALUE filename_v)
+{
+ cairo_surface_write_to_png (_SELF, STR2CSTR (filename_v));
+ return self;
+}
+
void
Init_cairo_surface (void)
{
@@ -276,10 +285,12 @@
rb_define_singleton_method (rb_cCairo_Surface, "new",
RUBY_METHOD_FUNC (rb_cairo_surface_new), 3);
+ rb_define_method (rb_cCairo_Surface, "write_to_png",
+ RUBY_METHOD_FUNC (rb_cairo_surface_write_to_png), 1);
rb_define_method (rb_cCairo_Surface, "finish",
RUBY_METHOD_FUNC (rb_cairo_surface_finish), 0);
-#ifdef CAIRO_HAS_PDF_SURFACE
+#if XXXCAIRO_HAS_PDF_SURFACE
rb_define_singleton_method (rb_cCairo_Surface, "new_pdf",
RUBY_METHOD_FUNC (rb_cairo_surface_new_pdf), 5);
#endif
@@ -289,7 +300,7 @@
RUBY_METHOD_FUNC (rb_cairo_surface_new_png), 4);
#endif
-#ifdef CAIRO_HAS_PS_SURFACE
+#ifdef XXXCAIRO_HAS_PS_SURFACE
rb_define_singleton_method (rb_cCairo_Surface, "new_ps",
RUBY_METHOD_FUNC (rb_cairo_surface_new_ps), 5);
#endif
- Previous message: [cairo-commit] rcairo/packages/cairo/lib cairo.rb,1.7,1.8
- Next message: [cairo-commit] rcairo/packages/cairo/ext rb_cairo_font.c, 1.1,
NONE rb_cairo_font.h, 1.1, NONE rb_cairo_font_face.c, NONE,
1.1 rb_cairo_font_face.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list