rays 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +7 -0
  2. data/.doc/ext/rays/bitmap.cpp +70 -233
  3. data/.doc/ext/rays/bounds.cpp +339 -57
  4. data/.doc/ext/rays/color.cpp +58 -48
  5. data/.doc/ext/rays/color_space.cpp +174 -0
  6. data/.doc/ext/rays/font.cpp +31 -53
  7. data/.doc/ext/rays/image.cpp +64 -67
  8. data/.doc/ext/rays/matrix.cpp +22 -50
  9. data/.doc/ext/rays/native.cpp +9 -2
  10. data/.doc/ext/rays/painter.cpp +276 -259
  11. data/.doc/ext/rays/point.cpp +186 -52
  12. data/.doc/ext/rays/rays.cpp +25 -20
  13. data/.doc/ext/rays/shader.cpp +61 -0
  14. data/.doc/ext/rays/texture.cpp +47 -59
  15. data/{README → README.md} +0 -0
  16. data/Rakefile +6 -5
  17. data/VERSION +1 -1
  18. data/ext/rays/bitmap.cpp +88 -248
  19. data/ext/rays/bounds.cpp +437 -141
  20. data/ext/rays/color.cpp +79 -69
  21. data/ext/rays/color_space.cpp +185 -0
  22. data/ext/rays/extconf.rb +14 -63
  23. data/ext/rays/font.cpp +44 -65
  24. data/ext/rays/image.cpp +82 -81
  25. data/ext/rays/matrix.cpp +32 -60
  26. data/ext/rays/native.cpp +9 -2
  27. data/ext/rays/painter.cpp +345 -321
  28. data/ext/rays/point.cpp +212 -69
  29. data/ext/rays/rays.cpp +29 -23
  30. data/ext/rays/shader.cpp +63 -0
  31. data/ext/rays/texture.cpp +64 -74
  32. data/include/rays/bitmap.h +21 -12
  33. data/include/rays/bounds.h +67 -9
  34. data/include/rays/color.h +23 -7
  35. data/include/rays/{colorspace.h → color_space.h} +6 -3
  36. data/include/rays/exception.h +17 -11
  37. data/include/rays/font.h +4 -3
  38. data/include/rays/image.h +11 -6
  39. data/include/rays/matrix.h +15 -12
  40. data/include/rays/opengl.h +54 -1
  41. data/include/rays/painter.h +98 -108
  42. data/include/rays/point.h +45 -5
  43. data/include/rays/rays.h +2 -2
  44. data/include/rays/ruby/bitmap.h +2 -16
  45. data/include/rays/ruby/bounds.h +4 -16
  46. data/include/rays/ruby/color.h +3 -16
  47. data/include/rays/ruby/color_space.h +27 -0
  48. data/include/rays/ruby/font.h +2 -16
  49. data/include/rays/ruby/image.h +2 -16
  50. data/include/rays/ruby/matrix.h +2 -16
  51. data/include/rays/ruby/painter.h +2 -16
  52. data/include/rays/ruby/point.h +3 -16
  53. data/include/rays/ruby/shader.h +27 -0
  54. data/include/rays/ruby/texture.h +2 -16
  55. data/include/rays/ruby.h +1 -0
  56. data/include/rays/shader.h +48 -0
  57. data/include/rays/texture.h +13 -2
  58. data/include/rays.h +2 -1
  59. data/lib/rays/bitmap.rb +20 -11
  60. data/lib/rays/bounds.rb +29 -68
  61. data/lib/rays/color.rb +39 -0
  62. data/lib/rays/color_space.rb +33 -0
  63. data/lib/rays/font.rb +29 -0
  64. data/lib/rays/image.rb +22 -0
  65. data/lib/rays/module.rb +11 -7
  66. data/lib/rays/painter.rb +103 -40
  67. data/lib/rays/point.rb +19 -36
  68. data/lib/rays/shader.rb +13 -0
  69. data/lib/rays/texture.rb +9 -0
  70. data/lib/rays.rb +4 -0
  71. data/rays.gemspec +3 -4
  72. data/src/bounds.cpp +272 -63
  73. data/src/color.cpp +168 -21
  74. data/src/{colorspace.cpp → color_space.cpp} +38 -1
  75. data/src/exception.cpp +24 -15
  76. data/src/frame_buffer.cpp +275 -0
  77. data/src/frame_buffer.h +79 -0
  78. data/src/image.cpp +80 -36
  79. data/src/ios/bitmap.mm +340 -0
  80. data/src/ios/font.mm +206 -0
  81. data/src/{cocoa → ios}/helper.h +2 -2
  82. data/src/{cocoa → ios}/helper.mm +0 -0
  83. data/src/ios/opengl.mm +21 -0
  84. data/src/ios/program.cpp +122 -0
  85. data/src/{cocoa → ios}/rays.mm +8 -7
  86. data/src/matrix.cpp +10 -22
  87. data/src/opengl.cpp +64 -0
  88. data/src/{cocoa → osx}/bitmap.mm +121 -70
  89. data/src/{cocoa → osx}/font.mm +32 -24
  90. data/src/osx/helper.h +26 -0
  91. data/src/osx/helper.mm +25 -0
  92. data/src/osx/opengl.mm +103 -0
  93. data/src/osx/rays.mm +43 -0
  94. data/src/painter.cpp +596 -422
  95. data/src/point.cpp +154 -11
  96. data/src/program.cpp +513 -0
  97. data/src/program.h +73 -0
  98. data/src/render_buffer.cpp +120 -0
  99. data/src/render_buffer.h +47 -0
  100. data/src/shader.cpp +117 -0
  101. data/src/texture.cpp +104 -134
  102. data/test/helper.rb +10 -3
  103. data/test/test_bitmap.rb +18 -0
  104. data/test/test_bounds.rb +81 -35
  105. data/test/test_color.rb +29 -2
  106. data/test/test_image.rb +63 -0
  107. data/test/test_painter.rb +120 -0
  108. data/test/test_point.rb +30 -9
  109. data/test/test_shader.rb +37 -0
  110. data/test/test_texture.rb +18 -0
  111. metadata +75 -58
  112. data/.gitignore +0 -14
  113. data/ChangeLog +0 -8
data/ext/rays/color.cpp CHANGED
@@ -10,60 +10,25 @@ using namespace Rucy;
10
10
 
11
11
  static Class cColor;
12
12
 
13
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Color, cColor)
13
14
 
14
- namespace Rays
15
- {
15
+ #define THIS to<Rays::Color*>(self)
16
16
 
17
-
18
- Class
19
- color_class ()
20
- {
21
- return cColor;
22
- }
23
-
24
-
25
- }// Rays
26
-
27
-
28
- namespace Rucy
29
- {
30
-
31
-
32
- Value
33
- value (const Rays::Color& obj)
34
- {
35
- return new_type(cColor, new Rays::Color(obj));
36
- }
37
-
38
- Value
39
- value (const Rays::Color* obj)
40
- {
41
- return obj ? value(*obj) : nil();
42
- }
43
-
44
-
45
- }// Rucy
46
-
47
-
48
- #define THIS to<Rays::Color*>(self)
49
-
50
- #define CHECK RUCY_CHECK_OBJ(self, Rays::Color, cColor)
17
+ #define CHECK RUCY_CHECK_OBJ(Rays::Color, cColor, self)
51
18
 
52
19
 
53
20
  static
54
- RUBY_DEF_ALLOC(alloc, klass)
21
+ RUCY_DEF_ALLOC(alloc, klass)
55
22
  {
56
23
  return new_type<Rays::Color>(klass);
57
24
  }
58
- RUBY_END
25
+ RUCY_END
59
26
 
60
27
  static
61
- RUBY_DEFN(initialize)
28
+ RUCY_DEFN(setup)
62
29
  {
63
- RUCY_CHECK_OBJ(self, Rays::Color, cColor);
64
-
65
- if (argc < 0 || 4 < argc)
66
- arg_count_error("Color#initialize", argc, 0, 1, 2, 3, 4);
30
+ CHECK;
31
+ check_arg_count(__FILE__, __LINE__, "Color#initialize", argc, 0, 1, 2, 3, 4);
67
32
 
68
33
  if (argc == 0) return self;
69
34
 
@@ -91,92 +56,88 @@ RUBY_DEFN(initialize)
91
56
 
92
57
  return self;
93
58
  }
94
- RUBY_END
59
+ RUCY_END
95
60
 
96
61
  static
97
- RUBY_DEF1(initialize_copy, obj)
62
+ RUCY_DEF1(initialize_copy, obj)
98
63
  {
99
- RUCY_CHECK_OBJ(self, Rays::Color, cColor);
100
-
101
- Rays::Color* color = to<Rays::Color*>(obj);
102
- if (!color) argument_error();
103
-
104
- *THIS = *color;
64
+ CHECK;
65
+ *THIS = to<Rays::Color&>(obj);
105
66
  return self;
106
67
  }
107
- RUBY_END
68
+ RUCY_END
108
69
 
109
70
  static
110
- RUBY_DEF1(set_red, red)
71
+ RUCY_DEF1(set_red, red)
111
72
  {
112
73
  CHECK;
113
74
 
114
75
  return value(THIS->red = to<float>(red));
115
76
  }
116
- RUBY_END
77
+ RUCY_END
117
78
 
118
79
  static
119
- RUBY_DEF0(get_red)
80
+ RUCY_DEF0(get_red)
120
81
  {
121
82
  CHECK;
122
83
 
123
84
  return value(THIS->red);
124
85
  }
125
- RUBY_END
86
+ RUCY_END
126
87
 
127
88
  static
128
- RUBY_DEF1(set_green, green)
89
+ RUCY_DEF1(set_green, green)
129
90
  {
130
91
  CHECK;
131
92
 
132
93
  return value(THIS->green = to<float>(green));
133
94
  }
134
- RUBY_END
95
+ RUCY_END
135
96
 
136
97
  static
137
- RUBY_DEF0(get_green)
98
+ RUCY_DEF0(get_green)
138
99
  {
139
100
  CHECK;
140
101
 
141
102
  return value(THIS->green);
142
103
  }
143
- RUBY_END
104
+ RUCY_END
144
105
 
145
106
  static
146
- RUBY_DEF1(set_blue, blue)
107
+ RUCY_DEF1(set_blue, blue)
147
108
  {
148
109
  CHECK;
149
110
 
150
111
  return value(THIS->blue = to<float>(blue));
151
112
  }
152
- RUBY_END
113
+ RUCY_END
153
114
 
154
115
  static
155
- RUBY_DEF0(get_blue)
116
+ RUCY_DEF0(get_blue)
156
117
  {
157
118
  CHECK;
158
119
 
159
120
  return value(THIS->blue);
160
121
  }
161
- RUBY_END
122
+ RUCY_END
162
123
 
163
124
  static
164
- RUBY_DEF1(set_alpha, alpha)
125
+ RUCY_DEF1(set_alpha, alpha)
165
126
  {
166
127
  CHECK;
167
128
 
168
129
  return value(THIS->alpha = to<float>(alpha));
169
130
  }
170
- RUBY_END
131
+ RUCY_END
171
132
 
172
133
  static
173
- RUBY_DEF0(get_alpha)
134
+ RUCY_DEF0(get_alpha)
174
135
  {
175
136
  CHECK;
176
137
 
177
138
  return value(THIS->alpha);
178
139
  }
179
- RUBY_END
140
+ RUCY_END
180
141
 
181
142
 
182
143
  void
@@ -186,7 +147,7 @@ Init_color ()
186
147
 
187
148
  cColor = mRays.define_class("Color");
188
149
  cColor.define_alloc_func(alloc);
189
- cColor.define_private_method("initialize", initialize);
150
+ cColor.define_private_method("setup", setup);
190
151
  cColor.define_private_method("initialize_copy", initialize_copy);
191
152
  cColor.define_method("red=", set_red);
192
153
  cColor.define_method("red", get_red);
@@ -197,3 +158,52 @@ Init_color ()
197
158
  cColor.define_method("alpha=", set_alpha);
198
159
  cColor.define_method("alpha", get_alpha);
199
160
  }
161
+
162
+
163
+ namespace Rucy
164
+ {
165
+
166
+
167
+ template <> Rays::Color
168
+ value_to<Rays::Color> (Value value, bool convert)
169
+ {
170
+ if (convert)
171
+ {
172
+ if (value.is_i() || value.is_f())
173
+ return Rays::Color(value.as_f(true));
174
+ else if (value.is_array())
175
+ {
176
+ int size = value.size();
177
+ if (size <= 0 || 4 < size)
178
+ Rucy::argument_error(__FILE__, __LINE__);
179
+
180
+ Value* a = value.as_array();
181
+ switch (size)
182
+ {
183
+ case 1: return Rays::Color(a[0].as_f(true));
184
+ case 2: return Rays::Color(a[0].as_f(true), a[1].as_f(true));
185
+ case 3: return Rays::Color(a[0].as_f(true), a[1].as_f(true), a[2].as_f(true));
186
+ case 4: return Rays::Color(a[0].as_f(true), a[1].as_f(true), a[2].as_f(true), a[3].as_f(true));
187
+ }
188
+ }
189
+ }
190
+
191
+ return value_to<Rays::Color&>(value, convert);
192
+ }
193
+
194
+
195
+ }// Rucy
196
+
197
+
198
+ namespace Rays
199
+ {
200
+
201
+
202
+ Class
203
+ color_class ()
204
+ {
205
+ return cColor;
206
+ }
207
+
208
+
209
+ }// Rays
@@ -0,0 +1,185 @@
1
+ #include "rays/ruby/color_space.h"
2
+
3
+
4
+ #include <rucy.h>
5
+ #include "defs.h"
6
+
7
+
8
+ using namespace Rucy;
9
+
10
+
11
+ static Class cColorSpace;
12
+
13
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::ColorSpace, cColorSpace)
14
+
15
+ #define THIS to<Rays::ColorSpace*>(self)
16
+
17
+ #define CHECK RUCY_CHECK_OBJ(Rays::ColorSpace, cColorSpace, self)
18
+
19
+
20
+ static
21
+ RUCY_DEF_ALLOC(alloc, klass)
22
+ {
23
+ return new_type<Rays::ColorSpace>(klass);
24
+ }
25
+ RUCY_END
26
+
27
+ static
28
+ RUCY_DEF2(setup, type, premultiplied)
29
+ {
30
+ CHECK;
31
+
32
+ *THIS = Rays::ColorSpace(
33
+ (Rays::ColorSpaceType) to<uint>(type),
34
+ to<bool>(premultiplied));
35
+ return self;
36
+ }
37
+ RUCY_END
38
+
39
+ static
40
+ RUCY_DEF1(initialize_copy, obj)
41
+ {
42
+ CHECK;
43
+ *THIS = to<Rays::ColorSpace&>(obj);
44
+ return self;
45
+ }
46
+ RUCY_END
47
+
48
+ static
49
+ RUCY_DEF0(type)
50
+ {
51
+ CHECK;
52
+
53
+ return value(THIS->type());
54
+ }
55
+ RUCY_END
56
+
57
+ static
58
+ RUCY_DEF0(is_gray)
59
+ {
60
+ CHECK;
61
+
62
+ return value(THIS->is_gray());
63
+ }
64
+ RUCY_END
65
+
66
+ static
67
+ RUCY_DEF0(is_rgb)
68
+ {
69
+ CHECK;
70
+
71
+ return value(THIS->is_rgb());
72
+ }
73
+ RUCY_END
74
+
75
+ static
76
+ RUCY_DEF0(is_bgr)
77
+ {
78
+ CHECK;
79
+
80
+ return value(THIS->is_bgr());
81
+ }
82
+ RUCY_END
83
+
84
+ static
85
+ RUCY_DEF0(is_float)
86
+ {
87
+ CHECK;
88
+
89
+ return value(THIS->is_float());
90
+ }
91
+ RUCY_END
92
+
93
+ static
94
+ RUCY_DEF0(has_alpha)
95
+ {
96
+ CHECK;
97
+
98
+ return value(THIS->has_alpha());
99
+ }
100
+ RUCY_END
101
+
102
+ static
103
+ RUCY_DEF0(has_skip)
104
+ {
105
+ CHECK;
106
+
107
+ return value(THIS->has_skip());
108
+ }
109
+ RUCY_END
110
+
111
+ static
112
+ RUCY_DEF0(is_premult)
113
+ {
114
+ CHECK;
115
+
116
+ return value(THIS->is_premult());
117
+ }
118
+ RUCY_END
119
+
120
+
121
+ void
122
+ Init_color_space ()
123
+ {
124
+ Module mRays = define_module("Rays");
125
+
126
+ cColorSpace = mRays.define_class("ColorSpace");
127
+ cColorSpace.define_alloc_func(alloc);
128
+ cColorSpace.define_private_method("initialize_copy", initialize_copy);
129
+ cColorSpace.define_private_method("setup", setup);
130
+ cColorSpace.define_method("type", type);
131
+ cColorSpace.define_method("gray?", is_gray);
132
+ cColorSpace.define_method("rgb?", is_rgb);
133
+ cColorSpace.define_method("bgr?", is_bgr);
134
+ cColorSpace.define_method("float?", is_float);
135
+ cColorSpace.define_method("alpha?", has_alpha);
136
+ cColorSpace.define_method("skip?", has_skip);
137
+ cColorSpace.define_method("premult?", is_premult);
138
+
139
+ cColorSpace.define_const("GRAY_8", Rays::GRAY_8);
140
+ cColorSpace.define_const("GRAY_16", Rays::GRAY_16);
141
+ cColorSpace.define_const("GRAY_24", Rays::GRAY_24);
142
+ cColorSpace.define_const("GRAY_32", Rays::GRAY_32);
143
+ cColorSpace.define_const("GRAY_float", Rays::GRAY_float);
144
+ cColorSpace.define_const("RGB_888", Rays:: RGB_888);
145
+ cColorSpace.define_const("RGBA_8888", Rays:: RGBA_8888);
146
+ cColorSpace.define_const("RGBX_8888", Rays:: RGBX_8888);
147
+ cColorSpace.define_const("ARGB_8888", Rays::ARGB_8888);
148
+ cColorSpace.define_const("XRGB_8888", Rays::XRGB_8888);
149
+ cColorSpace.define_const("BGR_888", Rays:: BGR_888);
150
+ cColorSpace.define_const("BGRA_8888", Rays:: BGRA_8888);
151
+ cColorSpace.define_const("BGRX_8888", Rays:: BGRX_8888);
152
+ cColorSpace.define_const("ABGR_8888", Rays::ABGR_8888);
153
+ cColorSpace.define_const("XBGR_8888", Rays::XBGR_8888);
154
+ cColorSpace.define_const("RGB_float", Rays:: RGB_float);
155
+ cColorSpace.define_const("RGBA_float", Rays:: RGBA_float);
156
+ cColorSpace.define_const("ARGB_float", Rays::ARGB_float);
157
+ cColorSpace.define_const("BGR_float", Rays:: BGR_float);
158
+ cColorSpace.define_const("BGRA_float", Rays:: BGRA_float);
159
+ cColorSpace.define_const("ABGR_float", Rays::ABGR_float);
160
+ cColorSpace.define_const("GRAY", Rays::GRAY);
161
+ cColorSpace.define_const("RGB", Rays:: RGB);
162
+ cColorSpace.define_const("BGR", Rays:: BGR);
163
+ cColorSpace.define_const("RGBA", Rays:: RGBA);
164
+ cColorSpace.define_const("RGBX", Rays:: RGBX);
165
+ cColorSpace.define_const("ARGB", Rays::ARGB);
166
+ cColorSpace.define_const("XRGB", Rays::XRGB);
167
+ cColorSpace.define_const("BGRA", Rays:: BGRA);
168
+ cColorSpace.define_const("BGRX", Rays:: BGRX);
169
+ cColorSpace.define_const("ABGR", Rays::ABGR);
170
+ cColorSpace.define_const("XBGR", Rays::XBGR);
171
+ }
172
+
173
+
174
+ namespace Rays
175
+ {
176
+
177
+
178
+ Class
179
+ color_space_class ()
180
+ {
181
+ return cColorSpace;
182
+ }
183
+
184
+
185
+ }// Rays
data/ext/rays/extconf.rb CHANGED
@@ -1,75 +1,26 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
 
4
- require 'xot/load_path'
5
- Xot::LoadPath.unshift File.expand_path('../../../lib', __FILE__)
4
+ %w[../xot ../rucy .]
5
+ .map {|s| File.expand_path "../../../#{s}/lib", __FILE__}
6
+ .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
6
7
 
7
8
  require 'mkmf'
8
- require 'xot/rake'
9
+ require 'xot/extconf'
9
10
  require 'xot/module'
10
11
  require 'rucy/module'
11
12
  require 'rays/module'
12
13
 
13
- include Xot::Rake
14
14
 
15
+ Xot::ExtConf.new Xot, Rucy, Rays do
16
+ setup do
17
+ headers << 'boost/noncopyable.hpp' << 'ruby.h'
18
+ local_libs << 'rucy'
19
+ libs.unshift 'gdi21', 'opengl32' if win32?
20
+ frameworks << 'AppKit' << 'OpenGL' if osx?
21
+ $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if cygwin?
22
+ end
15
23
 
16
- debug = env :DEBUG, false
17
-
18
-
19
- DEFS = []
20
- INCDIRS = %w[
21
- /opt/local/include
22
- /opt/include
23
- ]
24
- LIBDIRS = []
25
-
26
- HEADERS = %w[
27
- boost/shared_ptr.hpp
28
- ruby.h
29
- xot.h
30
- rucy.h
31
- rays.h
32
- ]
33
- LIBS = %w[
34
- stdc++
35
- xot
36
- rucy
37
- rays
38
- ]
39
- FRAMEWORKS = []
40
-
41
-
42
- DEFS << '_DEBUG' if debug
43
- DEFS << 'NDEBUG' unless debug
44
- DEFS << $~[0].upcase if RUBY_PLATFORM =~ /mswin|ming|cygwin|darwin/i
45
- if win32?
46
- DEFS << 'WINDOWS' << 'WIN32'
47
- LIBS.unshift 'gdi32', 'opengl32'
48
- elsif cocoa?
49
- DEFS << 'COCOA'
50
- FRAMEWORKS << 'AppKit' << 'OpenGL'
24
+ dir_config 'boost'
25
+ create_makefile 'rays/native'
51
26
  end
52
-
53
- $CPPFLAGS << DEFS.map {|s| " -D#{s}"}.join
54
- $CPPFLAGS << INCDIRS.map {|s| " -I#{s}"}.join
55
- $LDFLAGS << LIBDIRS.map {|s| " -L#{s}"}.join
56
- $LDFLAGS << FRAMEWORKS.map {|s| " -framework #{s}"}.join
57
- $LDFLAGS << ' -Wl,--out-implib=native.dll.a' if cygwin?
58
- $CFLAGS << ' --stdlib=libc++' if clang?
59
- $LOCAL_LIBS << ' -lrucy'
60
-
61
- RbConfig::CONFIG.each do |key, val|
62
- {'gcc' => 'g++', 'clang' => 'clang++'}.each {|from, to| val.gsub! from, to}
63
- end
64
-
65
-
66
- dir_config 'boost'
67
- dir_config 'xot', Xot.root_dir
68
- dir_config 'rucy', Rucy.root_dir
69
- dir_config 'rays', Rays.root_dir
70
-
71
- exit 1 unless HEADERS.all? {|s| have_header(s)}
72
- exit 1 unless LIBS.all? {|s| have_library(s)}
73
-
74
-
75
- create_makefile 'rays/native'
data/ext/rays/font.cpp CHANGED
@@ -12,59 +12,25 @@ using Rays::coord;
12
12
 
13
13
  static Class cFont;
14
14
 
15
+ RUCY_DEFINE_VALUE_FROM_TO(Rays::Font, cFont)
15
16
 
16
- namespace Rays
17
- {
18
-
19
-
20
- Class
21
- font_class ()
22
- {
23
- return cFont;
24
- }
25
-
26
-
27
- }// Rays
28
-
29
-
30
- namespace Rucy
31
- {
32
-
33
-
34
- Value
35
- value (const Rays::Font& obj)
36
- {
37
- return new_type(cFont, new Rays::Font(obj));
38
- }
39
-
40
- Value
41
- value (const Rays::Font* obj)
42
- {
43
- return obj ? value(*obj) : nil();
44
- }
45
-
46
-
47
- }// Rucy
48
-
49
-
50
- #define THIS to<Rays::Font*>(self)
17
+ #define THIS to<Rays::Font*>(self)
51
18
 
52
- #define CHECK RUCY_CHECK_OBJECT(self, Rays::Font, cFont)
19
+ #define CHECK RUCY_CHECK_OBJECT(Rays::Font, cFont, self)
53
20
 
54
21
 
55
22
  static
56
- RUBY_DEF_ALLOC(alloc, klass)
23
+ RUCY_DEF_ALLOC(alloc, klass)
57
24
  {
58
25
  return new_type<Rays::Font>(klass);
59
26
  }
60
- RUBY_END
27
+ RUCY_END
61
28
 
62
29
  static
63
- RUBY_DEFN(initialize)
30
+ RUCY_DEFN(initialize)
64
31
  {
65
- RUCY_CHECK_OBJ(self, Rays::Font, cFont);
66
- if (argc < 0 || 2 < argc)
67
- arg_count_error("Font#initialize", argc, 0, 1, 2);
32
+ RUCY_CHECK_OBJ(Rays::Font, cFont, self);
33
+ check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2);
68
34
 
69
35
  const char* name = (argc >= 1) ? argv[0].c_str() : NULL;
70
36
  float size = (argc >= 2) ? to<float>(argv[1]) : 0;
@@ -72,51 +38,49 @@ RUBY_DEFN(initialize)
72
38
 
73
39
  return self;
74
40
  }
75
- RUBY_END
41
+ RUCY_END
76
42
 
77
43
  static
78
- RUBY_DEF0(name)
44
+ RUCY_DEF1(initialize_copy, obj)
79
45
  {
80
- CHECK;
46
+ RUCY_CHECK_OBJ(Rays::Font, cFont, self);
81
47
 
82
- return value(THIS->name().c_str());
48
+ *THIS = to<Rays::Font&>(obj).copy();
49
+ return self;
83
50
  }
84
- RUBY_END
51
+ RUCY_END
85
52
 
86
53
  static
87
- RUBY_DEF0(size)
54
+ RUCY_DEF0(name)
88
55
  {
89
56
  CHECK;
57
+ return value(THIS->name().c_str());
58
+ }
59
+ RUCY_END
90
60
 
61
+ static
62
+ RUCY_DEF0(size)
63
+ {
64
+ CHECK;
91
65
  return value(THIS->size());
92
66
  }
93
- RUBY_END
67
+ RUCY_END
94
68
 
95
69
  static
96
- RUBY_DEF1(width, str)
70
+ RUCY_DEF1(width, str)
97
71
  {
98
72
  CHECK;
99
-
100
- coord width = 0;
101
- if (!THIS->get_width(&width, str.c_str()))
102
- rays_error("Font#width(%s) failed.", str.inspect().c_str());
103
-
104
- return value(width);
73
+ return value(THIS->get_width(str.c_str()));
105
74
  }
106
- RUBY_END
75
+ RUCY_END
107
76
 
108
77
  static
109
- RUBY_DEF0(height)
78
+ RUCY_DEF0(height)
110
79
  {
111
80
  CHECK;
112
-
113
- coord height = 0;
114
- if (!THIS->get_height(&height))
115
- rays_error("Font#height() failed.");
116
-
117
- return value(height);
81
+ return value(THIS->get_height());
118
82
  }
119
- RUBY_END
83
+ RUCY_END
120
84
 
121
85
 
122
86
  void
@@ -127,8 +91,23 @@ Init_font ()
127
91
  cFont = mRays.define_class("Font");
128
92
  cFont.define_alloc_func(alloc);
129
93
  cFont.define_private_method("initialize", initialize);
94
+ cFont.define_private_method("initialize_copy", initialize_copy);
130
95
  cFont.define_method("name", name);
131
96
  cFont.define_method("size", size);
132
97
  cFont.define_method("width", width);
133
98
  cFont.define_method("height", height);
134
99
  }
100
+
101
+
102
+ namespace Rays
103
+ {
104
+
105
+
106
+ Class
107
+ font_class ()
108
+ {
109
+ return cFont;
110
+ }
111
+
112
+
113
+ }// Rays