[cairo-commit] rcairo/packages/cairo/ext cairo.def, 1.3, 1.4 rb_cairo.h, 1.9, 1.10 rb_cairo_context.c, 1.12, 1.13 rb_cairo_pattern.c, 1.7, 1.8

Kouhei Sutou commit at pdx.freedesktop.org
Sat Oct 8 10:15:56 PDT 2005


Committed by: kou

Update of /cvs/cairo/rcairo/packages/cairo/ext
In directory gabe:/tmp/cvs-serv26112/packages/cairo/ext

Modified Files:
	cairo.def rb_cairo.h rb_cairo_context.c rb_cairo_pattern.c 
Log Message:
* packages/cairo/ext/rb_cairo_pattern.c: Implemented cairo_pattern_t.
* packages/cairo/ext/rb_cairo.c: ditto.
* packages/cairo/ext/rb_cairo.h: ditto.
* packages/cairo/ext/cairo.def: ditto.
* packages/cairo/lib/cairo.rb: ditto.
* packages/cairo/ext/rb_cairo_context.c: Followed the avobe changes.


Index: cairo.def
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/cairo.def,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- cairo.def	8 Oct 2005 14:01:42 -0000	1.3
+++ cairo.def	8 Oct 2005 17:15:54 -0000	1.4
@@ -1,16 +1,21 @@
 EXPORTS
     Init_cairo
-    rb_mCairo             DATA
-    rb_cCairo_Context     DATA
-    rb_cCairo_Path        DATA
-    rb_cCairo_Matrix      DATA
-    rb_cCairo_Pattern     DATA
-    rb_cCairo_FontFace    DATA
-    rb_cCairo_FontExtents DATA
-    rb_cCairo_FontOptions DATA
-    rb_cCairo_TextExtents DATA
-    rb_cCairo_Glyph       DATA
-    rb_cCairo_Surface     DATA
+    rb_mCairo                 DATA
+    rb_cCairo_Context         DATA
+    rb_cCairo_Path            DATA
+    rb_cCairo_Matrix          DATA
+    rb_cCairo_Pattern         DATA
+    rb_cCairo_SolidPattern    DATA
+    rb_cCairo_SurfacePattern  DATA
+    rb_cCairo_GradientPattern DATA
+    rb_cCairo_LinearPattern   DATA
+    rb_cCairo_RadialPattern   DATA
+    rb_cCairo_FontFace        DATA
+    rb_cCairo_FontExtents     DATA
+    rb_cCairo_FontOptions     DATA
+    rb_cCairo_TextExtents     DATA
+    rb_cCairo_Glyph           DATA
+    rb_cCairo_Surface         DATA
     rb_cairo_context_from_ruby_object
     rb_cairo_context_to_ruby_object
     rb_cairo_path_from_ruby_object
@@ -31,4 +36,3 @@
     rb_cairo_glyph_to_ruby_object
     rb_cairo_surface_from_ruby_object
     rb_cairo_surface_to_ruby_object
-    

Index: rb_cairo.h
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- rb_cairo.h	8 Oct 2005 14:01:42 -0000	1.9
+++ rb_cairo.h	8 Oct 2005 17:15:54 -0000	1.10
@@ -32,6 +32,11 @@
 RUBY_CAIRO_VAR VALUE rb_cCairo_Path;
 RUBY_CAIRO_VAR VALUE rb_cCairo_Matrix;
 RUBY_CAIRO_VAR VALUE rb_cCairo_Pattern;
+RUBY_CAIRO_VAR VALUE rb_cCairo_SolidPattern;
+RUBY_CAIRO_VAR VALUE rb_cCairo_SurfacePattern;
+RUBY_CAIRO_VAR VALUE rb_cCairo_GradientPattern;
+RUBY_CAIRO_VAR VALUE rb_cCairo_LinearPattern;
+RUBY_CAIRO_VAR VALUE rb_cCairo_RadialPattern;
 RUBY_CAIRO_VAR VALUE rb_cCairo_FontFace;
 RUBY_CAIRO_VAR VALUE rb_cCairo_FontExtents;
 RUBY_CAIRO_VAR VALUE rb_cCairo_FontOptions;
@@ -49,7 +54,7 @@
 #define CRMATRIX2RVAL(matrix)   (rb_cairo_matrix_to_ruby_object(matrix))
 
 #define RVAL2CRPATTERN(obj)     (rb_cairo_pattern_from_ruby_object(obj))
-#define CRPATTERN2RVAL(pattern) (rb_cairo_pattern_to_ruby_object(pattern))
+#define CRPATTERN2RVAL(pattern, klass) (rb_cairo_pattern_to_ruby_object(pattern, klass))
 
 #define RVAL2CRFONTFACE(obj)    (rb_cairo_font_face_from_ruby_object(obj))
 #define CRFONTFACE2RVAL(face)   (rb_cairo_font_face_to_ruby_object(face))
@@ -79,7 +84,7 @@
 VALUE                 rb_cairo_matrix_to_ruby_object         (cairo_matrix_t *matrix);
 
 cairo_pattern_t      *rb_cairo_pattern_from_ruby_object      (VALUE obj);
-VALUE                 rb_cairo_pattern_to_ruby_object        (cairo_pattern_t *pat);
+VALUE                 rb_cairo_pattern_to_ruby_object        (cairo_pattern_t *pat, VALUE klass);
 
 cairo_font_face_t    *rb_cairo_font_face_from_ruby_object    (VALUE obj);
 VALUE                 rb_cairo_font_face_to_ruby_object      (cairo_font_face_t *face);

Index: rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_context.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- rb_cairo_context.c	8 Oct 2005 14:41:40 -0000	1.12
+++ rb_cairo_context.c	8 Oct 2005 17:15:54 -0000	1.13
@@ -13,6 +13,8 @@
 
 VALUE rb_cCairo_Context;
 
+static ID cr_id_source_class;
+
 #define _SELF  (RVAL2CRCONTEXT(self))
 
 static VALUE
@@ -105,11 +107,11 @@
 }
 
 static VALUE
-cr_initialize (VALUE self, VALUE rb_target)
+cr_initialize (VALUE self, VALUE target)
 {
   cairo_t *cr;
 
-  cr = cairo_create (RVAL2CRSURFACE (rb_target));
+  cr = cairo_create (RVAL2CRSURFACE (target));
   cr_check_status (cr);
   DATA_PTR(self) = cr;
   return Qnil;
@@ -183,6 +185,7 @@
                         NUM2DBL (green),
                         NUM2DBL (blue));
   cr_check_status (_SELF);
+  rb_ivar_set (self, cr_id_source_class, rb_cCairo_SolidPattern);
   return self;
 }
 
@@ -219,6 +222,7 @@
                              NUM2DBL (blue),
                              NUM2DBL (alpha));
       cr_check_status (_SELF);
+      rb_ivar_set (self, cr_id_source_class, rb_cCairo_SolidPattern);
       return self;
     }
 }
@@ -231,6 +235,7 @@
                             NUM2INT (width),
                             NUM2INT (height));
   cr_check_status (_SELF);
+  rb_ivar_set (self, cr_id_source_class, rb_cCairo_SurfacePattern);
   return self;
 }
 
@@ -239,6 +244,7 @@
 {
   cairo_set_source (_SELF, RVAL2CRPATTERN (pattern));
   cr_check_status (_SELF);
+  rb_ivar_set (self, cr_id_source_class, rb_obj_class (pattern));
   return self;
 }
 
@@ -970,7 +976,16 @@
 static VALUE
 cr_get_source (VALUE self)
 {
-  return CRPATTERN2RVAL (cairo_get_source (_SELF));
+  cairo_pattern_t *source;
+  source = cairo_get_source (_SELF);
+
+  if (source)
+    {
+      rb_cairo_raise_exception (cairo_pattern_status (source));
+      return CRPATTERN2RVAL (source, rb_ivar_get (self, cr_id_source_class));
+    }
+  else
+    return Qnil;
 }
 
 static VALUE
@@ -1035,7 +1050,11 @@
 static VALUE
 cr_get_target (VALUE self)
 {
-  return CRSURFACE2RVAL (cairo_get_target (_SELF));
+  cairo_surface_t *surface;
+
+  surface = cairo_get_target (_SELF);
+  rb_cairo_raise_exception (cairo_surface_status (surface));
+  return CRSURFACE2RVAL (surface);
 }
 
 /* Paths */
@@ -1066,6 +1085,8 @@
 void
 Init_cairo_context (void)
 {
+  cr_id_source_class = rb_intern ("source_class");
+  
   rb_cCairo_Context =
     rb_define_class_under (rb_mCairo, "Context", rb_cObject);
 

Index: rb_cairo_pattern.c
===================================================================
RCS file: /cvs/cairo/rcairo/packages/cairo/ext/rb_cairo_pattern.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rb_cairo_pattern.c	7 Oct 2005 14:08:13 -0000	1.7
+++ rb_cairo_pattern.c	8 Oct 2005 17:15:54 -0000	1.8
@@ -12,8 +12,19 @@
 #include "rb_cairo.h"
 
 VALUE rb_cCairo_Pattern;
+VALUE rb_cCairo_SolidPattern;
+VALUE rb_cCairo_SurfacePattern;
+VALUE rb_cCairo_GradientPattern;
+VALUE rb_cCairo_LinearPattern;
+VALUE rb_cCairo_RadialPattern;
 
-#define _SELF  (RVAL2CRPATTERN(self))
+#define _SELF(self)  (RVAL2CRPATTERN(self))
+
+static inline void
+cr_pattern_check_status (cairo_pattern_t *pattern)
+{
+  rb_cairo_raise_exception (cairo_pattern_status (pattern));
+}
 
 cairo_pattern_t *
 rb_cairo_pattern_from_ruby_object (VALUE obj)
@@ -37,12 +48,12 @@
 }
 
 VALUE
-rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pat)
+rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pattern, VALUE klass)
 {
-  if (pat)
+  if (pattern)
     {
-      cairo_pattern_reference (pat);
-      return Data_Wrap_Struct (rb_cCairo_Pattern, NULL, cr_pattern_free, pat);
+      cairo_pattern_reference (pattern);
+      return Data_Wrap_Struct (klass, NULL, cr_pattern_free, pattern);
     }
   else
     {
@@ -50,156 +61,271 @@
     }
 }
 
-#if 0
-VALUE
-rb_cairo_pattern_create_linear (VALUE klass,
-                                VALUE x0_v, VALUE y0_v,
-                                VALUE x1_v, VALUE y1_v)
+static VALUE
+cr_pattern_allocate (VALUE klass)
 {
-  double x0 = NUM2DBL (x0_v);
-  double y0 = NUM2DBL (y0_v);
-  double x1 = NUM2DBL (x1_v);
-  double y1 = NUM2DBL (y1_v);
-
-  return rb_cairo_pattern_wrap (
-    cairo_pattern_create_linear (x0, y0, x1, y1));
+  return Data_Wrap_Struct (klass, NULL, cr_pattern_free, NULL);
 }
 
-VALUE
-rb_cairo_pattern_create_radial (VALUE klass,
-                                VALUE cx0_v, VALUE cy0_v, VALUE radius0_v,
-                                VALUE cx1_v, VALUE cy1_v, VALUE radius1_v)
+static VALUE
+cr_pattern_initialize (VALUE self)
 {
-  double cx0     = NUM2DBL (cx0_v);
-  double cy0     = NUM2DBL (cy0_v);
-  double radius0 = NUM2DBL (radius0_v);
-  double cx1     = NUM2DBL (cx1_v);
-  double cy1     = NUM2DBL (cy1_v);
-  double radius1 = NUM2DBL (radius1_v);
-
-  return rb_cairo_pattern_wrap (
-    cairo_pattern_create_radial (cx0, cy0, radius0,
-                                 cx1, cy1, radius1));
+  rb_raise (rb_eTypeError, "abstract class");
+  return Qnil;
 }
 
-VALUE
-rb_cairo_pattern_create_for_surface (VALUE klass,
-                                     VALUE surface_v)
+static VALUE
+cr_solid_pattern_initialize (int argc, VALUE *argv, VALUE self)
 {
+  VALUE red, green, blue, alpha;
+  int n;
+  cairo_pattern_t *pattern;
 
+  n = rb_scan_args (argc, argv, "13", &red, &green, &blue, &alpha);
+  
+  if (n == 1 && rb_obj_is_kind_of (red, rb_cArray) &&
+      (RARRAY (red)->len == 3 || RARRAY (red)->len == 4))
+    {
+      VALUE ary = red;
+      n = RARRAY (ary)->len;
+      
+      red = rb_ary_entry (ary, 0);
+      green = rb_ary_entry (ary, 1);
+      blue = rb_ary_entry (ary, 2);
+      alpha = rb_ary_entry (ary, 3);
+    }
 
-  return rb_cairo_pattern_wrap (
-     cairo_pattern_create_for_surface (rb_v_to_cairo_surface_t (surface_v)));
+  if (n == 3)
+    {
+      pattern = cairo_pattern_create_rgb (NUM2DBL (red),
+                                          NUM2DBL (green),
+                                          NUM2DBL (blue));
+    }
+  else if (n == 4)
+    {
+      pattern = cairo_pattern_create_rgba (NUM2DBL (red),
+                                           NUM2DBL (green),
+                                           NUM2DBL (blue),
+                                           NUM2DBL (alpha));
+    }
+  else
+    {
+      rb_raise (rb_eArgError,
+                "invalid argument (expect "
+                "(red, green, blue), "
+                "([red, green, blue]), "
+                "(red, green, blue, alpha) or "
+                "([red, green, blue, alpha])"
+                ")");
+    }
+  
+  cr_pattern_check_status (pattern);
+  DATA_PTR (self) = pattern;
+  return Qnil;
 }
 
+static VALUE
+cr_surface_pattern_initialize (VALUE self, VALUE surface)
+{
+  cairo_pattern_t *pattern;
+
+  pattern = cairo_pattern_create_for_surface (RVAL2CRSURFACE (surface));
+  cr_pattern_check_status (pattern);
+  DATA_PTR (self) = pattern;
+  return Qnil;
+}
 
-VALUE
-rb_cairo_pattern_add_color_stop (VALUE self,
-                                 VALUE offset_v,
-                                 VALUE red_v,
-                                 VALUE green_v,
-                                 VALUE blue_v,
-                                 VALUE alpha_v)
+static VALUE
+cr_linear_pattern_initialize (VALUE self, VALUE x0, VALUE y0,
+                              VALUE x1, VALUE y1)
 {
-  double offset = NUM2DBL (offset_v);
-  double red    = NUM2DBL (red_v);
-  double green  = NUM2DBL (green_v);
-  double blue   = NUM2DBL (blue_v);
-  double alpha  = NUM2DBL (alpha_v);
+  cairo_pattern_t *pattern;
 
-  cairo_pattern_add_color_stop (_SELF, offset, red, green, blue, alpha);
-  return self;
+  pattern = cairo_pattern_create_linear (NUM2DBL (x0), NUM2DBL (y0),
+                                         NUM2DBL (x1), NUM2DBL (y1));
+  cr_pattern_check_status (pattern);
+  DATA_PTR (self) = pattern;
+  return Qnil;
 }
 
-VALUE
-rb_cairo_pattern_set_matrix (VALUE self,
-                             VALUE matrix_v)
+static VALUE
+cr_radial_pattern_initialize (VALUE self, VALUE cx0, VALUE cy0, VALUE radius0,
+                              VALUE cx1, VALUE cy1, VALUE radius1)
 {
-  cairo_pattern_set_matrix (_SELF, rb_v_to_cairo_matrix_t (matrix_v));
-  return self;
+  cairo_pattern_t *pattern;
+
+  pattern = cairo_pattern_create_radial (NUM2DBL (cx0), NUM2DBL (cy0),
+                                         NUM2DBL (radius0),
+                                         NUM2DBL (cx1), NUM2DBL (cy1),
+                                         NUM2DBL (radius1));
+  cr_pattern_check_status (pattern);
+  DATA_PTR (self) = pattern;
+  return Qnil;
 }
 
-VALUE
-rb_cairo_pattern_get_matrix (VALUE self)
+/* Cairo::GradientPattern */
+static VALUE
+cr_gradient_pattern_add_color_stop (int argc, VALUE *argv, VALUE self)
 {
-  cairo_matrix_t *matrix = cairo_matrix_create ();
+  VALUE offset, red, green, blue, alpha;
+  int n;
+  
+  n = rb_scan_args (argc, argv, "23", &offset, &red, &green, &blue, &alpha);
 
-  if (matrix)
+  if (n == 2 && rb_obj_is_kind_of (red, rb_cArray) &&
+      (RARRAY (red)->len == 3 || RARRAY (red)->len == 4))
     {
-      cairo_pattern_get_matrix (_SELF, matrix);
-      return rb_cairo_matrix_wrap (matrix);
+      VALUE ary = red;
+      n = RARRAY (ary)->len;
+      
+      red = rb_ary_entry (ary, 0);
+      green = rb_ary_entry (ary, 1);
+      blue = rb_ary_entry (ary, 2);
+      alpha = rb_ary_entry (ary, 3);
+    }
+
+  if (n == 3)
+    {
+      cairo_pattern_add_color_stop_rgb (_SELF (self), NUM2DBL (offset),
+                                        NUM2DBL (red), NUM2DBL (green),
+                                        NUM2DBL (blue));
+    }
+  else if (n == 4)
+    {
+      cairo_pattern_add_color_stop_rgba (_SELF (self), NUM2DBL (offset),
+                                         NUM2DBL (red), NUM2DBL (green),
+                                         NUM2DBL (blue), NUM2DBL (alpha));
     }
   else
     {
-      rb_raise (rb_eNoMemError, "matrix problem");
+      rb_raise (rb_eArgError,
+                "invalid argument (expect "
+                "(offset, red, green, blue), "
+                "(offset, [red, green, blue]), "
+                "(offset, red, green, blue, alpha) or "
+                "(offset, [red, green, blue, alpha])"
+                ")");
     }
+
+  cr_pattern_check_status (_SELF (self));
+  return self;
 }
 
+
+/* Cairo::Pattern */
 static VALUE
-rb_cairo_pattern_set_extend (VALUE self,
-                             VALUE extend_v)
+cr_pattern_set_matrix (VALUE self, VALUE matrix)
 {
-  cairo_extend_t extend = FIX2INT (extend_v);
-  if (extend < CAIRO_EXTEND_NONE || extend > CAIRO_EXTEND_REFLECT)
-    rb_raise (rb_eArgError, "invalide pattern extend type");
-  cairo_pattern_set_extend (_SELF, extend);
-  return self; 
+  cairo_pattern_set_matrix (_SELF (self), RVAL2CRMATRIX (matrix));
+  cr_pattern_check_status (_SELF (self));
+  return self;
 }
 
 static VALUE
-rb_cairo_pattern_get_extend (VALUE self)
+cr_pattern_get_matrix (VALUE self)
 {
-  cairo_extend_t extend = cairo_pattern_get_extend (_SELF);
-  return INT2FIX (extend);
+  cairo_matrix_t matrix;
+  cairo_pattern_get_matrix (_SELF (self), &matrix);
+  cr_pattern_check_status (_SELF (self));
+  return CRMATRIX2RVAL (&matrix);
 }
 
+/* Cairo::SurfacePattern */
 static VALUE
-rb_cairo_pattern_set_filter (VALUE self,
-                             VALUE filter_v)
+cr_surface_pattern_set_extend (VALUE self, VALUE rb_extend)
 {
-  cairo_filter_t filter = FIX2INT (filter_v);
-  if (filter < CAIRO_FILTER_FAST || filter > CAIRO_FILTER_GAUSSIAN)
-    rb_raise (rb_eArgError, "invalide pattern filter type");
-  cairo_pattern_set_filter (_SELF, filter);
-  return self; 
+  cairo_extend_t extend;
+  extend = NUM2INT (rb_extend);
+  if (extend < CAIRO_EXTEND_NONE ||
+      extend > CAIRO_EXTEND_REFLECT)
+    {
+      rb_raise (rb_eArgError, "invalide pattern extend type");
+    }
+
+  cairo_pattern_set_extend (_SELF (self), extend);
+  cr_pattern_check_status (_SELF (self));
+  return self;
 }
 
 static VALUE
-rb_cairo_pattern_get_filter (VALUE self)
+cr_surface_pattern_get_extend (VALUE self)
 {
-  cairo_filter_t filter = cairo_pattern_get_filter (_SELF);
-  return INT2FIX (filter);
+  return INT2NUM (cairo_pattern_get_extend (_SELF (self)));
 }
 
-#endif
+static VALUE
+cr_surface_pattern_set_filter (VALUE self, VALUE rb_filter)
+{
+  cairo_filter_t filter;
+  filter = NUM2INT (rb_filter);
+  if (filter < CAIRO_FILTER_FAST ||
+      filter > CAIRO_FILTER_GAUSSIAN)
+    {
+      rb_raise (rb_eArgError, "invalide pattern filter type");
+    }
+
+  cairo_pattern_set_filter (_SELF (self), filter);
+  cr_pattern_check_status (_SELF (self));
+  return self;
+}
+
+static VALUE
+cr_surface_pattern_get_filter (VALUE self)
+{
+  return INT2NUM (cairo_pattern_get_filter (_SELF (self)));
+}
 
 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",
-    RUBY_METHOD_FUNC (rb_cairo_pattern_create_radial), 6);
- 
-  rb_define_method (rb_cCairo_Pattern, "add_color_stop",
-    RUBY_METHOD_FUNC (rb_cairo_pattern_add_color_stop), 5);
 
-  rb_define_method (rb_cCairo_Pattern, "set_matrix",
-    RUBY_METHOD_FUNC (rb_cairo_pattern_set_matrix), 1);
-  rb_define_method (rb_cCairo_Pattern, "get_matrix",
-    RUBY_METHOD_FUNC (rb_cairo_pattern_get_matrix), 0);
-    
-  rb_define_method (rb_cCairo_Pattern, "set_extend",
-    RUBY_METHOD_FUNC (rb_cairo_pattern_set_extend), 1);
-  rb_define_method (rb_cCairo_Pattern, "get_extend",
-    RUBY_METHOD_FUNC (rb_cairo_pattern_get_extend), 0);
+  rb_define_alloc_func (rb_cCairo_Pattern, cr_pattern_allocate);
 
-  rb_define_method (rb_cCairo_Pattern, "set_filter",
-    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
+  rb_define_method (rb_cCairo_Pattern, "initialize", cr_pattern_initialize, 0);
+  
+  rb_define_method (rb_cCairo_Pattern, "set_matrix", cr_pattern_set_matrix, 1);
+  rb_define_method (rb_cCairo_Pattern, "matrix", cr_pattern_get_matrix, 0);
+  
+  rb_cCairo_SolidPattern =
+    rb_define_class_under (rb_mCairo, "SolidPattern", rb_cCairo_Pattern);
+
+  rb_define_method (rb_cCairo_SolidPattern, "initialize",
+                    cr_solid_pattern_initialize, -1);
+
+  rb_cCairo_SurfacePattern =
+    rb_define_class_under (rb_mCairo, "SurfacePattern", rb_cCairo_Pattern);
+  
+  rb_define_method (rb_cCairo_SurfacePattern, "initialize",
+                    cr_surface_pattern_initialize, 1);
+
+  rb_define_method (rb_cCairo_SurfacePattern, "set_extend",
+                    cr_surface_pattern_set_extend, 1);
+  rb_define_method (rb_cCairo_SurfacePattern, "extend",
+                    cr_surface_pattern_get_extend, 0);
+  rb_define_method (rb_cCairo_SurfacePattern, "set_filter",
+                    cr_surface_pattern_set_filter, 1);
+  rb_define_method (rb_cCairo_SurfacePattern, "filter",
+                    cr_surface_pattern_get_filter, 0);
+
+  rb_cCairo_GradientPattern =
+    rb_define_class_under (rb_mCairo, "GradientPattern", rb_cCairo_Pattern);
+
+  rb_define_method (rb_cCairo_GradientPattern, "add_color_stop",
+                    cr_gradient_pattern_add_color_stop, -1);
+
+  rb_cCairo_LinearPattern =
+    rb_define_class_under (rb_mCairo, "LinearPattern",
+                           rb_cCairo_GradientPattern);
+
+  rb_define_method (rb_cCairo_LinearPattern, "initialize",
+                    cr_linear_pattern_initialize, 4);
+
+  rb_cCairo_RadialPattern =
+    rb_define_class_under (rb_mCairo, "RadialPattern",
+                           rb_cCairo_GradientPattern);
+
+  rb_define_method (rb_cCairo_RadialPattern, "initialize",
+                    cr_radial_pattern_initialize, 6);
 }



More information about the cairo-commit mailing list