rays 0.1.12 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- 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 +171 -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 +23 -81
- data/ext/rays/bounds.cpp +100 -128
- data/ext/rays/camera.cpp +186 -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 +74 -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 +24 -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 +23 -0
- data/src/ios/bitmap.mm +133 -110
- data/src/ios/camera.mm +510 -0
- data/src/ios/font.mm +50 -62
- data/src/ios/helper.h +4 -4
- 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 +23 -0
- data/src/osx/bitmap.mm +133 -110
- data/src/osx/camera.mm +451 -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
data/ext/rays/color_space.cpp
CHANGED
@@ -1,18 +1,65 @@
|
|
1
1
|
#include "rays/ruby/color_space.h"
|
2
2
|
|
3
3
|
|
4
|
-
#include <rucy.h>
|
5
4
|
#include "defs.h"
|
6
5
|
|
7
6
|
|
8
|
-
|
7
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::ColorSpace)
|
9
8
|
|
9
|
+
#define THIS to<Rays::ColorSpace*>(self)
|
10
10
|
|
11
|
-
|
11
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::ColorSpace, self)
|
12
12
|
|
13
|
-
#define THIS to<Rays::ColorSpace*>(self)
|
14
13
|
|
15
|
-
|
14
|
+
static struct ColorSpaceEnum
|
15
|
+
{
|
16
|
+
const char* name;
|
17
|
+
Rays::ColorSpaceType type;
|
18
|
+
}
|
19
|
+
COLOR_SPACES[] =
|
20
|
+
{
|
21
|
+
{"GRAY", Rays::GRAY},
|
22
|
+
{"ALPHA", Rays::ALPHA},
|
23
|
+
{"RGB", Rays:: RGB},
|
24
|
+
{"BGR", Rays:: BGR},
|
25
|
+
{"RGBA", Rays:: RGBA},
|
26
|
+
{"RGBX", Rays:: RGBX},
|
27
|
+
{"ARGB", Rays::ARGB},
|
28
|
+
{"XRGB", Rays::XRGB},
|
29
|
+
{"BGRA", Rays:: BGRA},
|
30
|
+
{"BGRX", Rays:: BGRX},
|
31
|
+
{"ABGR", Rays::ABGR},
|
32
|
+
{"XBGR", Rays::XBGR},
|
33
|
+
{"GRAY_8", Rays::GRAY_8},
|
34
|
+
{"GRAY_16", Rays::GRAY_16},
|
35
|
+
{"GRAY_24", Rays::GRAY_24},
|
36
|
+
{"GRAY_32", Rays::GRAY_32},
|
37
|
+
{"GRAY_float", Rays::GRAY_float},
|
38
|
+
{"ALPHA_8", Rays::ALPHA_8},
|
39
|
+
{"ALPHA_16", Rays::ALPHA_16},
|
40
|
+
{"ALPHA_24", Rays::ALPHA_24},
|
41
|
+
{"ALPHA_32", Rays::ALPHA_32},
|
42
|
+
{"ALPHA_float", Rays::ALPHA_float},
|
43
|
+
{"RGB_888", Rays:: RGB_888},
|
44
|
+
{"RGBA_8888", Rays:: RGBA_8888},
|
45
|
+
{"RGBX_8888", Rays:: RGBX_8888},
|
46
|
+
{"ARGB_8888", Rays::ARGB_8888},
|
47
|
+
{"XRGB_8888", Rays::XRGB_8888},
|
48
|
+
{"BGR_888", Rays:: BGR_888},
|
49
|
+
{"BGRA_8888", Rays:: BGRA_8888},
|
50
|
+
{"BGRX_8888", Rays:: BGRX_8888},
|
51
|
+
{"ABGR_8888", Rays::ABGR_8888},
|
52
|
+
{"XBGR_8888", Rays::XBGR_8888},
|
53
|
+
{"RGB_float", Rays:: RGB_float},
|
54
|
+
{"RGBA_float", Rays:: RGBA_float},
|
55
|
+
{"ARGB_float", Rays::ARGB_float},
|
56
|
+
{"BGR_float", Rays:: BGR_float},
|
57
|
+
{"BGRA_float", Rays:: BGRA_float},
|
58
|
+
{"ABGR_float", Rays::ABGR_float},
|
59
|
+
};
|
60
|
+
|
61
|
+
static const size_t COLOR_SPACES_SIZE =
|
62
|
+
sizeof(COLOR_SPACES) / sizeof(COLOR_SPACES[0]);
|
16
63
|
|
17
64
|
|
18
65
|
static
|
@@ -23,13 +70,12 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
23
70
|
RUCY_END
|
24
71
|
|
25
72
|
static
|
26
|
-
|
73
|
+
RUCY_DEFN(initialize)
|
27
74
|
{
|
28
|
-
|
75
|
+
RUCY_CHECK_OBJ(Rays::ColorSpace, self);
|
76
|
+
check_arg_count(__FILE__, __LINE__, "ColorSpace#initialize", argc, 1, 2);
|
29
77
|
|
30
|
-
*THIS = Rays::ColorSpace(
|
31
|
-
(Rays::ColorSpaceType) to<uint>(type),
|
32
|
-
to<bool>(premultiplied));
|
78
|
+
*THIS = to<Rays::ColorSpace>(argc, argv);
|
33
79
|
return self;
|
34
80
|
}
|
35
81
|
RUCY_END
|
@@ -61,6 +107,15 @@ RUCY_DEF0(is_gray)
|
|
61
107
|
}
|
62
108
|
RUCY_END
|
63
109
|
|
110
|
+
static
|
111
|
+
RUCY_DEF0(is_alpha)
|
112
|
+
{
|
113
|
+
CHECK;
|
114
|
+
|
115
|
+
return value(THIS->is_alpha());
|
116
|
+
}
|
117
|
+
RUCY_END
|
118
|
+
|
64
119
|
static
|
65
120
|
RUCY_DEF0(is_rgb)
|
66
121
|
{
|
@@ -115,6 +170,22 @@ RUCY_DEF0(is_premult)
|
|
115
170
|
}
|
116
171
|
RUCY_END
|
117
172
|
|
173
|
+
static
|
174
|
+
RUCY_DEF0(to_s)
|
175
|
+
{
|
176
|
+
CHECK;
|
177
|
+
|
178
|
+
Rays::ColorSpaceType type = THIS->type();
|
179
|
+
for (size_t i = 0; i < COLOR_SPACES_SIZE; ++i)
|
180
|
+
{
|
181
|
+
if (type == COLOR_SPACES[i].type)
|
182
|
+
return value(COLOR_SPACES[i].name);
|
183
|
+
}
|
184
|
+
|
185
|
+
invalid_object_error(__FILE__, __LINE__);
|
186
|
+
}
|
187
|
+
RUCY_END
|
188
|
+
|
118
189
|
|
119
190
|
static Class cColorSpace;
|
120
191
|
|
@@ -123,54 +194,85 @@ Init_color_space ()
|
|
123
194
|
{
|
124
195
|
Module mRays = define_module("Rays");
|
125
196
|
|
197
|
+
for (size_t i = 0; i < COLOR_SPACES_SIZE; ++i)
|
198
|
+
mRays.define_const(COLOR_SPACES[i].name, COLOR_SPACES[i].type);
|
199
|
+
|
126
200
|
cColorSpace = mRays.define_class("ColorSpace");
|
127
201
|
cColorSpace.define_alloc_func(alloc);
|
202
|
+
cColorSpace.define_private_method("initialize", initialize);
|
128
203
|
cColorSpace.define_private_method("initialize_copy", initialize_copy);
|
129
|
-
cColorSpace.
|
130
|
-
cColorSpace.define_method("type", type);
|
204
|
+
cColorSpace.define_method("type", type);
|
131
205
|
cColorSpace.define_method("gray?", is_gray);
|
206
|
+
cColorSpace.define_method("alpha?", is_alpha);
|
132
207
|
cColorSpace.define_method("rgb?", is_rgb);
|
133
208
|
cColorSpace.define_method("bgr?", is_bgr);
|
134
209
|
cColorSpace.define_method("float?", is_float);
|
135
|
-
cColorSpace.define_method("
|
136
|
-
cColorSpace.define_method("
|
210
|
+
cColorSpace.define_method("has_alpha?", has_alpha);
|
211
|
+
cColorSpace.define_method("has_skip?", has_skip);
|
137
212
|
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);
|
213
|
+
cColorSpace.define_method("to_s", to_s);
|
171
214
|
}
|
172
215
|
|
173
216
|
|
217
|
+
namespace Rucy
|
218
|
+
{
|
219
|
+
|
220
|
+
|
221
|
+
template <> Rays::ColorSpace
|
222
|
+
value_to<Rays::ColorSpace> (int argc, const Value* argv, bool convert)
|
223
|
+
{
|
224
|
+
if (argc == 1 && argv->is_array())
|
225
|
+
{
|
226
|
+
argc = argv->size();
|
227
|
+
argv = argv->as_array();
|
228
|
+
}
|
229
|
+
|
230
|
+
assert(argc > 0 && argv);
|
231
|
+
|
232
|
+
if (convert)
|
233
|
+
{
|
234
|
+
if (argv->is_i() || argv->is_s() || argv->is_sym())
|
235
|
+
{
|
236
|
+
return Rays::ColorSpace(
|
237
|
+
to<Rays::ColorSpaceType>(argv[0]),
|
238
|
+
argc >= 2 ? to<bool>(argv[1]) : true);
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
if (argc != 1)
|
243
|
+
argument_error(__FILE__, __LINE__);
|
244
|
+
|
245
|
+
return value_to<Rays::ColorSpace&>(*argv, convert);
|
246
|
+
}
|
247
|
+
|
248
|
+
|
249
|
+
template <> Rays::ColorSpaceType
|
250
|
+
value_to<Rays::ColorSpaceType> (Value value, bool convert)
|
251
|
+
{
|
252
|
+
if (convert)
|
253
|
+
{
|
254
|
+
if (value.is_s() || value.is_sym())
|
255
|
+
{
|
256
|
+
const char* str = value.c_str();
|
257
|
+
for (size_t i = 0; i < COLOR_SPACES_SIZE; ++i)
|
258
|
+
{
|
259
|
+
if (strcasecmp(str, COLOR_SPACES[i].name) == 0)
|
260
|
+
return COLOR_SPACES[i].type;
|
261
|
+
}
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
uint type = value_to<uint>(value, convert);
|
266
|
+
if (type >= Rays::COLORSPACE_MAX)
|
267
|
+
argument_error(__FILE__, __LINE__, "invalid color space type -- %d", type);
|
268
|
+
|
269
|
+
return (Rays::ColorSpaceType) type;
|
270
|
+
}
|
271
|
+
|
272
|
+
|
273
|
+
}// Rucy
|
274
|
+
|
275
|
+
|
174
276
|
namespace Rays
|
175
277
|
{
|
176
278
|
|
data/ext/rays/defs.cpp
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
#include "defs.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <assert.h>
|
5
|
+
#include "rays/ruby/bounds.h"
|
6
|
+
#include "rays/ruby/point.h"
|
7
|
+
|
8
|
+
|
9
|
+
void
|
10
|
+
get_line_args (std::vector<Rays::Point>* points, int argc, const Value* argv)
|
11
|
+
{
|
12
|
+
assert(points && argv);
|
13
|
+
|
14
|
+
points->clear();
|
15
|
+
|
16
|
+
if (argc <= 0)
|
17
|
+
return;
|
18
|
+
|
19
|
+
if (argv[0].is_num())
|
20
|
+
{
|
21
|
+
if (argc % 2 != 0)
|
22
|
+
argument_error(__FILE__, __LINE__);
|
23
|
+
|
24
|
+
points->reserve(argc / 2);
|
25
|
+
for (int i = 0; i < argc; i += 2)
|
26
|
+
{
|
27
|
+
coord x = to<coord>(argv[i + 0]);
|
28
|
+
coord y = to<coord>(argv[i + 1]);
|
29
|
+
points->emplace_back(Rays::Point(x, y));
|
30
|
+
}
|
31
|
+
}
|
32
|
+
else
|
33
|
+
{
|
34
|
+
points->reserve(argc);
|
35
|
+
for (int i = 0; i < argc; ++i)
|
36
|
+
points->emplace_back(to<Rays::Point>(argv[i]));
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
static uint
|
41
|
+
get_nsegment (Value nsegment)
|
42
|
+
{
|
43
|
+
int value = nsegment ? to<int>(nsegment) : 0;
|
44
|
+
if (value < 0) value = 0;
|
45
|
+
return (uint) value;
|
46
|
+
}
|
47
|
+
|
48
|
+
void get_rect_args (
|
49
|
+
coord* x, coord* y, coord* w, coord* h,
|
50
|
+
coord* lt, coord* rt, coord* lb, coord* rb,
|
51
|
+
uint* nseg,
|
52
|
+
int argc, const Value* argv,
|
53
|
+
Value round, Value lefttop, Value righttop, Value leftbottom, Value rightbottom,
|
54
|
+
Value nsegment)
|
55
|
+
{
|
56
|
+
assert(x && y && w && h && lt && rt && lb && rb && nseg && argv);
|
57
|
+
|
58
|
+
if (argc <= 0)
|
59
|
+
argument_error(__FILE__, __LINE__);
|
60
|
+
|
61
|
+
if (argv[0].is_kind_of(Rays::bounds_class()))
|
62
|
+
{
|
63
|
+
Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
64
|
+
*x = b.x;
|
65
|
+
*y = b.y;
|
66
|
+
*w = b.w;
|
67
|
+
*h = b.h;
|
68
|
+
*lt = argc >= 2 ? to<coord>(argv[1]) : 0;
|
69
|
+
*rt = argc >= 3 ? to<coord>(argv[2]) : *lt;
|
70
|
+
*lb = argc >= 4 ? to<coord>(argv[3]) : *lt;
|
71
|
+
*rb = argc >= 5 ? to<coord>(argv[4]) : *lt;
|
72
|
+
}
|
73
|
+
else if (argv[0].is_kind_of(Rays::point_class()))
|
74
|
+
{
|
75
|
+
if (argc < 2)
|
76
|
+
argument_error(__FILE__, __LINE__);
|
77
|
+
|
78
|
+
Rays::Point& p = to<Rays::Point&>(argv[0]);
|
79
|
+
*x = p.x;
|
80
|
+
*y = p.y;
|
81
|
+
*w = to<coord>(argv[1]);
|
82
|
+
*h = argc >= 3 ? to<coord>(argv[2]) : *w;
|
83
|
+
*lt = argc >= 4 ? to<coord>(argv[3]) : 0;
|
84
|
+
*rt = argc >= 5 ? to<coord>(argv[4]) : *lt;
|
85
|
+
*lb = argc >= 6 ? to<coord>(argv[5]) : *lt;
|
86
|
+
*rb = argc >= 7 ? to<coord>(argv[6]) : *lt;
|
87
|
+
}
|
88
|
+
else if (argc <= 2)
|
89
|
+
{
|
90
|
+
*x = *y = *lt = *rt = *lb = *rb = 0;
|
91
|
+
*w = to<coord>(argv[0]);
|
92
|
+
*h = argc >= 2 ? to<coord>(argv[1]) : *w;
|
93
|
+
}
|
94
|
+
else
|
95
|
+
{
|
96
|
+
*x = to<coord>(argv[0]);
|
97
|
+
*y = to<coord>(argv[1]);
|
98
|
+
*w = to<coord>(argv[2]);
|
99
|
+
*h = argc >= 4 ? to<coord>(argv[3]) : *w;
|
100
|
+
*lt = argc >= 5 ? to<coord>(argv[4]) : 0;
|
101
|
+
*rt = argc >= 6 ? to<coord>(argv[5]) : *lt;
|
102
|
+
*lb = argc >= 7 ? to<coord>(argv[6]) : *lt;
|
103
|
+
*rb = argc >= 8 ? to<coord>(argv[7]) : *lt;
|
104
|
+
}
|
105
|
+
|
106
|
+
if (! lefttop) lefttop = round;
|
107
|
+
if (!righttop) righttop = round;
|
108
|
+
if (! leftbottom) leftbottom = round;
|
109
|
+
if (!rightbottom) rightbottom = round;
|
110
|
+
|
111
|
+
if ( lefttop) *lt = to<coord>( lefttop);
|
112
|
+
if (righttop) *rt = to<coord>(righttop);
|
113
|
+
if ( leftbottom) *lb = to<coord>( leftbottom);
|
114
|
+
if (rightbottom) *rb = to<coord>(rightbottom);
|
115
|
+
|
116
|
+
*nseg = get_nsegment(nsegment);
|
117
|
+
}
|
118
|
+
|
119
|
+
void get_ellipse_args (
|
120
|
+
coord* x, coord* y, coord* w, coord* h,
|
121
|
+
Rays::Point* hole_size, float* from, float* to_,
|
122
|
+
uint* nseg,
|
123
|
+
int argc, const Value* argv,
|
124
|
+
Value center, Value radius, Value hole, Value angle_from, Value angle_to,
|
125
|
+
Value nsegment)
|
126
|
+
{
|
127
|
+
assert(x && y && w && h && hole_size && from && to_ && nseg && argv);
|
128
|
+
|
129
|
+
if (argc <= 0)
|
130
|
+
argument_error(__FILE__, __LINE__);
|
131
|
+
|
132
|
+
if (argv[0].is_kind_of(Rays::bounds_class()))
|
133
|
+
{
|
134
|
+
const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
135
|
+
*x = b.x;
|
136
|
+
*y = b.y;
|
137
|
+
*w = b.w;
|
138
|
+
*h = b.h;
|
139
|
+
}
|
140
|
+
else if (argv[0].is_kind_of(Rays::point_class()))
|
141
|
+
{
|
142
|
+
if (argc < 2)
|
143
|
+
argument_error(__FILE__, __LINE__);
|
144
|
+
|
145
|
+
const Rays::Point& p = to<Rays::Point&>(argv[0]);
|
146
|
+
*x = p.x;
|
147
|
+
*y = p.y;
|
148
|
+
*w = to<coord>(argv[1]);
|
149
|
+
*h = argc >= 3 ? to<coord>(argv[2]) : *w;
|
150
|
+
}
|
151
|
+
else if (argc <= 2)
|
152
|
+
{
|
153
|
+
*x = *y = 0;
|
154
|
+
*w = to<coord>(argv[0]);
|
155
|
+
*h = argc >= 2 ? to<coord>(argv[1]) : *w;
|
156
|
+
}
|
157
|
+
else
|
158
|
+
{
|
159
|
+
*x = to<coord>(argv[0]);
|
160
|
+
*y = to<coord>(argv[1]);
|
161
|
+
*w = to<coord>(argv[2]);
|
162
|
+
*h = argc >= 4 ? to<coord>(argv[3]) : *w;
|
163
|
+
}
|
164
|
+
|
165
|
+
if (center)
|
166
|
+
{
|
167
|
+
Rays::Point p = to<Rays::Point>(center);
|
168
|
+
*x = p.x;
|
169
|
+
*y = p.y;
|
170
|
+
}
|
171
|
+
|
172
|
+
if (radius)
|
173
|
+
{
|
174
|
+
Rays::Point p = to<Rays::Point>(radius);
|
175
|
+
*w = p.x * 2;
|
176
|
+
*h = p.y * 2;
|
177
|
+
}
|
178
|
+
|
179
|
+
*hole_size = hole ? to<Rays::Point>(hole) : 0;
|
180
|
+
*from = angle_from ? to<float>(angle_from) : 0;
|
181
|
+
*to_ = angle_to ? to<float>(angle_to) : 360;
|
182
|
+
*nseg = get_nsegment(nsegment);
|
183
|
+
}
|
data/ext/rays/defs.h
CHANGED
@@ -4,10 +4,34 @@
|
|
4
4
|
#define __RAYS_EXT_DEFS_H__
|
5
5
|
|
6
6
|
|
7
|
-
#include <
|
7
|
+
#include <vector>
|
8
|
+
#include <rucy.h>
|
9
|
+
#include <rays/defs.h>
|
10
|
+
#include <rays/point.h>
|
8
11
|
|
9
12
|
|
10
|
-
using
|
13
|
+
using namespace Rucy;
|
14
|
+
|
15
|
+
using Rays::coord;
|
16
|
+
|
17
|
+
|
18
|
+
void get_line_args (
|
19
|
+
std::vector<Rays::Point>* points,
|
20
|
+
int argc, const Value* argv);
|
21
|
+
|
22
|
+
void get_rect_args (
|
23
|
+
coord* x, coord* y, coord* w, coord* h,
|
24
|
+
coord* lt, coord* rt, coord* lb, coord* rb, uint* nseg,
|
25
|
+
int argc, const Value* argv,
|
26
|
+
Value round, Value lefttop, Value righttop, Value leftbottom, Value rightbottom,
|
27
|
+
Value nsegment);
|
28
|
+
|
29
|
+
void get_ellipse_args (
|
30
|
+
coord* x, coord* y, coord* w, coord* h,
|
31
|
+
Rays::Point* hole_size, float* from, float* to, uint* nseg,
|
32
|
+
int argc, const Value* argv,
|
33
|
+
Value center, Value radius, Value hole, Value angel_from, Value angle_to,
|
34
|
+
Value nsegment);
|
11
35
|
|
12
36
|
|
13
37
|
#endif//EOH
|