cairo 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cairo might be problematic. Click here for more details.

@@ -0,0 +1,21 @@
1
+ module Cairo
2
+ define_constants = Proc.new do |const_module, prefix, target|
3
+ target ||= self
4
+ const_module.constants.each do |const_name|
5
+ target.const_set([prefix, const_name].compact.join("_"),
6
+ const_module.const_get(const_name))
7
+ end
8
+ end
9
+
10
+ %w(operator antialias fill_rule line_cap line_join font_slant
11
+ font_weight subpixel_order hint_style hint_metrics content
12
+ format extend filter).each do |name|
13
+ module_name = name.split(/_/).collect {|component| component.capitalize}.join
14
+ define_constants.call(const_get(module_name), name.upcase)
15
+ end
16
+
17
+ define_constants.call(PathDataType, "PATH")
18
+ define_constants.call(PathDataType, nil, Path)
19
+ define_constants.call(SVGVersion, nil, SVGSurface)
20
+ define_constants.call(SVGVersion, "SVG")
21
+ end
@@ -1,13 +1,27 @@
1
- require 'cairo/context/quad'
2
1
  require 'cairo/context/rectangle'
3
2
  require 'cairo/context/circle'
4
3
  require 'cairo/context/path'
4
+ require 'cairo/context/blur'
5
+ require 'cairo/context/color'
5
6
 
6
7
  module Cairo
7
8
  class Context
8
- include Quad
9
9
  include Rectangle
10
10
  include Circle
11
11
  include Path
12
+ include Blur
13
+ include Color
14
+
15
+ def stroke_preserve(&block)
16
+ stroke(true, &block)
17
+ end
18
+
19
+ def fill_preserve(&block)
20
+ fill(true, &block)
21
+ end
22
+
23
+ def clip_preserve(&block)
24
+ clip(true, &block)
25
+ end
12
26
  end
13
27
  end
@@ -0,0 +1,45 @@
1
+ module Cairo
2
+ class Context
3
+ module Blur
4
+ def pseudo_blur(radius=3, &block)
5
+ raise ArgumentError, "should specify block" if block.nil?
6
+ pattern = push_group(Cairo::CONTENT_COLOR_ALPHA, false, &block)
7
+
8
+ save do
9
+ set_source(pattern)
10
+ paint(0.5)
11
+ end
12
+
13
+ 1.step(radius, 1) do |i|
14
+ opacity = 0.075 - 0.005 * i
15
+ next if opacity <= 0
16
+ 5.downto(1) do |ratio|
17
+ r = i / ratio.to_f
18
+ r_13 = r / 3.0
19
+ r_23 = 2 * r_13
20
+ [
21
+ [-r, 0],
22
+ [-r_23, r_23],
23
+ [-r_23, r_13],
24
+ [0, r],
25
+ [r_13, r_23],
26
+ [r_23, r_23],
27
+ [r, 0],
28
+ [r_23, -r_13],
29
+ [r_23, -r_23],
30
+ [0, -r],
31
+ [-r_13, -r_23],
32
+ [-r_23, -r_23],
33
+ ].each do |x, y|
34
+ save do
35
+ translate(x, y)
36
+ set_source(pattern)
37
+ paint(opacity)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,8 +1,8 @@
1
1
  module Cairo
2
2
  class Context
3
3
  module Circle
4
- def circle(x, y, radius)
5
- arc(x, y, radius, 0, 2 * Math::PI)
4
+ def circle(center_x, center_y, radius)
5
+ arc(center_x, center_y, radius, 0, 2 * Math::PI)
6
6
  end
7
7
  end
8
8
  end
@@ -0,0 +1,11 @@
1
+ require 'cairo/color'
2
+
3
+ module Cairo
4
+ class Context
5
+ module Color
6
+ def set_source_color(color)
7
+ set_source_rgba(*Cairo::Color.parse(color).to_rgb.to_a)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,32 +1,21 @@
1
1
  module Cairo
2
2
  class Context
3
3
  module Path
4
- module Point
5
- module_function
6
- def distance(a, b)
7
- ax, ay = a
8
- bx, by = b
9
- Math.sqrt((bx - ax) ** 2 + (by - ay) ** 2)
10
- end
11
- end
12
-
13
4
  def transform_path(path, &block)
14
- save do
15
- new_path
16
- path.each do |type, points|
17
- case type
18
- when PATH_CURVE_TO
19
- curve_to(*points.collect(&block).flatten)
20
- when PATH_MOVE_TO
21
- move_to(*points.collect(&block).flatten)
22
- when PATH_LINE_TO
23
- line_to(*points.collect(&block).flatten)
24
- when PATH_CLOSE_PATH
25
- close_path
26
- end
5
+ transformed_path = Cairo::Path.new
6
+ path.each do |type, points|
7
+ case type
8
+ when PATH_MOVE_TO
9
+ transformed_path.move_to(*points.collect(&block).flatten)
10
+ when PATH_LINE_TO
11
+ transformed_path.line_to(*points.collect(&block).flatten)
12
+ when PATH_CURVE_TO
13
+ transformed_path.curve_to(*points.collect(&block).flatten)
14
+ when PATH_CLOSE_PATH
15
+ transformed_path.close
27
16
  end
28
- copy_path
29
17
  end
18
+ transformed_path
30
19
  end
31
20
 
32
21
  def map_path_onto(path)
@@ -38,7 +27,7 @@ module Cairo
38
27
  type = points = nil
39
28
  path.each do |type, points|
40
29
  i += 1
41
- break if d <= parameterized_path[i]
30
+ break if d < parameterized_path[i]
42
31
  d -= parameterized_path[i]
43
32
  case type
44
33
  when PATH_MOVE_TO
@@ -110,12 +99,12 @@ module Cairo
110
99
  when PATH_MOVE_TO
111
100
  current_point = points[0]
112
101
  when PATH_LINE_TO
113
- result = Point.distance(current_point, points[0])
102
+ result = current_point.distance(points[0])
114
103
  current_point = points[0]
115
104
  when PATH_CURVE_TO
116
- result = Point.distance(current_point, points[0])
117
- result += Point.distance(points[0], points[1])
118
- result += Point.distance(points[1], points[2])
105
+ result = current_point.distance(points[0])
106
+ result += points[0].distance(points[1])
107
+ result += points[1].distance(points[2])
119
108
  current_point = points[2]
120
109
  when PATH_CLOSE_PATH
121
110
  end
@@ -0,0 +1,15 @@
1
+ require 'forwardable'
2
+
3
+ module Cairo
4
+ class Path
5
+ extend Forwardable
6
+ methods = %w(new_path new_sub_path move_to line_to curve_to
7
+ arc arc_negative rel_move_to rel_line_to rel_curve_to
8
+ rectangle rounded_rectangle circle)
9
+ def_delegators :@context, *methods
10
+
11
+ def close
12
+ @context.close_path
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ module Cairo
2
+ class Point
3
+ def distance(other)
4
+ Math.sqrt((other.x - x) ** 2 + (other.y - y) ** 2)
5
+ end
6
+ end
7
+ end
@@ -3,7 +3,7 @@
3
3
  * Ruby Cairo Binding
4
4
  *
5
5
  * $Author: kou $
6
- * $Date: 2007/03/10 11:54:17 $
6
+ * $Date: 2007/05/23 02:26:24 $
7
7
  *
8
8
  * Copyright 2006-2007 Kouhei Sutou <kou@cozmixng.org>
9
9
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
@@ -15,22 +15,9 @@
15
15
 
16
16
 
17
17
  #include "rb_cairo.h"
18
+ #include "rb_cairo_private.h"
18
19
 
19
- VALUE rb_mCairo;
20
-
21
- extern void Init_cairo_context (void);
22
- extern void Init_cairo_path (void);
23
- extern void Init_cairo_matrix (void);
24
- extern void Init_cairo_surface (void);
25
- extern void Init_cairo_constants (void);
26
- extern void Init_cairo_exception (void);
27
- extern void Init_cairo_font (void);
28
- extern void Init_cairo_font_extents (void);
29
- extern void Init_cairo_font_options (void);
30
- extern void Init_cairo_scaled_font (void);
31
- extern void Init_cairo_text_extents (void);
32
- extern void Init_cairo_pattern (void);
33
- extern void Init_cairo_glyph (void);
20
+ VALUE rb_mCairo, rb_mCairo_Color, rb_cCairo_Color_Base;
34
21
 
35
22
  static ID id__add_one_arg_setter;
36
23
 
@@ -71,8 +58,12 @@ Init_cairo ()
71
58
 
72
59
  rb_define_const (rb_mCairo, "BINDINGS_VERSION",
73
60
  rb_ary_new3 (4,
74
- INT2FIX (1), INT2FIX (4), INT2FIX (1), Qnil));
61
+ INT2FIX (1), INT2FIX (5), INT2FIX (0), Qnil));
75
62
 
63
+ rb_mCairo_Color = rb_const_get (rb_mCairo, rb_intern ("Color"));
64
+ rb_cCairo_Color_Base = rb_const_get (rb_mCairo_Color, rb_intern ("Base"));
65
+
66
+ Init_cairo_private ();
76
67
  Init_cairo_constants ();
77
68
 
78
69
  Init_cairo_context ();
@@ -3,7 +3,7 @@
3
3
  * Ruby Cairo Binding
4
4
  *
5
5
  * $Author: kou $
6
- * $Date: 2007/03/06 12:17:34 $
6
+ * $Date: 2007/05/22 11:25:39 $
7
7
  *
8
8
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
9
9
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
@@ -30,6 +30,12 @@
30
30
  # include <cairo-svg.h>
31
31
  #endif
32
32
 
33
+ #if CAIRO_HAS_WIN32_SURFACE
34
+ # define OpenFile OpenFile_win32
35
+ # include <cairo-win32.h>
36
+ # undef OpenFile
37
+ #endif
38
+
33
39
  #define CAIRO_CHECK_VERSION(major, minor, micro) \
34
40
  (CAIRO_VERSION_MAJOR > (major) || \
35
41
  (CAIRO_VERSION_MAJOR == (major) && CAIRO_VERSION_MINOR > (minor)) || \
@@ -50,7 +56,13 @@
50
56
 
51
57
  RUBY_CAIRO_VAR VALUE rb_mCairo;
52
58
  RUBY_CAIRO_VAR VALUE rb_cCairo_Context;
59
+ RUBY_CAIRO_VAR VALUE rb_cCairo_Point;
53
60
  RUBY_CAIRO_VAR VALUE rb_cCairo_Path;
61
+ RUBY_CAIRO_VAR VALUE rb_cCairo_PathData;
62
+ RUBY_CAIRO_VAR VALUE rb_cCairo_PathMoveTo;
63
+ RUBY_CAIRO_VAR VALUE rb_cCairo_PathLineTo;
64
+ RUBY_CAIRO_VAR VALUE rb_cCairo_PathCurveTo;
65
+ RUBY_CAIRO_VAR VALUE rb_cCairo_PathClosePath;
54
66
  RUBY_CAIRO_VAR VALUE rb_cCairo_Matrix;
55
67
  RUBY_CAIRO_VAR VALUE rb_cCairo_Pattern;
56
68
  RUBY_CAIRO_VAR VALUE rb_cCairo_SolidPattern;
@@ -65,6 +77,35 @@ RUBY_CAIRO_VAR VALUE rb_cCairo_ScaledFont;
65
77
  RUBY_CAIRO_VAR VALUE rb_cCairo_TextExtents;
66
78
  RUBY_CAIRO_VAR VALUE rb_cCairo_Glyph;
67
79
  RUBY_CAIRO_VAR VALUE rb_cCairo_Surface;
80
+ RUBY_CAIRO_VAR VALUE rb_cCairo_ImageSurface;
81
+ RUBY_CAIRO_VAR VALUE rb_cCairo_PDFSurface;
82
+ RUBY_CAIRO_VAR VALUE rb_cCairo_PSSurface;
83
+ RUBY_CAIRO_VAR VALUE rb_cCairo_SVGSurface;
84
+ RUBY_CAIRO_VAR VALUE rb_cCairo_WIN32Surface;
85
+
86
+ RUBY_CAIRO_VAR VALUE rb_mCairo_Operator;
87
+ RUBY_CAIRO_VAR VALUE rb_mCairo_Antialias;
88
+ RUBY_CAIRO_VAR VALUE rb_mCairo_FillRule;
89
+ RUBY_CAIRO_VAR VALUE rb_mCairo_LineCap;
90
+ RUBY_CAIRO_VAR VALUE rb_mCairo_LineJoin;
91
+ RUBY_CAIRO_VAR VALUE rb_mCairo_FontSlant;
92
+ RUBY_CAIRO_VAR VALUE rb_mCairo_FontWeight;
93
+ RUBY_CAIRO_VAR VALUE rb_mCairo_SubpixelOrder;
94
+ RUBY_CAIRO_VAR VALUE rb_mCairo_HintStyle;
95
+ RUBY_CAIRO_VAR VALUE rb_mCairo_HintMetrics;
96
+ RUBY_CAIRO_VAR VALUE rb_mCairo_FontType;
97
+ RUBY_CAIRO_VAR VALUE rb_mCairo_PathDataType;
98
+ RUBY_CAIRO_VAR VALUE rb_mCairo_Content;
99
+ RUBY_CAIRO_VAR VALUE rb_mCairo_SurfaceType;
100
+ RUBY_CAIRO_VAR VALUE rb_mCairo_Format;
101
+ RUBY_CAIRO_VAR VALUE rb_mCairo_PatternType;
102
+ RUBY_CAIRO_VAR VALUE rb_mCairo_Extend;
103
+ RUBY_CAIRO_VAR VALUE rb_mCairo_Filter;
104
+ RUBY_CAIRO_VAR VALUE rb_mCairo_SVGVersion;
105
+
106
+ RUBY_CAIRO_VAR VALUE rb_mCairo_Color;
107
+ RUBY_CAIRO_VAR VALUE rb_cCairo_Color_Base;
108
+
68
109
 
69
110
  #define RVAL2CRCONTEXT(obj) (rb_cairo_context_from_ruby_object(obj))
70
111
  #define CRCONTEXT2RVAL(cr) (rb_cairo_context_to_ruby_object(cr))
@@ -76,7 +117,7 @@ RUBY_CAIRO_VAR VALUE rb_cCairo_Surface;
76
117
  #define CRMATRIX2RVAL(matrix) (rb_cairo_matrix_to_ruby_object(matrix))
77
118
 
78
119
  #define RVAL2CRPATTERN(obj) (rb_cairo_pattern_from_ruby_object(obj))
79
- #define CRPATTERN2RVAL(pattern, klass) (rb_cairo_pattern_to_ruby_object(pattern, klass))
120
+ #define CRPATTERN2RVAL(pattern) (rb_cairo_pattern_to_ruby_object(pattern))
80
121
 
81
122
  #define RVAL2CRFONTFACE(obj) (rb_cairo_font_face_from_ruby_object(obj))
82
123
  #define CRFONTFACE2RVAL(face) (rb_cairo_font_face_to_ruby_object(face))
@@ -109,7 +150,7 @@ cairo_matrix_t *rb_cairo_matrix_from_ruby_object (VALUE obj);
109
150
  VALUE rb_cairo_matrix_to_ruby_object (cairo_matrix_t *matrix);
110
151
 
111
152
  cairo_pattern_t *rb_cairo_pattern_from_ruby_object (VALUE obj);
112
- VALUE rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pat, VALUE klass);
153
+ VALUE rb_cairo_pattern_to_ruby_object (cairo_pattern_t *pat);
113
154
 
114
155
  cairo_font_face_t *rb_cairo_font_face_from_ruby_object (VALUE obj);
115
156
  VALUE rb_cairo_font_face_to_ruby_object (cairo_font_face_t *face);
@@ -3,7 +3,7 @@
3
3
  * Ruby Cairo Binding
4
4
  *
5
5
  * $Author: kou $
6
- * $Date: 2007/03/06 12:17:34 $
6
+ * $Date: 2007/05/20 09:18:49 $
7
7
  *
8
8
  * Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
9
9
  * Copyright 2004-2005 MenTaLguY <mental@rydia.com>
@@ -14,6 +14,24 @@
14
14
 
15
15
 
16
16
  #include "rb_cairo.h"
17
+ #include "rb_cairo_private.h"
18
+
19
+ VALUE rb_mCairo_Operator;
20
+ VALUE rb_mCairo_Antialias;
21
+ VALUE rb_mCairo_FillRule;
22
+ VALUE rb_mCairo_LineCap;
23
+ VALUE rb_mCairo_LineJoin;
24
+ VALUE rb_mCairo_FontSlant;
25
+ VALUE rb_mCairo_FontWeight;
26
+ VALUE rb_mCairo_SubpixelOrder;
27
+ VALUE rb_mCairo_HintStyle;
28
+ VALUE rb_mCairo_HintMetrics;
29
+ VALUE rb_mCairo_PathDataType;
30
+ VALUE rb_mCairo_Content;
31
+ VALUE rb_mCairo_Format;
32
+ VALUE rb_mCairo_Extend;
33
+ VALUE rb_mCairo_Filter;
34
+ VALUE rb_mCairo_SVGVersion;
17
35
 
18
36
  #define CAIRO_OPERATOR_MIN CAIRO_OPERATOR_CLEAR
19
37
  #define CAIRO_OPERATOR_MAX CAIRO_OPERATOR_SATURATE
@@ -63,23 +81,28 @@
63
81
  #define CAIRO_SVG_VERSION_MIN CAIRO_SVG_VERSION_1_1
64
82
  #define CAIRO_SVG_VERSION_MAX CAIRO_SVG_VERSION_1_2
65
83
 
66
- #define DEFINE_RVAL2ENUM(name, const_name) \
67
- cairo_ ## name ## _t \
68
- rb_cairo_ ## name ## _from_ruby_object (VALUE rb_ ## name) \
69
- { \
70
- cairo_ ## name ## _t name; \
71
- name = FIX2INT (rb_ ## name); \
72
- if (name < CAIRO_ ## const_name ## _MIN || \
73
- name > CAIRO_ ## const_name ## _MAX) \
74
- { \
75
- rb_raise (rb_eArgError, \
76
- "invalid %s: %d (expect %d <= %s <= %d)", \
77
- #name, name, \
78
- CAIRO_ ## const_name ## _MIN, \
79
- #name, \
80
- CAIRO_ ## const_name ## _MAX); \
81
- } \
82
- return name; \
84
+ #define DEFINE_RVAL2ENUM(name, const_name) \
85
+ cairo_ ## name ## _t \
86
+ rb_cairo_ ## name ## _from_ruby_object (VALUE rb_ ## name) \
87
+ { \
88
+ cairo_ ## name ## _t name; \
89
+ \
90
+ if (!rb_cairo__is_kind_of (rb_ ## name, rb_cNumeric)) \
91
+ rb_ ## name = rb_cairo__const_get (rb_ ## name, \
92
+ # const_name "_"); \
93
+ \
94
+ name = FIX2INT (rb_ ## name); \
95
+ if (name < CAIRO_ ## const_name ## _MIN || \
96
+ name > CAIRO_ ## const_name ## _MAX) \
97
+ { \
98
+ rb_raise (rb_eArgError, \
99
+ "invalid %s: %d (expect %d <= %s <= %d)", \
100
+ #name, name, \
101
+ CAIRO_ ## const_name ## _MIN, \
102
+ #name, \
103
+ CAIRO_ ## const_name ## _MAX); \
104
+ } \
105
+ return name; \
83
106
  }
84
107
 
85
108
  DEFINE_RVAL2ENUM(operator, OPERATOR)
@@ -105,238 +128,207 @@ void
105
128
  Init_cairo_constants (void)
106
129
  {
107
130
  /* cairo_operator_t */
108
- rb_define_const (rb_mCairo, "OPERATOR_CLEAR",
131
+ rb_mCairo_Operator = rb_define_module_under (rb_mCairo, "Operator");
132
+ rb_define_const (rb_mCairo_Operator, "CLEAR",
109
133
  INT2FIX (CAIRO_OPERATOR_CLEAR));
110
134
 
111
- rb_define_const (rb_mCairo, "OPERATOR_SOURCE",
135
+ rb_define_const (rb_mCairo_Operator, "SOURCE",
112
136
  INT2FIX (CAIRO_OPERATOR_SOURCE));
113
- rb_define_const (rb_mCairo, "OPERATOR_OVER",
137
+ rb_define_const (rb_mCairo_Operator, "OVER",
114
138
  INT2FIX (CAIRO_OPERATOR_OVER));
115
- rb_define_const (rb_mCairo, "OPERATOR_IN",
139
+ rb_define_const (rb_mCairo_Operator, "IN",
116
140
  INT2FIX (CAIRO_OPERATOR_IN));
117
- rb_define_const (rb_mCairo, "OPERATOR_OUT",
141
+ rb_define_const (rb_mCairo_Operator, "OUT",
118
142
  INT2FIX (CAIRO_OPERATOR_OUT));
119
- rb_define_const (rb_mCairo, "OPERATOR_ATOP",
143
+ rb_define_const (rb_mCairo_Operator, "ATOP",
120
144
  INT2FIX (CAIRO_OPERATOR_ATOP));
121
-
122
- rb_define_const (rb_mCairo, "OPERATOR_DEST",
145
+
146
+ rb_define_const (rb_mCairo_Operator, "DEST",
123
147
  INT2FIX (CAIRO_OPERATOR_DEST));
124
- rb_define_const (rb_mCairo, "OPERATOR_DEST_OVER",
148
+ rb_define_const (rb_mCairo_Operator, "DEST_OVER",
125
149
  INT2FIX (CAIRO_OPERATOR_DEST_OVER));
126
- rb_define_const (rb_mCairo, "OPERATOR_DEST_IN",
150
+ rb_define_const (rb_mCairo_Operator, "DEST_IN",
127
151
  INT2FIX (CAIRO_OPERATOR_DEST_IN));
128
- rb_define_const (rb_mCairo, "OPERATOR_DEST_OUT",
152
+ rb_define_const (rb_mCairo_Operator, "DEST_OUT",
129
153
  INT2FIX (CAIRO_OPERATOR_DEST_OUT));
130
- rb_define_const (rb_mCairo, "OPERATOR_DEST_ATOP",
154
+ rb_define_const (rb_mCairo_Operator, "DEST_ATOP",
131
155
  INT2FIX (CAIRO_OPERATOR_DEST_ATOP));
132
156
 
133
- rb_define_const (rb_mCairo, "OPERATOR_XOR",
157
+ rb_define_const (rb_mCairo_Operator, "XOR",
134
158
  INT2FIX (CAIRO_OPERATOR_XOR));
135
- rb_define_const (rb_mCairo, "OPERATOR_ADD",
159
+ rb_define_const (rb_mCairo_Operator, "ADD",
136
160
  INT2FIX (CAIRO_OPERATOR_ADD));
137
- rb_define_const (rb_mCairo, "OPERATOR_SATURATE",
161
+ rb_define_const (rb_mCairo_Operator, "SATURATE",
138
162
  INT2FIX (CAIRO_OPERATOR_SATURATE));
139
163
 
140
-
164
+
141
165
  /* cairo_antialias_t */
142
- rb_define_const (rb_mCairo, "ANTIALIAS_DEFAULT",
166
+ rb_mCairo_Antialias = rb_define_module_under (rb_mCairo, "Antialias");
167
+ rb_define_const (rb_mCairo_Antialias, "DEFAULT",
143
168
  INT2FIX (CAIRO_ANTIALIAS_DEFAULT));
144
- rb_define_const (rb_mCairo, "ANTIALIAS_NONE",
169
+ rb_define_const (rb_mCairo_Antialias, "NONE",
145
170
  INT2FIX (CAIRO_ANTIALIAS_NONE));
146
- rb_define_const (rb_mCairo, "ANTIALIAS_GRAY",
171
+ rb_define_const (rb_mCairo_Antialias, "GRAY",
147
172
  INT2FIX (CAIRO_ANTIALIAS_GRAY));
148
- rb_define_const (rb_mCairo, "ANTIALIAS_SUBPIXEL",
173
+ rb_define_const (rb_mCairo_Antialias, "SUBPIXEL",
149
174
  INT2FIX (CAIRO_ANTIALIAS_SUBPIXEL));
150
175
 
151
176
 
152
177
  /* cairo_fill_rule_t */
153
- rb_define_const (rb_mCairo, "FILL_RULE_WINDING",
178
+ rb_mCairo_FillRule = rb_define_module_under (rb_mCairo, "FillRule");
179
+ rb_define_const (rb_mCairo_FillRule, "WINDING",
154
180
  INT2FIX (CAIRO_FILL_RULE_WINDING));
155
- rb_define_const (rb_mCairo, "FILL_RULE_EVEN_ODD",
181
+ rb_define_const (rb_mCairo_FillRule, "EVEN_ODD",
156
182
  INT2FIX (CAIRO_FILL_RULE_EVEN_ODD));
157
183
 
158
184
 
159
185
  /* cairo_line_cap_t */
160
- rb_define_const (rb_mCairo, "LINE_CAP_BUTT",
186
+ rb_mCairo_LineCap = rb_define_module_under (rb_mCairo, "LineCap");
187
+ rb_define_const (rb_mCairo_LineCap, "BUTT",
161
188
  INT2FIX (CAIRO_LINE_CAP_BUTT));
162
- rb_define_const (rb_mCairo, "LINE_CAP_ROUND",
189
+ rb_define_const (rb_mCairo_LineCap, "ROUND",
163
190
  INT2FIX (CAIRO_LINE_CAP_ROUND));
164
- rb_define_const (rb_mCairo, "LINE_CAP_SQUARE",
191
+ rb_define_const (rb_mCairo_LineCap, "SQUARE",
165
192
  INT2FIX (CAIRO_LINE_CAP_SQUARE));
166
193
 
167
194
 
168
195
  /* cairo_line_join_t */
169
- rb_define_const (rb_mCairo, "LINE_JOIN_MITER",
196
+ rb_mCairo_LineJoin = rb_define_module_under (rb_mCairo, "LineJoin");
197
+ rb_define_const (rb_mCairo_LineJoin, "MITER",
170
198
  INT2FIX (CAIRO_LINE_JOIN_MITER));
171
- rb_define_const (rb_mCairo, "LINE_JOIN_ROUND",
199
+ rb_define_const (rb_mCairo_LineJoin, "ROUND",
172
200
  INT2FIX (CAIRO_LINE_JOIN_ROUND));
173
- rb_define_const (rb_mCairo, "LINE_JOIN_BEVEL",
201
+ rb_define_const (rb_mCairo_LineJoin, "BEVEL",
174
202
  INT2FIX (CAIRO_LINE_JOIN_BEVEL));
175
203
 
176
204
 
177
205
  /* cairo_font_slant_t */
178
- rb_define_const (rb_mCairo, "FONT_SLANT_NORMAL",
206
+ rb_mCairo_FontSlant = rb_define_module_under (rb_mCairo, "FontSlant");
207
+ rb_define_const (rb_mCairo_FontSlant, "NORMAL",
179
208
  INT2FIX (CAIRO_FONT_SLANT_NORMAL));
180
- rb_define_const (rb_mCairo, "FONT_SLANT_ITALIC",
209
+ rb_define_const (rb_mCairo_FontSlant, "ITALIC",
181
210
  INT2FIX (CAIRO_FONT_SLANT_ITALIC));
182
- rb_define_const (rb_mCairo, "FONT_SLANT_OBLIQUE",
211
+ rb_define_const (rb_mCairo_FontSlant, "OBLIQUE",
183
212
  INT2FIX (CAIRO_FONT_SLANT_OBLIQUE));
184
213
 
185
214
 
186
215
  /* cairo_font_weight_t */
187
- rb_define_const (rb_mCairo, "FONT_WEIGHT_NORMAL",
216
+ rb_mCairo_FontWeight = rb_define_module_under (rb_mCairo, "FontWeight");
217
+ rb_define_const (rb_mCairo_FontWeight, "NORMAL",
188
218
  INT2FIX (CAIRO_FONT_WEIGHT_NORMAL));
189
- rb_define_const (rb_mCairo, "FONT_WEIGHT_BOLD",
219
+ rb_define_const (rb_mCairo_FontWeight, "BOLD",
190
220
  INT2FIX (CAIRO_FONT_WEIGHT_BOLD));
191
-
221
+
192
222
 
193
223
  /* cairo_subpixel_order_t */
194
- rb_define_const (rb_mCairo, "SUBPIXEL_ORDER_DEFAULT",
224
+ rb_mCairo_SubpixelOrder = rb_define_module_under (rb_mCairo, "SubpixelOrder");
225
+ rb_define_const (rb_mCairo_SubpixelOrder, "DEFAULT",
195
226
  INT2FIX (CAIRO_SUBPIXEL_ORDER_DEFAULT));
196
- rb_define_const (rb_mCairo, "SUBPIXEL_ORDER_RGB",
227
+ rb_define_const (rb_mCairo_SubpixelOrder, "RGB",
197
228
  INT2FIX (CAIRO_SUBPIXEL_ORDER_RGB));
198
- rb_define_const (rb_mCairo, "SUBPIXEL_ORDER_BGR",
229
+ rb_define_const (rb_mCairo_SubpixelOrder, "BGR",
199
230
  INT2FIX (CAIRO_SUBPIXEL_ORDER_BGR));
200
- rb_define_const (rb_mCairo, "SUBPIXEL_ORDER_VRGB",
231
+ rb_define_const (rb_mCairo_SubpixelOrder, "VRGB",
201
232
  INT2FIX (CAIRO_SUBPIXEL_ORDER_VRGB));
202
- rb_define_const (rb_mCairo, "SUBPIXEL_ORDER_VBGR",
233
+ rb_define_const (rb_mCairo_SubpixelOrder, "VBGR",
203
234
  INT2FIX (CAIRO_SUBPIXEL_ORDER_VBGR));
204
-
235
+
205
236
 
206
237
  /* cairo_hint_style_t */
207
- rb_define_const (rb_mCairo, "HINT_STYLE_DEFAULT",
238
+ rb_mCairo_HintStyle = rb_define_module_under (rb_mCairo, "HintStyle");
239
+ rb_define_const (rb_mCairo_HintStyle, "DEFAULT",
208
240
  INT2FIX (CAIRO_HINT_STYLE_DEFAULT));
209
- rb_define_const (rb_mCairo, "HINT_STYLE_NONE",
241
+ rb_define_const (rb_mCairo_HintStyle, "NONE",
210
242
  INT2FIX (CAIRO_HINT_STYLE_NONE));
211
- rb_define_const (rb_mCairo, "HINT_STYLE_SLIGHT",
243
+ rb_define_const (rb_mCairo_HintStyle, "SLIGHT",
212
244
  INT2FIX (CAIRO_HINT_STYLE_SLIGHT));
213
- rb_define_const (rb_mCairo, "HINT_STYLE_MEDIUM",
245
+ rb_define_const (rb_mCairo_HintStyle, "MEDIUM",
214
246
  INT2FIX (CAIRO_HINT_STYLE_MEDIUM));
215
- rb_define_const (rb_mCairo, "HINT_STYLE_FULL",
247
+ rb_define_const (rb_mCairo_HintStyle, "FULL",
216
248
  INT2FIX (CAIRO_HINT_STYLE_FULL));
217
249
 
218
250
 
219
251
  /* cairo_hint_metrics_t */
220
- rb_define_const (rb_mCairo, "HINT_METRICS_DEFAULT",
252
+ rb_mCairo_HintMetrics = rb_define_module_under (rb_mCairo, "HintMetrics");
253
+ rb_define_const (rb_mCairo_HintMetrics, "DEFAULT",
221
254
  INT2FIX (CAIRO_HINT_METRICS_DEFAULT));
222
- rb_define_const (rb_mCairo, "HINT_METRICS_ON",
255
+ rb_define_const (rb_mCairo_HintMetrics, "ON",
223
256
  INT2FIX (CAIRO_HINT_METRICS_ON));
224
- rb_define_const (rb_mCairo, "HINT_METRICS_OFF",
257
+ rb_define_const (rb_mCairo_HintMetrics, "OFF",
225
258
  INT2FIX (CAIRO_HINT_METRICS_OFF));
226
259
 
227
260
 
228
- /* cairo_font_type_t */
229
- rb_define_const (rb_mCairo, "FONT_TYPE_TOY", INT2FIX(CAIRO_FONT_TYPE_TOY));
230
- rb_define_const (rb_mCairo, "FONT_TYPE_FT", INT2FIX(CAIRO_FONT_TYPE_FT));
231
- rb_define_const (rb_mCairo, "FONT_TYPE_WIN32",
232
- INT2FIX(CAIRO_FONT_TYPE_WIN32));
233
- rb_define_const (rb_mCairo, "FONT_TYPE_ATSUI",
234
- INT2FIX(CAIRO_FONT_TYPE_ATSUI));
235
-
236
-
237
261
  /* cairo_path_data_type_t */
238
- rb_define_const (rb_mCairo, "PATH_MOVE_TO",
262
+ rb_mCairo_PathDataType = rb_define_module_under (rb_mCairo, "PathDataType");
263
+ rb_define_const (rb_mCairo_PathDataType, "MOVE_TO",
239
264
  INT2FIX (CAIRO_PATH_MOVE_TO));
240
- rb_define_const (rb_mCairo, "PATH_LINE_TO",
265
+ rb_define_const (rb_mCairo_PathDataType, "LINE_TO",
241
266
  INT2FIX (CAIRO_PATH_LINE_TO));
242
- rb_define_const (rb_mCairo, "PATH_CURVE_TO",
267
+ rb_define_const (rb_mCairo_PathDataType, "CURVE_TO",
243
268
  INT2FIX (CAIRO_PATH_CURVE_TO));
244
- rb_define_const (rb_mCairo, "PATH_CLOSE_PATH",
269
+ rb_define_const (rb_mCairo_PathDataType, "CLOSE_PATH",
245
270
  INT2FIX (CAIRO_PATH_CLOSE_PATH));
246
271
 
247
272
 
248
273
  /* cairo_content_t */
249
- rb_define_const (rb_mCairo, "CONTENT_COLOR",
274
+ rb_mCairo_Content = rb_define_module_under (rb_mCairo, "Content");
275
+ rb_define_const (rb_mCairo_Content, "COLOR",
250
276
  INT2FIX (CAIRO_CONTENT_COLOR));
251
- rb_define_const (rb_mCairo, "CONTENT_ALPHA",
277
+ rb_define_const (rb_mCairo_Content, "ALPHA",
252
278
  INT2FIX (CAIRO_CONTENT_ALPHA));
253
- rb_define_const (rb_mCairo, "CONTENT_COLOR_ALPHA",
279
+ rb_define_const (rb_mCairo_Content, "COLOR_ALPHA",
254
280
  INT2FIX (CAIRO_CONTENT_COLOR_ALPHA));
255
281
 
256
282
 
257
- /* cairo_surface_type_t */
258
- rb_define_const (rb_mCairo, "SURFACE_TYPE_IMAGE",
259
- INT2FIX (CAIRO_SURFACE_TYPE_IMAGE));
260
- rb_define_const (rb_mCairo, "SURFACE_TYPE_PDF",
261
- INT2FIX (CAIRO_SURFACE_TYPE_PDF));
262
- rb_define_const (rb_mCairo, "SURFACE_TYPE_PS",
263
- INT2FIX (CAIRO_SURFACE_TYPE_PS));
264
- rb_define_const (rb_mCairo, "SURFACE_TYPE_XLIB",
265
- INT2FIX (CAIRO_SURFACE_TYPE_XLIB));
266
- rb_define_const (rb_mCairo, "SURFACE_TYPE_XCB",
267
- INT2FIX (CAIRO_SURFACE_TYPE_XCB));
268
- rb_define_const (rb_mCairo, "SURFACE_TYPE_GLITZ",
269
- INT2FIX (CAIRO_SURFACE_TYPE_GLITZ));
270
- rb_define_const (rb_mCairo, "SURFACE_TYPE_QUARTZ",
271
- INT2FIX (CAIRO_SURFACE_TYPE_QUARTZ));
272
- rb_define_const (rb_mCairo, "SURFACE_TYPE_WIN32",
273
- INT2FIX (CAIRO_SURFACE_TYPE_WIN32));
274
- rb_define_const (rb_mCairo, "SURFACE_TYPE_BEOS",
275
- INT2FIX (CAIRO_SURFACE_TYPE_BEOS));
276
- rb_define_const (rb_mCairo, "SURFACE_TYPE_DIRECTFB",
277
- INT2FIX (CAIRO_SURFACE_TYPE_DIRECTFB));
278
- rb_define_const (rb_mCairo, "SURFACE_TYPE_SVG",
279
- INT2FIX (CAIRO_SURFACE_TYPE_SVG));
280
- #if CAIRO_CHECK_VERSION(1, 3, 0)
281
- rb_define_const (rb_mCairo, "SURFACE_TYPE_OS2",
282
- INT2FIX (CAIRO_SURFACE_TYPE_OS2));
283
- #endif
284
-
285
283
  /* cairo_format_t */
286
- rb_define_const (rb_mCairo, "FORMAT_ARGB32",
284
+ rb_mCairo_Format = rb_define_module_under (rb_mCairo, "Format");
285
+ rb_define_const (rb_mCairo_Format, "ARGB32",
287
286
  INT2FIX (CAIRO_FORMAT_ARGB32));
288
- rb_define_const (rb_mCairo, "FORMAT_RGB24",
287
+ rb_define_const (rb_mCairo_Format, "RGB24",
289
288
  INT2FIX (CAIRO_FORMAT_RGB24));
290
- rb_define_const (rb_mCairo, "FORMAT_A8",
289
+ rb_define_const (rb_mCairo_Format, "A8",
291
290
  INT2FIX (CAIRO_FORMAT_A8));
292
- rb_define_const (rb_mCairo, "FORMAT_A1",
291
+ rb_define_const (rb_mCairo_Format, "A1",
293
292
  INT2FIX (CAIRO_FORMAT_A1));
294
293
  #if !CAIRO_CHECK_VERSION(1, 3, 0)
295
- rb_define_const (rb_mCairo, "FORMAT_RGB16_565",
294
+ rb_define_const (rb_mCairo_Format, "RGB16_565",
296
295
  INT2FIX (CAIRO_FORMAT_RGB16_565));
297
296
  #endif
298
297
 
299
298
 
300
- /* cairo_pattern_type_t */
301
- rb_define_const (rb_mCairo, "PATTERN_TYPE_SOLID",
302
- INT2FIX (CAIRO_PATTERN_TYPE_SOLID));
303
- rb_define_const (rb_mCairo, "PATTERN_TYPE_SURFACE",
304
- INT2FIX (CAIRO_PATTERN_TYPE_SURFACE));
305
- rb_define_const (rb_mCairo, "PATTERN_TYPE_LINEAR",
306
- INT2FIX (CAIRO_PATTERN_TYPE_LINEAR));
307
- rb_define_const (rb_mCairo, "PATTERN_TYPE_RADIAL",
308
- INT2FIX (CAIRO_PATTERN_TYPE_RADIAL));
309
-
310
299
  /* cairo_extend_t */
311
- rb_define_const (rb_mCairo, "EXTEND_NONE",
300
+ rb_mCairo_Extend = rb_define_module_under (rb_mCairo, "Extend");
301
+ rb_define_const (rb_mCairo_Extend, "NONE",
312
302
  INT2FIX (CAIRO_EXTEND_NONE));
313
- rb_define_const (rb_mCairo, "EXTEND_REPEAT",
303
+ rb_define_const (rb_mCairo_Extend, "REPEAT",
314
304
  INT2FIX (CAIRO_EXTEND_REPEAT));
315
- rb_define_const (rb_mCairo, "EXTEND_REFLECT",
305
+ rb_define_const (rb_mCairo_Extend, "REFLECT",
316
306
  INT2FIX (CAIRO_EXTEND_REFLECT));
317
- rb_define_const (rb_mCairo, "EXTEND_PAD",
307
+ rb_define_const (rb_mCairo_Extend, "PAD",
318
308
  INT2FIX (CAIRO_EXTEND_PAD));
319
309
 
320
310
 
321
311
  /* cairo_filter_t */
322
- rb_define_const (rb_mCairo, "FILTER_FAST",
312
+ rb_mCairo_Filter = rb_define_module_under (rb_mCairo, "Filter");
313
+ rb_define_const (rb_mCairo_Filter, "FAST",
323
314
  INT2FIX (CAIRO_FILTER_FAST));
324
- rb_define_const (rb_mCairo, "FILTER_GOOD",
315
+ rb_define_const (rb_mCairo_Filter, "GOOD",
325
316
  INT2FIX (CAIRO_FILTER_GOOD));
326
- rb_define_const (rb_mCairo, "FILTER_BEST",
317
+ rb_define_const (rb_mCairo_Filter, "BEST",
327
318
  INT2FIX (CAIRO_FILTER_BEST));
328
- rb_define_const (rb_mCairo, "FILTER_NEAREST",
319
+ rb_define_const (rb_mCairo_Filter, "NEAREST",
329
320
  INT2FIX (CAIRO_FILTER_NEAREST));
330
- rb_define_const (rb_mCairo, "FILTER_BILINEAR",
321
+ rb_define_const (rb_mCairo_Filter, "BILINEAR",
331
322
  INT2FIX (CAIRO_FILTER_BILINEAR));
332
- rb_define_const (rb_mCairo, "FILTER_GAUSSIAN",
323
+ rb_define_const (rb_mCairo_Filter, "GAUSSIAN",
333
324
  INT2FIX (CAIRO_FILTER_GAUSSIAN));
334
325
 
335
326
  #if CAIRO_HAS_SVG_SURFACE
336
327
  /* cairo_svg_version_t */
337
- rb_define_const (rb_mCairo, "SVG_VERSION_1_1",
328
+ rb_mCairo_SVGVersion = rb_define_module_under (rb_mCairo, "SVGVersion");
329
+ rb_define_const (rb_mCairo_SVGVersion, "VERSION_1_1",
338
330
  INT2FIX (CAIRO_SVG_VERSION_1_1));
339
- rb_define_const (rb_mCairo, "SVG_VERSION_1_2",
331
+ rb_define_const (rb_mCairo_SVGVersion, "VERSION_1_2",
340
332
  INT2FIX (CAIRO_SVG_VERSION_1_2));
341
333
  #endif
342
334
  }