rays 0.1.11 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.doc/ext/rays/bitmap.cpp +22 -76
- data/.doc/ext/rays/bounds.cpp +95 -125
- data/.doc/ext/rays/camera.cpp +88 -0
- data/.doc/ext/rays/color.cpp +223 -45
- data/.doc/ext/rays/color_space.cpp +146 -46
- data/.doc/ext/rays/defs.cpp +183 -0
- data/.doc/ext/rays/font.cpp +69 -21
- data/.doc/ext/rays/image.cpp +26 -37
- data/.doc/ext/rays/matrix.cpp +186 -29
- data/.doc/ext/rays/native.cpp +14 -8
- data/.doc/ext/rays/noise.cpp +53 -0
- data/.doc/ext/rays/painter.cpp +187 -292
- data/.doc/ext/rays/point.cpp +96 -77
- data/.doc/ext/rays/polygon.cpp +313 -0
- data/.doc/ext/rays/polygon_line.cpp +96 -0
- data/.doc/ext/rays/polyline.cpp +167 -0
- data/.doc/ext/rays/rays.cpp +103 -12
- data/.doc/ext/rays/shader.cpp +83 -9
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/Rakefile +24 -9
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +22 -80
- data/ext/rays/bounds.cpp +100 -128
- data/ext/rays/camera.cpp +94 -0
- data/ext/rays/color.cpp +231 -51
- data/ext/rays/color_space.cpp +149 -47
- data/ext/rays/defs.cpp +183 -0
- data/ext/rays/defs.h +26 -2
- data/ext/rays/extconf.rb +2 -3
- data/ext/rays/font.cpp +74 -24
- data/ext/rays/image.cpp +28 -40
- data/ext/rays/matrix.cpp +198 -30
- data/ext/rays/native.cpp +14 -8
- data/ext/rays/noise.cpp +55 -0
- data/ext/rays/painter.cpp +203 -298
- data/ext/rays/point.cpp +105 -81
- data/ext/rays/polygon.cpp +329 -0
- data/ext/rays/polygon_line.cpp +99 -0
- data/ext/rays/polyline.cpp +176 -0
- data/ext/rays/rays.cpp +103 -13
- data/ext/rays/shader.cpp +84 -9
- data/include/rays.h +10 -2
- data/include/rays/bitmap.h +14 -26
- data/include/rays/bounds.h +21 -4
- data/include/rays/camera.h +49 -0
- data/include/rays/color.h +25 -14
- data/include/rays/color_space.h +15 -10
- data/include/rays/coord.h +114 -0
- data/include/rays/debug.h +22 -0
- data/include/rays/defs.h +36 -0
- data/include/rays/exception.h +6 -2
- data/include/rays/font.h +4 -4
- data/include/rays/image.h +12 -18
- data/include/rays/matrix.h +50 -24
- data/include/rays/noise.h +42 -0
- data/include/rays/opengl.h +2 -50
- data/include/rays/painter.h +89 -93
- data/include/rays/point.h +44 -51
- data/include/rays/polygon.h +198 -0
- data/include/rays/polyline.h +71 -0
- data/include/rays/rays.h +3 -0
- data/include/rays/ruby.h +7 -1
- data/include/rays/ruby/bounds.h +1 -1
- data/include/rays/ruby/camera.h +41 -0
- data/include/rays/ruby/color.h +1 -1
- data/include/rays/ruby/color_space.h +1 -1
- data/include/rays/ruby/font.h +1 -1
- data/include/rays/ruby/matrix.h +1 -1
- data/include/rays/ruby/point.h +1 -1
- data/include/rays/ruby/polygon.h +52 -0
- data/include/rays/ruby/polyline.h +41 -0
- data/include/rays/ruby/rays.h +8 -0
- data/include/rays/ruby/shader.h +1 -1
- data/include/rays/shader.h +36 -8
- data/lib/rays.rb +7 -2
- data/lib/rays/bitmap.rb +0 -15
- data/lib/rays/bounds.rb +17 -23
- data/lib/rays/camera.rb +21 -0
- data/lib/rays/color.rb +20 -47
- data/lib/rays/color_space.rb +13 -13
- data/lib/rays/image.rb +3 -7
- data/lib/rays/matrix.rb +28 -0
- data/lib/rays/module.rb +4 -19
- data/lib/rays/painter.rb +78 -93
- data/lib/rays/point.rb +13 -21
- data/lib/rays/polygon.rb +58 -0
- data/lib/rays/polygon_line.rb +36 -0
- data/lib/rays/polyline.rb +32 -0
- data/lib/rays/shader.rb +20 -1
- data/rays.gemspec +5 -7
- data/src/bitmap.h +36 -0
- data/src/bounds.cpp +74 -11
- data/src/color.cpp +58 -23
- data/src/color_space.cpp +52 -34
- data/src/color_space.h +22 -0
- data/src/coord.cpp +170 -0
- data/src/coord.h +35 -0
- data/src/font.cpp +118 -0
- data/src/font.h +64 -0
- data/src/frame_buffer.cpp +37 -71
- data/src/frame_buffer.h +4 -4
- data/src/image.cpp +172 -98
- data/src/image.h +25 -0
- data/src/ios/bitmap.h +21 -0
- data/src/ios/bitmap.mm +129 -110
- data/src/ios/camera.mm +236 -0
- data/src/ios/font.mm +50 -62
- data/src/ios/helper.h +2 -2
- data/src/ios/opengl.mm +19 -4
- data/src/ios/rays.mm +3 -0
- data/src/matrix.cpp +111 -26
- data/src/matrix.h +30 -0
- data/src/noise.cpp +74 -0
- data/src/opengl.cpp +9 -27
- data/src/opengl.h +37 -0
- data/src/osx/bitmap.h +21 -0
- data/src/osx/bitmap.mm +129 -110
- data/src/osx/camera.mm +236 -0
- data/src/osx/font.mm +49 -62
- data/src/osx/helper.h +2 -2
- data/src/osx/opengl.mm +19 -83
- data/src/osx/rays.mm +3 -0
- data/src/painter.cpp +845 -671
- data/src/painter.h +24 -0
- data/src/point.cpp +140 -119
- data/src/polygon.cpp +1266 -0
- data/src/polygon.h +32 -0
- data/src/polyline.cpp +160 -0
- data/src/polyline.h +69 -0
- data/src/render_buffer.cpp +11 -4
- data/src/render_buffer.h +2 -2
- data/src/shader.cpp +163 -106
- data/src/shader.h +38 -0
- data/src/shader_program.cpp +533 -0
- data/src/{program.h → shader_program.h} +28 -16
- data/src/shader_source.cpp +140 -0
- data/src/shader_source.h +52 -0
- data/src/texture.cpp +136 -160
- data/src/texture.h +65 -0
- data/src/win32/bitmap.cpp +62 -52
- data/src/win32/font.cpp +11 -13
- data/src/win32/font.h +24 -0
- data/src/win32/gdi.h +6 -6
- data/test/helper.rb +0 -3
- data/test/test_bitmap.rb +31 -7
- data/test/test_bounds.rb +36 -0
- data/test/test_color.rb +59 -19
- data/test/test_color_space.rb +95 -0
- data/test/test_font.rb +5 -0
- data/test/test_image.rb +24 -20
- data/test/test_matrix.rb +106 -0
- data/test/test_painter.rb +157 -51
- data/test/test_painter_shape.rb +102 -0
- data/test/test_point.rb +29 -0
- data/test/test_polygon.rb +234 -0
- data/test/test_polygon_line.rb +167 -0
- data/test/test_polyline.rb +171 -0
- data/test/test_shader.rb +9 -9
- metadata +102 -70
- data/.doc/ext/rays/texture.cpp +0 -138
- data/ext/rays/texture.cpp +0 -149
- data/include/rays/ruby/texture.h +0 -41
- data/include/rays/texture.h +0 -71
- data/lib/rays/texture.rb +0 -24
- data/src/program.cpp +0 -648
- data/test/test_texture.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 257d69d9a622000399ced2465f798ffa54db2e1943cc9eeea9c1a0d3f40503c2
|
4
|
+
data.tar.gz: 302a565d951db2bdbb8d7fcf114fc26064ed55e9b1936f7683f24b77975d70d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69618fc55b5fe15c1f13c49f4e52e468f734ceb874a5cffc0186747595ad0df06f096b63a2b6e6e8271327385373e1c9efe6b23954c94064e961d3e547658577
|
7
|
+
data.tar.gz: d0c8e174262e60747382005cefcc0c7ebf7a03d8300ea607976f861dcc0dbec61bff530aad0d890df4cfd05b116cc3b6f5d119a97be6c4e63e061dd89731b0df
|
data/.doc/ext/rays/bitmap.cpp
CHANGED
@@ -1,23 +1,12 @@
|
|
1
1
|
#include "rays/ruby/bitmap.h"
|
2
2
|
|
3
3
|
|
4
|
-
#include <rucy.h>
|
5
|
-
#include "rays/exception.h"
|
6
4
|
#include "rays/ruby/color_space.h"
|
7
5
|
#include "rays/ruby/color.h"
|
8
6
|
#include "rays/ruby/font.h"
|
9
|
-
#include "rays/ruby/texture.h"
|
10
7
|
#include "defs.h"
|
11
8
|
|
12
9
|
|
13
|
-
using namespace Rucy;
|
14
|
-
|
15
|
-
using Rays::uchar;
|
16
|
-
using Rays::ushort;
|
17
|
-
using Rays::uint;
|
18
|
-
using Rays::coord;
|
19
|
-
|
20
|
-
|
21
10
|
RUCY_DEFINE_VALUE_FROM_TO(Rays::Bitmap)
|
22
11
|
|
23
12
|
#define THIS to<Rays::Bitmap*>(self)
|
@@ -32,40 +21,24 @@ VALUE alloc(VALUE klass)
|
|
32
21
|
}
|
33
22
|
|
34
23
|
static
|
35
|
-
VALUE
|
24
|
+
VALUE initialize(VALUE self)
|
36
25
|
{
|
37
26
|
RUCY_CHECK_OBJ(Rays::Bitmap, self);
|
27
|
+
check_arg_count(__FILE__, __LINE__, "Bitmap#initialize", argc, 2, 3);
|
38
28
|
|
39
|
-
*THIS =
|
40
|
-
|
41
|
-
|
29
|
+
*THIS = Rays::Bitmap(
|
30
|
+
to<int>(argv[0]), to<int>(argv[1]),
|
31
|
+
argc >= 3 ? to<Rays::ColorSpace>(argv[2]) : Rays::RGBA);
|
42
32
|
|
43
|
-
static
|
44
|
-
VALUE setup(VALUE self, VALUE width, VALUE height, VALUE color_space)
|
45
|
-
{
|
46
|
-
RUCY_CHECK_OBJ(Rays::Bitmap, self);
|
47
|
-
|
48
|
-
Rays::ColorSpace* cs = to<Rays::ColorSpace*>(color_space);
|
49
|
-
if (!cs)
|
50
|
-
argument_error(__FILE__, __LINE__);
|
51
|
-
|
52
|
-
*THIS = Rays::Bitmap(to<int>(width), to<int>(height), *cs);
|
53
33
|
return self;
|
54
34
|
}
|
55
35
|
|
56
36
|
static
|
57
|
-
VALUE
|
37
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
58
38
|
{
|
59
|
-
|
60
|
-
check_arg_count(__FILE__, __LINE__, "Bitmap#draw_string", argc, 1, 2, 3, 4);
|
61
|
-
|
62
|
-
const char* str = to<const char*>(argv[0]);
|
63
|
-
coord x = argc >= 2 ? to<coord>(argv[1]) : 0;
|
64
|
-
coord y = argc >= 3 ? to<coord>(argv[2]) : 0;
|
65
|
-
const Rays::Font* font = argc >= 4
|
66
|
-
? to<Rays::Font*>(argv[3]) : &Rays::default_font();
|
39
|
+
RUCY_CHECK_OBJ(Rays::Bitmap, self);
|
67
40
|
|
68
|
-
Rays::
|
41
|
+
*THIS = to<Rays::Bitmap&>(obj).dup();
|
69
42
|
return self;
|
70
43
|
}
|
71
44
|
|
@@ -94,50 +67,27 @@ VALUE color_space(VALUE self)
|
|
94
67
|
}
|
95
68
|
|
96
69
|
static
|
97
|
-
VALUE
|
98
|
-
{
|
99
|
-
CHECK;
|
100
|
-
|
101
|
-
return value(Rays::Color(THIS->at<void>(x.as_i(), y.as_i()), THIS->color_space()));
|
102
|
-
}
|
103
|
-
|
104
|
-
static
|
105
|
-
VALUE set_at(VALUE self, VALUE x, VALUE y, VALUE color)
|
70
|
+
VALUE set_at(VALUE self)
|
106
71
|
{
|
107
72
|
CHECK;
|
73
|
+
check_arg_count(__FILE__, __LINE__, "Bitmap#set_at", argc, 3, 4, 5, 6);
|
108
74
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
col->get(THIS->at<void>(x.as_i(), y.as_i()), THIS->color_space());
|
75
|
+
int x = to<int>(argv[0]);
|
76
|
+
int y = to<int>(argv[1]);
|
77
|
+
Rays::Color color = to<Rays::Color>(argc - 2, argv + 2);
|
114
78
|
|
115
|
-
|
79
|
+
color.get(THIS->at<void>(x, y), THIS->color_space());
|
80
|
+
return value(color);
|
116
81
|
}
|
117
82
|
|
118
83
|
static
|
119
|
-
VALUE
|
84
|
+
VALUE get_at(VALUE self, VALUE x, VALUE y)
|
120
85
|
{
|
121
86
|
CHECK;
|
122
87
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
static
|
128
|
-
VALUE save(VALUE self, VALUE path)
|
129
|
-
{
|
130
|
-
CHECK;
|
131
|
-
|
132
|
-
Rays::save_bitmap(*THIS, path.c_str());
|
133
|
-
return self;
|
134
|
-
}
|
135
|
-
|
136
|
-
|
137
|
-
static
|
138
|
-
VALUE load(VALUE self, VALUE path)
|
139
|
-
{
|
140
|
-
return value(Rays::load_bitmap(path.c_str()));
|
88
|
+
int xx = to<int>(x);
|
89
|
+
int yy = to<int>(y);
|
90
|
+
return value(Rays::Color(THIS->at<void>(xx, yy), THIS->color_space()));
|
141
91
|
}
|
142
92
|
|
143
93
|
|
@@ -150,17 +100,13 @@ Init_bitmap ()
|
|
150
100
|
|
151
101
|
cBitmap = rb_define_class_under(mRays, "Bitmap", rb_cObject);
|
152
102
|
rb_define_alloc_func(cBitmap, alloc);
|
103
|
+
rb_define_private_method(cBitmap, "initialize", RUBY_METHOD_FUNC(initialize), -1);
|
153
104
|
rb_define_private_method(cBitmap, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
154
|
-
rb_define_private_method(cBitmap, "setup", RUBY_METHOD_FUNC(setup), 3);
|
155
|
-
rb_define_method(cBitmap, "draw_string", RUBY_METHOD_FUNC(draw_string), -1);
|
156
105
|
rb_define_method(cBitmap, "width", RUBY_METHOD_FUNC(width), 0);
|
157
106
|
rb_define_method(cBitmap, "height", RUBY_METHOD_FUNC(height), 0);
|
158
107
|
rb_define_method(cBitmap, "color_space", RUBY_METHOD_FUNC(color_space), 0);
|
159
|
-
cBitmap.define_method("[]",
|
160
|
-
|
161
|
-
rb_define_method(cBitmap, "to_texture", RUBY_METHOD_FUNC(to_texture), -1);
|
162
|
-
rb_define_method(cBitmap, "save", RUBY_METHOD_FUNC(save), 1);
|
163
|
-
rb_define_function(cBitmap, "load", RUBY_METHOD_FUNC(load), 1);
|
108
|
+
cBitmap.define_method("[]=", set_at);
|
109
|
+
cBitmap.define_method("[]", get_at);
|
164
110
|
}
|
165
111
|
|
166
112
|
|
data/.doc/ext/rays/bounds.cpp
CHANGED
@@ -1,17 +1,11 @@
|
|
1
1
|
#include "rays/ruby/bounds.h"
|
2
2
|
|
3
3
|
|
4
|
-
#include <rucy.h>
|
5
4
|
#include "rays/ruby/point.h"
|
6
5
|
#include "defs.h"
|
7
6
|
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
using Rays::coord;
|
12
|
-
|
13
|
-
|
14
|
-
RUCY_DEFINE_VALUE_FROM_TO(Rays::Bounds)
|
8
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Bounds)
|
15
9
|
|
16
10
|
#define THIS to<Rays::Bounds*>(self)
|
17
11
|
|
@@ -30,35 +24,8 @@ VALUE initialize(VALUE self)
|
|
30
24
|
CHECK;
|
31
25
|
check_arg_count(__FILE__, __LINE__, "Bounds#initialize", argc, 0, 1, 2, 3, 4, 6);
|
32
26
|
|
33
|
-
if (argc
|
34
|
-
|
35
|
-
switch (argc)
|
36
|
-
{
|
37
|
-
case 1:
|
38
|
-
*THIS = Rays::Bounds(to<coord>(argv[0]));
|
39
|
-
break;
|
40
|
-
|
41
|
-
case 2:
|
42
|
-
*THIS = Rays::Bounds(to<coord>(argv[0]), to<coord>(argv[1]));
|
43
|
-
break;
|
44
|
-
|
45
|
-
case 3:
|
46
|
-
*THIS = Rays::Bounds(
|
47
|
-
to<coord>(argv[0]), to<coord>(argv[1]), to<coord>(argv[2]));
|
48
|
-
break;
|
49
|
-
|
50
|
-
case 4:
|
51
|
-
*THIS = Rays::Bounds(
|
52
|
-
to<coord>(argv[0]), to<coord>(argv[1]),
|
53
|
-
to<coord>(argv[2]), to<coord>(argv[3]));
|
54
|
-
break;
|
55
|
-
|
56
|
-
case 6:
|
57
|
-
*THIS = Rays::Bounds(
|
58
|
-
to<coord>(argv[0]), to<coord>(argv[1]), to<coord>(argv[2]),
|
59
|
-
to<coord>(argv[3]), to<coord>(argv[4]), to<coord>(argv[5]));
|
60
|
-
break;
|
61
|
-
}
|
27
|
+
if (argc >= 1)
|
28
|
+
*THIS = to<Rays::Bounds>(argc, argv);
|
62
29
|
|
63
30
|
return self;
|
64
31
|
}
|
@@ -67,6 +34,7 @@ static
|
|
67
34
|
VALUE initialize_copy(VALUE self, VALUE obj)
|
68
35
|
{
|
69
36
|
CHECK;
|
37
|
+
|
70
38
|
*THIS = to<Rays::Bounds&>(obj);
|
71
39
|
return self;
|
72
40
|
}
|
@@ -112,7 +80,7 @@ VALUE move_to(VALUE self)
|
|
112
80
|
}
|
113
81
|
|
114
82
|
const Rays::Point& p = THIS->position();
|
115
|
-
coord x =
|
83
|
+
coord x = argv[0] ? to<coord>(argv[0]) : p.x;
|
116
84
|
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : p.y;
|
117
85
|
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : p.z;
|
118
86
|
THIS->move_to(x, y, z);
|
@@ -137,7 +105,7 @@ VALUE move_by(VALUE self)
|
|
137
105
|
argv = argv[0].as_array();
|
138
106
|
}
|
139
107
|
|
140
|
-
coord x =
|
108
|
+
coord x = argv[0] ? to<coord>(argv[0]) : 0;
|
141
109
|
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : 0;
|
142
110
|
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : 0;
|
143
111
|
THIS->move_by(x, y, z);
|
@@ -163,7 +131,7 @@ VALUE resize_to(VALUE self)
|
|
163
131
|
}
|
164
132
|
|
165
133
|
const Rays::Point& p = THIS->size();
|
166
|
-
coord x =
|
134
|
+
coord x = argv[0] ? to<coord>(argv[0]) : p.x;
|
167
135
|
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : p.y;
|
168
136
|
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : p.z;
|
169
137
|
THIS->resize_to(x, y, z);
|
@@ -188,7 +156,7 @@ VALUE resize_by(VALUE self)
|
|
188
156
|
argv = argv[0].as_array();
|
189
157
|
}
|
190
158
|
|
191
|
-
coord x =
|
159
|
+
coord x = argv[0] ? to<coord>(argv[0]) : 0;
|
192
160
|
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : 0;
|
193
161
|
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : 0;
|
194
162
|
THIS->resize_by(x, y, z);
|
@@ -213,7 +181,7 @@ VALUE inset_by(VALUE self)
|
|
213
181
|
argv = argv[0].as_array();
|
214
182
|
}
|
215
183
|
|
216
|
-
coord x =
|
184
|
+
coord x = argv[0] ? to<coord>(argv[0]) : 0;
|
217
185
|
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : 0;
|
218
186
|
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : 0;
|
219
187
|
THIS->inset_by(x, y, z);
|
@@ -222,12 +190,21 @@ VALUE inset_by(VALUE self)
|
|
222
190
|
return self;
|
223
191
|
}
|
224
192
|
|
193
|
+
static
|
194
|
+
VALUE is_valid(VALUE self)
|
195
|
+
{
|
196
|
+
CHECK;
|
197
|
+
|
198
|
+
return value(THIS->operator bool());
|
199
|
+
}
|
200
|
+
|
225
201
|
static
|
226
202
|
VALUE set_x(VALUE self, VALUE x)
|
227
203
|
{
|
228
204
|
CHECK;
|
229
205
|
|
230
|
-
|
206
|
+
THIS->x = to<coord>(x);
|
207
|
+
return x;
|
231
208
|
}
|
232
209
|
|
233
210
|
static
|
@@ -243,7 +220,8 @@ VALUE set_y(VALUE self, VALUE y)
|
|
243
220
|
{
|
244
221
|
CHECK;
|
245
222
|
|
246
|
-
|
223
|
+
THIS->y = to<coord>(y);
|
224
|
+
return y;
|
247
225
|
}
|
248
226
|
|
249
227
|
static
|
@@ -259,7 +237,8 @@ VALUE set_z(VALUE self, VALUE z)
|
|
259
237
|
{
|
260
238
|
CHECK;
|
261
239
|
|
262
|
-
|
240
|
+
THIS->z = to<coord>(z);
|
241
|
+
return z;
|
263
242
|
}
|
264
243
|
|
265
244
|
static
|
@@ -275,7 +254,8 @@ VALUE set_width(VALUE self, VALUE width)
|
|
275
254
|
{
|
276
255
|
CHECK;
|
277
256
|
|
278
|
-
|
257
|
+
THIS->width = to<coord>(width);
|
258
|
+
return width;
|
279
259
|
}
|
280
260
|
|
281
261
|
static
|
@@ -291,7 +271,8 @@ VALUE set_height(VALUE self, VALUE height)
|
|
291
271
|
{
|
292
272
|
CHECK;
|
293
273
|
|
294
|
-
|
274
|
+
THIS->height = to<coord>(height);
|
275
|
+
return height;
|
295
276
|
}
|
296
277
|
|
297
278
|
static
|
@@ -307,7 +288,8 @@ VALUE set_depth(VALUE self, VALUE depth)
|
|
307
288
|
{
|
308
289
|
CHECK;
|
309
290
|
|
310
|
-
|
291
|
+
THIS->depth = to<coord>(depth);
|
292
|
+
return depth;
|
311
293
|
}
|
312
294
|
|
313
295
|
static
|
@@ -322,10 +304,9 @@ static
|
|
322
304
|
VALUE set_left(VALUE self, VALUE left)
|
323
305
|
{
|
324
306
|
CHECK;
|
325
|
-
Rays::Bounds* this_ = THIS;
|
326
307
|
|
327
|
-
|
328
|
-
return
|
308
|
+
THIS->set_left(to<coord>(left));
|
309
|
+
return left;
|
329
310
|
}
|
330
311
|
|
331
312
|
static
|
@@ -340,10 +321,9 @@ static
|
|
340
321
|
VALUE set_right(VALUE self, VALUE right)
|
341
322
|
{
|
342
323
|
CHECK;
|
343
|
-
Rays::Bounds* this_ = THIS;
|
344
324
|
|
345
|
-
|
346
|
-
return
|
325
|
+
THIS->set_right(to<coord>(right));
|
326
|
+
return right;
|
347
327
|
}
|
348
328
|
|
349
329
|
static
|
@@ -358,10 +338,9 @@ static
|
|
358
338
|
VALUE set_top(VALUE self, VALUE top)
|
359
339
|
{
|
360
340
|
CHECK;
|
361
|
-
Rays::Bounds* this_ = THIS;
|
362
341
|
|
363
|
-
|
364
|
-
return
|
342
|
+
THIS->set_top(to<coord>(top));
|
343
|
+
return top;
|
365
344
|
}
|
366
345
|
|
367
346
|
static
|
@@ -376,10 +355,9 @@ static
|
|
376
355
|
VALUE set_bottom(VALUE self, VALUE bottom)
|
377
356
|
{
|
378
357
|
CHECK;
|
379
|
-
Rays::Bounds* this_ = THIS;
|
380
358
|
|
381
|
-
|
382
|
-
return
|
359
|
+
THIS->set_bottom(to<coord>(bottom));
|
360
|
+
return bottom;
|
383
361
|
}
|
384
362
|
|
385
363
|
static
|
@@ -394,10 +372,9 @@ static
|
|
394
372
|
VALUE set_back(VALUE self, VALUE back)
|
395
373
|
{
|
396
374
|
CHECK;
|
397
|
-
Rays::Bounds* this_ = THIS;
|
398
375
|
|
399
|
-
|
400
|
-
return
|
376
|
+
THIS->set_back(to<coord>(back));
|
377
|
+
return back;
|
401
378
|
}
|
402
379
|
|
403
380
|
static
|
@@ -412,10 +389,9 @@ static
|
|
412
389
|
VALUE set_front(VALUE self, VALUE front)
|
413
390
|
{
|
414
391
|
CHECK;
|
415
|
-
Rays::Bounds* this_ = THIS;
|
416
392
|
|
417
|
-
|
418
|
-
return
|
393
|
+
THIS->set_front(to<coord>(front));
|
394
|
+
return front;
|
419
395
|
}
|
420
396
|
|
421
397
|
static
|
@@ -430,11 +406,9 @@ static
|
|
430
406
|
VALUE set_position(VALUE self)
|
431
407
|
{
|
432
408
|
CHECK;
|
433
|
-
check_arg_count(__FILE__, __LINE__, "Bounds#set_position", argc, 1, 2, 3);
|
434
409
|
|
435
|
-
|
436
|
-
|
437
|
-
if (argc > i && !argv[i].is_nil()) pos[i] = to<coord>(argv[i]);
|
410
|
+
THIS->set_position(to<Rays::Point>(argc, argv));
|
411
|
+
return value(THIS->position());
|
438
412
|
}
|
439
413
|
|
440
414
|
static
|
@@ -449,11 +423,9 @@ static
|
|
449
423
|
VALUE set_size(VALUE self)
|
450
424
|
{
|
451
425
|
CHECK;
|
452
|
-
check_arg_count(__FILE__, __LINE__, "Bounds#set_size", argc, 1, 2, 3);
|
453
426
|
|
454
|
-
|
455
|
-
|
456
|
-
if (argc > i && !argv[i].is_nil()) size[i] = to<coord>(argv[i]);
|
427
|
+
THIS->set_size(to<Rays::Point>(argc, argv));
|
428
|
+
return value(THIS->size());
|
457
429
|
}
|
458
430
|
|
459
431
|
static
|
@@ -468,24 +440,13 @@ static
|
|
468
440
|
VALUE set_center(VALUE self)
|
469
441
|
{
|
470
442
|
CHECK;
|
471
|
-
check_arg_count(__FILE__, __LINE__, "Bounds#set_center", argc, 1, 2, 3);
|
472
|
-
|
473
|
-
if (argv[0].is_kind_of(Rays::point_class()))
|
474
|
-
THIS->set_center(to<Rays::Point&>(argv[0]));
|
475
|
-
else
|
476
|
-
{
|
477
|
-
Rays::Point p = THIS->center();
|
478
|
-
coord x = (argc >= 1 && argv[0]) ? to<coord>(argv[0]) : p.x;
|
479
|
-
coord y = (argc >= 2 && argv[1]) ? to<coord>(argv[1]) : p.y;
|
480
|
-
coord z = (argc >= 3 && argv[2]) ? to<coord>(argv[2]) : p.z;
|
481
|
-
THIS->set_center(x, y, z);
|
482
|
-
}
|
483
443
|
|
444
|
+
THIS->set_center(to<Rays::Point>(argc, argv));
|
484
445
|
return value(THIS->center());
|
485
446
|
}
|
486
447
|
|
487
448
|
static
|
488
|
-
VALUE
|
449
|
+
VALUE get_center(VALUE self)
|
489
450
|
{
|
490
451
|
CHECK;
|
491
452
|
|
@@ -493,7 +454,7 @@ VALUE center(VALUE self)
|
|
493
454
|
}
|
494
455
|
|
495
456
|
static
|
496
|
-
VALUE
|
457
|
+
VALUE set_at(VALUE self, VALUE index, VALUE value)
|
497
458
|
{
|
498
459
|
CHECK;
|
499
460
|
|
@@ -501,11 +462,12 @@ VALUE array_get(VALUE self, VALUE index)
|
|
501
462
|
if (i < 0 || 1 < i)
|
502
463
|
index_error(__FILE__, __LINE__);
|
503
464
|
|
504
|
-
|
465
|
+
(*THIS)[i] = to<Rays::Point&>(value);
|
466
|
+
return value;
|
505
467
|
}
|
506
468
|
|
507
469
|
static
|
508
|
-
VALUE
|
470
|
+
VALUE get_at(VALUE self, VALUE index)
|
509
471
|
{
|
510
472
|
CHECK;
|
511
473
|
|
@@ -513,12 +475,11 @@ VALUE array_set(VALUE self, VALUE index, VALUE value)
|
|
513
475
|
if (i < 0 || 1 < i)
|
514
476
|
index_error(__FILE__, __LINE__);
|
515
477
|
|
516
|
-
(*THIS)[i]
|
517
|
-
return value;
|
478
|
+
return value((*THIS)[i]);
|
518
479
|
}
|
519
480
|
|
520
481
|
static
|
521
|
-
VALUE
|
482
|
+
VALUE op_and(VALUE self, VALUE bounds)
|
522
483
|
{
|
523
484
|
CHECK;
|
524
485
|
|
@@ -528,12 +489,18 @@ VALUE and_(VALUE self, VALUE bounds)
|
|
528
489
|
}
|
529
490
|
|
530
491
|
static
|
531
|
-
VALUE
|
492
|
+
VALUE op_or(VALUE self, VALUE arg)
|
532
493
|
{
|
533
494
|
CHECK;
|
534
495
|
|
535
496
|
Rays::Bounds b = *THIS;
|
536
|
-
|
497
|
+
if (arg.is_kind_of(Rays::bounds_class()))
|
498
|
+
b |= to<Rays::Bounds&>(arg);
|
499
|
+
else if (arg.is_kind_of(Rays::point_class()))
|
500
|
+
b |= to<Rays::Point&>(arg);
|
501
|
+
else
|
502
|
+
argument_error(__FILE__, __LINE__);
|
503
|
+
|
537
504
|
return value(b);
|
538
505
|
}
|
539
506
|
|
@@ -545,6 +512,12 @@ VALUE inspect(VALUE self)
|
|
545
512
|
return value(Xot::stringf("#<Rays::Bounds %s>", THIS->inspect().c_str()));
|
546
513
|
}
|
547
514
|
|
515
|
+
static
|
516
|
+
VALUE invalid(VALUE self)
|
517
|
+
{
|
518
|
+
return value(Rays::invalid_bounds());
|
519
|
+
}
|
520
|
+
|
548
521
|
|
549
522
|
static Class cBounds;
|
550
523
|
|
@@ -564,6 +537,7 @@ Init_bounds ()
|
|
564
537
|
cBounds.define_method("resize_to!", resize_to);
|
565
538
|
cBounds.define_method("resize_by!", resize_by);
|
566
539
|
cBounds.define_method("inset_by!", inset_by);
|
540
|
+
cBounds.define_method("valid?", is_valid);
|
567
541
|
rb_define_method(cBounds, "x=", RUBY_METHOD_FUNC(set_x), 1);
|
568
542
|
rb_define_method(cBounds, "x", RUBY_METHOD_FUNC(get_x), 0);
|
569
543
|
rb_define_method(cBounds, "y=", RUBY_METHOD_FUNC(set_y), 1);
|
@@ -588,17 +562,18 @@ Init_bounds ()
|
|
588
562
|
rb_define_method(cBounds, "back", RUBY_METHOD_FUNC(get_back), 0);
|
589
563
|
rb_define_method(cBounds, "front=", RUBY_METHOD_FUNC(set_front), 1);
|
590
564
|
rb_define_method(cBounds, "front", RUBY_METHOD_FUNC(get_front), 0);
|
591
|
-
rb_define_method(cBounds, "
|
565
|
+
rb_define_method(cBounds, "position=", RUBY_METHOD_FUNC(set_position), -1);
|
592
566
|
rb_define_method(cBounds, "position", RUBY_METHOD_FUNC(get_position), 0);
|
593
|
-
rb_define_method(cBounds, "
|
567
|
+
rb_define_method(cBounds, "size=", RUBY_METHOD_FUNC(set_size), -1);
|
594
568
|
rb_define_method(cBounds, "size", RUBY_METHOD_FUNC(get_size), 0);
|
595
|
-
rb_define_method(cBounds, "
|
596
|
-
rb_define_method(cBounds, "center", RUBY_METHOD_FUNC(
|
597
|
-
cBounds.define_method("[]",
|
598
|
-
cBounds.define_method("[]=",
|
599
|
-
cBounds.define_method("&",
|
600
|
-
cBounds.define_method("|",
|
569
|
+
rb_define_method(cBounds, "center=", RUBY_METHOD_FUNC(set_center), -1);
|
570
|
+
rb_define_method(cBounds, "center", RUBY_METHOD_FUNC(get_center), 0);
|
571
|
+
cBounds.define_method("[]", get_at);
|
572
|
+
cBounds.define_method("[]=", set_at);
|
573
|
+
cBounds.define_method("&", op_and);
|
574
|
+
cBounds.define_method("|", op_or);
|
601
575
|
rb_define_method(cBounds, "inspect", RUBY_METHOD_FUNC(inspect), 0);
|
576
|
+
rb_define_singleton_method(cBounds, "invalid", RUBY_METHOD_FUNC(invalid), 0);
|
602
577
|
}
|
603
578
|
|
604
579
|
|
@@ -607,29 +582,21 @@ namespace Rucy
|
|
607
582
|
|
608
583
|
|
609
584
|
template <> Rays::Bounds
|
610
|
-
value_to<Rays::Bounds> (Value
|
585
|
+
value_to<Rays::Bounds> (int argc, const Value* argv, bool convert)
|
611
586
|
{
|
612
|
-
if (
|
587
|
+
if (argc == 1 && argv->is_array())
|
613
588
|
{
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
{
|
618
|
-
argc = value.size();
|
619
|
-
argv = value.as_array();
|
620
|
-
}
|
621
|
-
else
|
622
|
-
{
|
623
|
-
argc = 1;
|
624
|
-
argv = &value;
|
625
|
-
}
|
589
|
+
argc = argv->size();
|
590
|
+
argv = argv->as_array();
|
591
|
+
}
|
626
592
|
|
627
|
-
|
628
|
-
Rucy::argument_error(__FILE__, __LINE__);
|
593
|
+
assert(argc == 0 || (argc > 0 && argv));
|
629
594
|
|
630
|
-
|
631
|
-
|
632
|
-
|
595
|
+
if (convert)
|
596
|
+
{
|
597
|
+
if (argc == 0)
|
598
|
+
return Rays::Bounds();
|
599
|
+
else if (argv->is_kind_of(Rays::point_class()))
|
633
600
|
{
|
634
601
|
switch (argc)
|
635
602
|
{
|
@@ -637,10 +604,10 @@ namespace Rucy
|
|
637
604
|
case 1: return Rays::Bounds(V(0));
|
638
605
|
case 2: return Rays::Bounds(V(0), V(1));
|
639
606
|
#undef V
|
640
|
-
default:
|
607
|
+
default: argument_error(__FILE__, __LINE__);
|
641
608
|
}
|
642
609
|
}
|
643
|
-
else if (argv
|
610
|
+
else if (argv->is_num())
|
644
611
|
{
|
645
612
|
switch (argc)
|
646
613
|
{
|
@@ -651,12 +618,15 @@ namespace Rucy
|
|
651
618
|
case 4: return Rays::Bounds(V(0), V(1), V(2), V(3));
|
652
619
|
case 6: return Rays::Bounds(V(0), V(1), V(2), V(3), V(4), V(5));
|
653
620
|
#undef V
|
654
|
-
default:
|
621
|
+
default: argument_error(__FILE__, __LINE__);
|
655
622
|
}
|
656
623
|
}
|
657
624
|
}
|
658
625
|
|
659
|
-
|
626
|
+
if (argc != 1)
|
627
|
+
argument_error(__FILE__, __LINE__);
|
628
|
+
|
629
|
+
return value_to<Rays::Bounds&>(*argv, convert);
|
660
630
|
}
|
661
631
|
|
662
632
|
|