rays 0.2.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/rays/bitmap.cpp +99 -32
- data/.doc/ext/rays/bounds.cpp +16 -12
- data/.doc/ext/rays/camera.cpp +1 -1
- data/.doc/ext/rays/color.cpp +2 -2
- data/.doc/ext/rays/color_space.cpp +3 -3
- data/.doc/ext/rays/defs.cpp +4 -4
- data/.doc/ext/rays/font.cpp +4 -3
- data/.doc/ext/rays/image.cpp +32 -18
- data/.doc/ext/rays/matrix.cpp +6 -6
- data/.doc/ext/rays/painter.cpp +1 -1
- data/.doc/ext/rays/point.cpp +10 -6
- data/.doc/ext/rays/polygon.cpp +11 -9
- data/.doc/ext/rays/polyline.cpp +6 -4
- data/.doc/ext/rays/rays.cpp +25 -15
- data/.doc/ext/rays/shader.cpp +3 -3
- data/.github/workflows/release-gem.yml +1 -1
- data/.github/workflows/test.yml +3 -0
- data/ChangeLog.md +11 -0
- data/Gemfile.lock +1 -1
- data/LICENSE +1 -1
- data/Rakefile +17 -3
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +99 -32
- data/ext/rays/bounds.cpp +16 -12
- data/ext/rays/camera.cpp +1 -1
- data/ext/rays/color.cpp +2 -2
- data/ext/rays/color_space.cpp +3 -3
- data/ext/rays/defs.cpp +4 -4
- data/ext/rays/defs.h +2 -0
- data/ext/rays/extconf.rb +4 -2
- data/ext/rays/font.cpp +4 -3
- data/ext/rays/image.cpp +34 -18
- data/ext/rays/matrix.cpp +6 -6
- data/ext/rays/painter.cpp +1 -1
- data/ext/rays/point.cpp +10 -6
- data/ext/rays/polygon.cpp +11 -9
- data/ext/rays/polyline.cpp +6 -4
- data/ext/rays/rays.cpp +25 -15
- data/ext/rays/shader.cpp +3 -3
- data/include/rays/defs.h +7 -0
- data/include/rays/image.h +8 -2
- data/include/rays/ruby/bitmap.h +2 -2
- data/include/rays/ruby/bounds.h +2 -2
- data/include/rays/ruby/camera.h +2 -2
- data/include/rays/ruby/color.h +2 -2
- data/include/rays/ruby/color_space.h +2 -2
- data/include/rays/ruby/exception.h +3 -3
- data/include/rays/ruby/font.h +2 -2
- data/include/rays/ruby/image.h +2 -2
- data/include/rays/ruby/matrix.h +2 -2
- data/include/rays/ruby/painter.h +2 -2
- data/include/rays/ruby/point.h +2 -2
- data/include/rays/ruby/polygon.h +2 -2
- data/include/rays/ruby/polyline.h +2 -2
- data/include/rays/ruby/rays.h +6 -6
- data/include/rays/ruby/shader.h +2 -2
- data/lib/rays/bitmap.rb +7 -0
- data/lib/rays/extension.rb +4 -0
- data/lib/rays/image.rb +4 -0
- data/rays.gemspec +2 -2
- data/src/bounds.cpp +6 -2
- data/src/color.cpp +12 -4
- data/src/coord.h +2 -2
- data/src/font.cpp +1 -0
- data/src/image.cpp +32 -4
- data/src/ios/bitmap.mm +40 -33
- data/src/ios/font.mm +6 -1
- data/src/ios/rays.mm +2 -2
- data/src/matrix.h +1 -1
- data/src/opengl.h +1 -2
- data/src/osx/bitmap.mm +40 -33
- data/src/osx/font.mm +6 -1
- data/src/osx/rays.mm +2 -2
- data/src/painter.cpp +4 -1
- data/src/point.cpp +15 -3
- data/src/polygon.cpp +3 -5
- data/src/render_buffer.cpp +11 -3
- data/src/shader.cpp +3 -0
- data/src/shader_program.cpp +19 -9
- data/src/shader_source.cpp +5 -1
- data/src/texture.cpp +33 -11
- data/src/texture.h +6 -2
- data/src/win32/bitmap.cpp +178 -66
- data/src/win32/camera.cpp +119 -0
- data/src/win32/font.cpp +181 -40
- data/src/win32/gdi.h +1 -1
- data/src/win32/opengl.cpp +127 -0
- data/src/win32/rays.cpp +16 -9
- data/test/helper.rb +2 -0
- data/test/test_bitmap.rb +3 -1
- data/test/test_image.rb +8 -14
- data/test/test_painter.rb +4 -4
- data/test/test_painter_shape.rb +6 -5
- metadata +8 -7
- data/src/win32/font.h +0 -24
data/ext/rays/color.cpp
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
#include "defs.h"
|
7
7
|
|
8
8
|
|
9
|
-
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Color)
|
9
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Color)
|
10
10
|
|
11
11
|
#define THIS to<Rays::Color*>(self)
|
12
12
|
|
@@ -344,7 +344,7 @@ namespace Rucy
|
|
344
344
|
return find_color(str_.c_str());
|
345
345
|
}
|
346
346
|
|
347
|
-
template <> Rays::Color
|
347
|
+
template <> RAYS_EXPORT Rays::Color
|
348
348
|
value_to<Rays::Color> (int argc, const Value*argv, bool convert)
|
349
349
|
{
|
350
350
|
if (argc == 1 && argv->is_array())
|
data/ext/rays/color_space.cpp
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
#include "defs.h"
|
6
6
|
|
7
7
|
|
8
|
-
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::ColorSpace)
|
8
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::ColorSpace)
|
9
9
|
|
10
10
|
#define THIS to<Rays::ColorSpace*>(self)
|
11
11
|
|
@@ -219,7 +219,7 @@ namespace Rucy
|
|
219
219
|
{
|
220
220
|
|
221
221
|
|
222
|
-
template <> Rays::ColorSpace
|
222
|
+
template <> RAYS_EXPORT Rays::ColorSpace
|
223
223
|
value_to<Rays::ColorSpace> (int argc, const Value* argv, bool convert)
|
224
224
|
{
|
225
225
|
if (argc == 1 && argv->is_array())
|
@@ -247,7 +247,7 @@ namespace Rucy
|
|
247
247
|
}
|
248
248
|
|
249
249
|
|
250
|
-
template <> Rays::ColorSpaceType
|
250
|
+
template <> RAYS_EXPORT Rays::ColorSpaceType
|
251
251
|
value_to<Rays::ColorSpaceType> (Value value, bool convert)
|
252
252
|
{
|
253
253
|
if (convert)
|
data/ext/rays/defs.cpp
CHANGED
@@ -84,7 +84,7 @@ void get_rect_args (
|
|
84
84
|
if (argc <= 0)
|
85
85
|
argument_error(__FILE__, __LINE__);
|
86
86
|
|
87
|
-
if (argv[0].
|
87
|
+
if (argv[0].is_a(Rays::bounds_class()))
|
88
88
|
{
|
89
89
|
Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
90
90
|
*x = b.x;
|
@@ -96,7 +96,7 @@ void get_rect_args (
|
|
96
96
|
*lb = argc >= 4 ? to<coord>(argv[3]) : *lt;
|
97
97
|
*rb = argc >= 5 ? to<coord>(argv[4]) : *lt;
|
98
98
|
}
|
99
|
-
else if (argv[0].
|
99
|
+
else if (argv[0].is_a(Rays::point_class()))
|
100
100
|
{
|
101
101
|
if (argc < 2)
|
102
102
|
argument_error(__FILE__, __LINE__);
|
@@ -154,7 +154,7 @@ void get_ellipse_args (
|
|
154
154
|
{
|
155
155
|
*x = *y = *w = *h = 0;
|
156
156
|
}
|
157
|
-
else if (argv[0].
|
157
|
+
else if (argv[0].is_a(Rays::bounds_class()))
|
158
158
|
{
|
159
159
|
const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
160
160
|
*x = b.x;
|
@@ -162,7 +162,7 @@ void get_ellipse_args (
|
|
162
162
|
*w = b.w;
|
163
163
|
*h = b.h;
|
164
164
|
}
|
165
|
-
else if (argv[0].
|
165
|
+
else if (argv[0].is_a(Rays::point_class()))
|
166
166
|
{
|
167
167
|
if (argc < 2)
|
168
168
|
argument_error(__FILE__, __LINE__);
|
data/ext/rays/defs.h
CHANGED
data/ext/rays/extconf.rb
CHANGED
@@ -12,9 +12,11 @@ require 'rays/extension'
|
|
12
12
|
Xot::ExtConf.new Xot, Rucy, Rays do
|
13
13
|
setup do
|
14
14
|
headers << 'ruby.h'
|
15
|
-
libs.unshift '
|
15
|
+
libs.unshift 'gdi32', 'opengl32', 'glew32' if win32?
|
16
16
|
frameworks << 'AppKit' << 'OpenGL' << 'AVFoundation' if osx?
|
17
|
-
$LDFLAGS << ' -Wl,--out-implib=native.dll.a'
|
17
|
+
$LDFLAGS << ' -Wl,--out-implib=native.dll.a' if mingw? || cygwin?
|
18
|
+
|
19
|
+
$CPPFLAGS << ' -DRAYS_32BIT_PIXELS_STRING' if RUBY_PLATFORM == 'x64-mingw-ucrt'
|
18
20
|
end
|
19
21
|
|
20
22
|
create_makefile 'rays/native'
|
data/ext/rays/font.cpp
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
#include "defs.h"
|
6
6
|
|
7
7
|
|
8
|
-
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Font)
|
8
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Font)
|
9
9
|
|
10
10
|
#define THIS to<Rays::Font*>(self)
|
11
11
|
|
@@ -169,7 +169,7 @@ namespace Rucy
|
|
169
169
|
{
|
170
170
|
|
171
171
|
|
172
|
-
template <> Rays::Font
|
172
|
+
template <> RAYS_EXPORT Rays::Font
|
173
173
|
value_to<Rays::Font> (int argc, const Value* argv, bool convert)
|
174
174
|
{
|
175
175
|
if (argc == 1 && argv->is_array())
|
@@ -185,7 +185,8 @@ namespace Rucy
|
|
185
185
|
if (argc == 0)
|
186
186
|
return Rays::get_default_font();
|
187
187
|
|
188
|
-
coord size =
|
188
|
+
coord size =
|
189
|
+
argc >= 2 ? to<coord>(argv[1]) : (coord) Rays::Font::DEFAULT_SIZE;
|
189
190
|
if (argv->is_nil())
|
190
191
|
return Rays::Font(NULL, size);
|
191
192
|
else if (argv->is_s() || argv->is_sym())
|
data/ext/rays/image.cpp
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
#include "defs.h"
|
8
8
|
|
9
9
|
|
10
|
-
RUCY_DEFINE_VALUE_FROM_TO(Rays::Image)
|
10
|
+
RUCY_DEFINE_VALUE_FROM_TO(RAYS_EXPORT, Rays::Image)
|
11
11
|
|
12
12
|
#define THIS to<Rays::Image*>(self)
|
13
13
|
|
@@ -22,31 +22,28 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
22
22
|
RUCY_END
|
23
23
|
|
24
24
|
static
|
25
|
-
|
25
|
+
RUCY_DEF3(initialize, args, pixel_density, smooth)
|
26
26
|
{
|
27
27
|
RUCY_CHECK_OBJ(Rays::Image, self);
|
28
|
-
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3, 4);
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2);
|
29
|
+
size_t argc = args.size();
|
30
|
+
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3);
|
33
31
|
|
34
|
-
|
35
|
-
|
32
|
+
float pd = to<float>(pixel_density);
|
33
|
+
if (args[0].is_a(Rays::bitmap_class()))
|
34
|
+
{
|
35
|
+
const Rays::Bitmap* bmp = to<Rays::Bitmap*>(args[0]);
|
36
|
+
if (!bmp)
|
36
37
|
argument_error(__FILE__, __LINE__);
|
37
38
|
|
38
|
-
|
39
|
-
*THIS = Rays::Image(*bitmap, pixel_density);
|
39
|
+
*THIS = Rays::Image(*bmp, pd, smooth);
|
40
40
|
}
|
41
41
|
else
|
42
42
|
{
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
Rays::ColorSpace cs = (argc >= 3) ? to<Rays::ColorSpace>(argv[2]) : Rays::RGBA;
|
48
|
-
float pixel_density = (argc >= 4) ? to<float>(argv[3]) : 1;
|
49
|
-
*THIS = Rays::Image(width, height, cs, pixel_density);
|
43
|
+
int width = to<int>(args[0]);
|
44
|
+
int height = to<int>(args[1]);
|
45
|
+
auto cs = (argc >= 3) ? to<Rays::ColorSpace>(args[2]) : Rays::RGBA;
|
46
|
+
*THIS = Rays::Image(width, height, cs, pd, smooth);
|
50
47
|
}
|
51
48
|
|
52
49
|
return self;
|
@@ -120,6 +117,23 @@ RUCY_DEF1(get_bitmap, modify)
|
|
120
117
|
}
|
121
118
|
RUCY_END
|
122
119
|
|
120
|
+
static
|
121
|
+
RUCY_DEF1(set_smooth, smooth)
|
122
|
+
{
|
123
|
+
CHECK;
|
124
|
+
THIS->set_smooth(smooth);
|
125
|
+
return smooth;
|
126
|
+
}
|
127
|
+
RUCY_END
|
128
|
+
|
129
|
+
static
|
130
|
+
RUCY_DEF0(get_smooth)
|
131
|
+
{
|
132
|
+
CHECK;
|
133
|
+
return value(THIS->smooth());
|
134
|
+
}
|
135
|
+
RUCY_END
|
136
|
+
|
123
137
|
static
|
124
138
|
RUCY_DEF1(load, path)
|
125
139
|
{
|
@@ -137,7 +151,7 @@ Init_rays_image ()
|
|
137
151
|
|
138
152
|
cImage = mRays.define_class("Image");
|
139
153
|
cImage.define_alloc_func(alloc);
|
140
|
-
cImage.define_private_method("initialize",
|
154
|
+
cImage.define_private_method("initialize!", initialize);
|
141
155
|
cImage.define_private_method("initialize_copy", initialize_copy);
|
142
156
|
cImage.define_method("save", save);
|
143
157
|
cImage.define_method("width", width);
|
@@ -146,6 +160,8 @@ Init_rays_image ()
|
|
146
160
|
cImage.define_method("pixel_density", pixel_density);
|
147
161
|
cImage.define_method("painter", painter);
|
148
162
|
cImage.define_private_method("get_bitmap", get_bitmap);
|
163
|
+
cImage.define_method("smooth=", set_smooth);
|
164
|
+
cImage.define_method("smooth", get_smooth);
|
149
165
|
cImage.define_module_function("load", load);
|
150
166
|
}
|
151
167
|
|
data/ext/rays/matrix.cpp
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
#include "defs.h"
|
7
7
|
|
8
8
|
|
9
|
-
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Matrix)
|
9
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Matrix)
|
10
10
|
|
11
11
|
#define THIS to<Rays::Matrix*>(self)
|
12
12
|
|
@@ -136,10 +136,10 @@ RUCY_DEF1(mult, val)
|
|
136
136
|
{
|
137
137
|
CHECK;
|
138
138
|
|
139
|
-
if (val.
|
139
|
+
if (val.is_a(Rays::matrix_class()))
|
140
140
|
return value(*THIS * to<Rays::Matrix&>(val));
|
141
141
|
|
142
|
-
if (val.
|
142
|
+
if (val.is_a(Rays::point_class()))
|
143
143
|
return value(*THIS * to<Rays::Point&>(val));
|
144
144
|
|
145
145
|
if (val.is_array())
|
@@ -232,10 +232,10 @@ RUCY_DEFN(s_ortho)
|
|
232
232
|
RUCY_END
|
233
233
|
|
234
234
|
static
|
235
|
-
RUCY_DEF4(s_perspective, fov_y, aspect_ratio,
|
235
|
+
RUCY_DEF4(s_perspective, fov_y, aspect_ratio, near_, far_)
|
236
236
|
{
|
237
237
|
return value(Rays::perspective(
|
238
|
-
to<float>(fov_y), to<float>(aspect_ratio), to<coord>(
|
238
|
+
to<float>(fov_y), to<float>(aspect_ratio), to<coord>(near_), to<coord>(far_)));
|
239
239
|
}
|
240
240
|
RUCY_END
|
241
241
|
|
@@ -301,7 +301,7 @@ namespace Rucy
|
|
301
301
|
{
|
302
302
|
|
303
303
|
|
304
|
-
template <> Rays::Matrix
|
304
|
+
template <> RAYS_EXPORT Rays::Matrix
|
305
305
|
value_to<Rays::Matrix> (int argc, const Value* argv, bool convert)
|
306
306
|
{
|
307
307
|
if (argc == 1 && argv->is_array())
|
data/ext/rays/painter.cpp
CHANGED
data/ext/rays/point.cpp
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
#include "defs.h"
|
6
6
|
|
7
7
|
|
8
|
-
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Point)
|
8
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Point)
|
9
9
|
|
10
10
|
#define THIS to<Rays::Point*>(self)
|
11
11
|
|
@@ -47,7 +47,7 @@ RUCY_DEFN(move_to)
|
|
47
47
|
CHECK;
|
48
48
|
check_arg_count(__FILE__, __LINE__, "Point#move_to", argc, 1, 2, 3);
|
49
49
|
|
50
|
-
if (argv[0].
|
50
|
+
if (argv[0].is_a(Rays::point_class()))
|
51
51
|
THIS->move_to(to<Rays::Point&>(argv[0]));
|
52
52
|
else
|
53
53
|
{
|
@@ -68,7 +68,7 @@ RUCY_DEFN(move_by)
|
|
68
68
|
CHECK;
|
69
69
|
check_arg_count(__FILE__, __LINE__, "Point#move_by", argc, 1, 2, 3);
|
70
70
|
|
71
|
-
if (argv[0].
|
71
|
+
if (argv[0].is_a(Rays::point_class()))
|
72
72
|
THIS->move_by(to<Rays::Point&>(argv[0]));
|
73
73
|
else
|
74
74
|
{
|
@@ -224,7 +224,9 @@ RUCY_DEF2(set_at, index, value)
|
|
224
224
|
CHECK;
|
225
225
|
|
226
226
|
int i = index.as_i();
|
227
|
-
if (i < 0
|
227
|
+
if (i < 0)
|
228
|
+
index_error(__FILE__, __LINE__);
|
229
|
+
if (i > 2)
|
228
230
|
index_error(__FILE__, __LINE__);
|
229
231
|
|
230
232
|
(*THIS)[i] = to<coord>(value);
|
@@ -238,7 +240,9 @@ RUCY_DEF1(get_at, index)
|
|
238
240
|
CHECK;
|
239
241
|
|
240
242
|
int i = index.as_i();
|
241
|
-
if (i < 0
|
243
|
+
if (i < 0)
|
244
|
+
index_error(__FILE__, __LINE__);
|
245
|
+
if (i > 2)
|
242
246
|
index_error(__FILE__, __LINE__);
|
243
247
|
|
244
248
|
return value((*THIS)[i]);
|
@@ -299,7 +303,7 @@ namespace Rucy
|
|
299
303
|
{
|
300
304
|
|
301
305
|
|
302
|
-
template <> Rays::Point
|
306
|
+
template <> RAYS_EXPORT Rays::Point
|
303
307
|
value_to<Rays::Point> (int argc, const Value* argv, bool convert)
|
304
308
|
{
|
305
309
|
if (argc == 1 && argv->is_array())
|
data/ext/rays/polygon.cpp
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
#include "defs.h"
|
9
9
|
|
10
10
|
|
11
|
-
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon)
|
11
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Polygon)
|
12
12
|
|
13
13
|
#define THIS to<Rays::Polygon*>(self)
|
14
14
|
|
@@ -27,7 +27,7 @@ RUCY_DEF4(setup, args, loop, colors, texcoords)
|
|
27
27
|
{
|
28
28
|
CHECK;
|
29
29
|
|
30
|
-
if (args[0].
|
30
|
+
if (args[0].is_a(Rays::polyline_class()))
|
31
31
|
*THIS = to<Rays::Polygon>(args.size(), args.as_array());
|
32
32
|
else
|
33
33
|
{
|
@@ -48,7 +48,7 @@ RUCY_DEFN(expand)
|
|
48
48
|
coord width = to<coord> (argv[0]);
|
49
49
|
Rays::CapType cap = argc >= 2 ? to<Rays::CapType> (argv[1]) : Rays::CAP_DEFAULT;
|
50
50
|
Rays::JoinType join = argc >= 3 ? to<Rays::JoinType>(argv[2]) : Rays::JOIN_DEFAULT;
|
51
|
-
coord ml = argc >= 4 ? to<coord> (argv[3]) : Rays::JOIN_DEFAULT_MITER_LIMIT;
|
51
|
+
coord ml = argc >= 4 ? to<coord> (argv[3]) : (coord) Rays::JOIN_DEFAULT_MITER_LIMIT;
|
52
52
|
|
53
53
|
Rays::Polygon polygon;
|
54
54
|
THIS->expand(&polygon, width, cap, join, ml);
|
@@ -89,7 +89,9 @@ RUCY_DEF1(get_at, index)
|
|
89
89
|
int i = to<int>(index);
|
90
90
|
if (i < 0) i += size;
|
91
91
|
|
92
|
-
if (i < 0
|
92
|
+
if (i < 0)
|
93
|
+
index_error(__FILE__, __LINE__);
|
94
|
+
if (i >= size)
|
93
95
|
index_error(__FILE__, __LINE__);
|
94
96
|
|
95
97
|
return value((*THIS)[i]);
|
@@ -124,10 +126,10 @@ RUCY_DEF1(op_add, obj)
|
|
124
126
|
{
|
125
127
|
CHECK;
|
126
128
|
|
127
|
-
if (obj.
|
129
|
+
if (obj.is_a(Rays::polyline_class()))
|
128
130
|
return value(*THIS + to<Rays::Polyline&>(obj));
|
129
131
|
|
130
|
-
if (obj.
|
132
|
+
if (obj.is_a(Rays::polygon_class()))
|
131
133
|
return value(*THIS + to<Rays::Polygon&>(obj));
|
132
134
|
|
133
135
|
if (!obj.is_array())
|
@@ -139,7 +141,7 @@ RUCY_DEF1(op_add, obj)
|
|
139
141
|
for (const auto& polyline : to<Rays::Polygon&>(self))
|
140
142
|
polylines.emplace_back(polyline);
|
141
143
|
|
142
|
-
if (obj[0].
|
144
|
+
if (obj[0].is_a(Rays::polyline_class()))
|
143
145
|
{
|
144
146
|
each_poly<Rays::Polyline>(obj, [&](const auto& polyline)
|
145
147
|
{
|
@@ -400,14 +402,14 @@ namespace Rucy
|
|
400
402
|
{
|
401
403
|
|
402
404
|
|
403
|
-
template <> Rays::Polygon
|
405
|
+
template <> RAYS_EXPORT Rays::Polygon
|
404
406
|
value_to<Rays::Polygon> (int argc, const Value* argv, bool convert)
|
405
407
|
{
|
406
408
|
if (convert)
|
407
409
|
{
|
408
410
|
if (argc <= 0)
|
409
411
|
return Rays::Polygon();
|
410
|
-
else if (argv->
|
412
|
+
else if (argv->is_a(Rays::polyline_class()))
|
411
413
|
{
|
412
414
|
if (argc == 1)
|
413
415
|
return Rays::Polygon(to<Rays::Polyline&>(*argv));
|
data/ext/rays/polyline.cpp
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#include "defs.h"
|
11
11
|
|
12
12
|
|
13
|
-
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Polyline)
|
13
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Polyline)
|
14
14
|
|
15
15
|
#define THIS to<Rays::Polyline*>(self)
|
16
16
|
|
@@ -46,7 +46,7 @@ RUCY_DEFN(expand)
|
|
46
46
|
coord width = to<coord> (argv[0]);
|
47
47
|
Rays::CapType cap = argc >= 2 ? to<Rays::CapType> (argv[1]) : Rays::CAP_DEFAULT;
|
48
48
|
Rays::JoinType join = argc >= 3 ? to<Rays::JoinType>(argv[2]) : Rays::JOIN_DEFAULT;
|
49
|
-
coord ml = argc >= 4 ? to<coord> (argv[3]) : Rays::JOIN_DEFAULT_MITER_LIMIT;
|
49
|
+
coord ml = argc >= 4 ? to<coord> (argv[3]) : (coord) Rays::JOIN_DEFAULT_MITER_LIMIT;
|
50
50
|
|
51
51
|
Rays::Polygon polygon;
|
52
52
|
THIS->expand(&polygon, width, cap, join, ml);
|
@@ -111,7 +111,9 @@ RUCY_DEF1(get_at, index)
|
|
111
111
|
int i = to<int>(index);
|
112
112
|
if (i < 0) i += size;
|
113
113
|
|
114
|
-
if (i < 0
|
114
|
+
if (i < 0)
|
115
|
+
index_error(__FILE__, __LINE__);
|
116
|
+
if (i >= size)
|
115
117
|
index_error(__FILE__, __LINE__);
|
116
118
|
|
117
119
|
return value((*THIS)[i]);
|
@@ -222,7 +224,7 @@ namespace Rucy
|
|
222
224
|
{
|
223
225
|
|
224
226
|
|
225
|
-
template <> Rays::Polyline
|
227
|
+
template <> RAYS_EXPORT Rays::Polyline
|
226
228
|
value_to<Rays::Polyline> (int argc, const Value* argv, bool convert)
|
227
229
|
{
|
228
230
|
assert(argc == 0 || (argc > 0 && argv));
|
data/ext/rays/rays.cpp
CHANGED
@@ -6,11 +6,11 @@
|
|
6
6
|
#include "defs.h"
|
7
7
|
|
8
8
|
|
9
|
-
RUCY_DEFINE_CONVERT_TO(Rays::CapType)
|
10
|
-
RUCY_DEFINE_CONVERT_TO(Rays::JoinType)
|
11
|
-
RUCY_DEFINE_CONVERT_TO(Rays::BlendMode)
|
12
|
-
RUCY_DEFINE_CONVERT_TO(Rays::TexCoordMode)
|
13
|
-
RUCY_DEFINE_CONVERT_TO(Rays::TexCoordWrap)
|
9
|
+
RUCY_DEFINE_CONVERT_TO(RAYS_EXPORT, Rays::CapType)
|
10
|
+
RUCY_DEFINE_CONVERT_TO(RAYS_EXPORT, Rays::JoinType)
|
11
|
+
RUCY_DEFINE_CONVERT_TO(RAYS_EXPORT, Rays::BlendMode)
|
12
|
+
RUCY_DEFINE_CONVERT_TO(RAYS_EXPORT, Rays::TexCoordMode)
|
13
|
+
RUCY_DEFINE_CONVERT_TO(RAYS_EXPORT, Rays::TexCoordWrap)
|
14
14
|
|
15
15
|
|
16
16
|
template <typename T>
|
@@ -104,7 +104,7 @@ namespace Rucy
|
|
104
104
|
{
|
105
105
|
|
106
106
|
|
107
|
-
template <> Rays::CapType
|
107
|
+
template <> RAYS_EXPORT Rays::CapType
|
108
108
|
value_to<Rays::CapType> (int argc, const Value* argv, bool convert)
|
109
109
|
{
|
110
110
|
assert(argc > 0 && argv);
|
@@ -128,14 +128,16 @@ namespace Rucy
|
|
128
128
|
}
|
129
129
|
|
130
130
|
int type = value_to<int>(*argv, convert);
|
131
|
-
if (type < 0
|
131
|
+
if (type < 0)
|
132
|
+
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
|
133
|
+
if (type >= Rays::CAP_MAX)
|
132
134
|
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
|
133
135
|
|
134
136
|
return (Rays::CapType) type;
|
135
137
|
}
|
136
138
|
|
137
139
|
|
138
|
-
template <> Rays::JoinType
|
140
|
+
template <> RAYS_EXPORT Rays::JoinType
|
139
141
|
value_to<Rays::JoinType> (int argc, const Value* argv, bool convert)
|
140
142
|
{
|
141
143
|
assert(argc > 0 && argv);
|
@@ -159,14 +161,16 @@ namespace Rucy
|
|
159
161
|
}
|
160
162
|
|
161
163
|
int type = value_to<int>(*argv, convert);
|
162
|
-
if (type < 0
|
164
|
+
if (type < 0)
|
165
|
+
argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
|
166
|
+
if (type >= Rays::JOIN_MAX)
|
163
167
|
argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
|
164
168
|
|
165
169
|
return (Rays::JoinType) type;
|
166
170
|
}
|
167
171
|
|
168
172
|
|
169
|
-
template <> Rays::BlendMode
|
173
|
+
template <> RAYS_EXPORT Rays::BlendMode
|
170
174
|
value_to<Rays::BlendMode> (int argc, const Value* argv, bool convert)
|
171
175
|
{
|
172
176
|
assert(argc > 0 && argv);
|
@@ -190,14 +194,16 @@ namespace Rucy
|
|
190
194
|
}
|
191
195
|
|
192
196
|
int mode = value_to<int>(*argv, convert);
|
193
|
-
if (mode < 0
|
197
|
+
if (mode < 0)
|
198
|
+
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
199
|
+
if (mode >= Rays::BLEND_MAX)
|
194
200
|
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
195
201
|
|
196
202
|
return (Rays::BlendMode) mode;
|
197
203
|
}
|
198
204
|
|
199
205
|
|
200
|
-
template <> Rays::TexCoordMode
|
206
|
+
template <> RAYS_EXPORT Rays::TexCoordMode
|
201
207
|
value_to<Rays::TexCoordMode> (int argc, const Value* argv, bool convert)
|
202
208
|
{
|
203
209
|
assert(argc > 0 && argv);
|
@@ -221,14 +227,16 @@ namespace Rucy
|
|
221
227
|
}
|
222
228
|
|
223
229
|
int mode = value_to<int>(*argv, convert);
|
224
|
-
if (mode < 0
|
230
|
+
if (mode < 0)
|
231
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %d", mode);
|
232
|
+
if (mode >= Rays::TEXCOORD_MODE_MAX)
|
225
233
|
argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %d", mode);
|
226
234
|
|
227
235
|
return (Rays::TexCoordMode) mode;
|
228
236
|
}
|
229
237
|
|
230
238
|
|
231
|
-
template <> Rays::TexCoordWrap
|
239
|
+
template <> RAYS_EXPORT Rays::TexCoordWrap
|
232
240
|
value_to<Rays::TexCoordWrap> (int argc, const Value* argv, bool convert)
|
233
241
|
{
|
234
242
|
assert(argc > 0 && argv);
|
@@ -252,7 +260,9 @@ namespace Rucy
|
|
252
260
|
}
|
253
261
|
|
254
262
|
int wrap = value_to<int>(*argv, convert);
|
255
|
-
if (wrap < 0
|
263
|
+
if (wrap < 0)
|
264
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %d", wrap);
|
265
|
+
if (wrap >= Rays::TEXCOORD_WRAP_MAX)
|
256
266
|
argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %d", wrap);
|
257
267
|
|
258
268
|
return (Rays::TexCoordWrap) wrap;
|
data/ext/rays/shader.cpp
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
#include "defs.h"
|
7
7
|
|
8
8
|
|
9
|
-
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Shader)
|
9
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Shader)
|
10
10
|
|
11
11
|
#define THIS to<Rays::Shader*>(self)
|
12
12
|
|
@@ -141,7 +141,7 @@ RUCY_DEFN(set_uniform)
|
|
141
141
|
case 4: THIS->set_uniform(name, Af(0), Af(1), Af(2), Af(3)); break;
|
142
142
|
}
|
143
143
|
}
|
144
|
-
else if (argv[0].
|
144
|
+
else if (argv[0].is_a(Rays::image_class()))
|
145
145
|
THIS->set_uniform(name, to<Rays::Image&>(argv[0]));
|
146
146
|
else
|
147
147
|
argument_error(__FILE__, __LINE__);
|
@@ -194,7 +194,7 @@ namespace Rucy
|
|
194
194
|
{
|
195
195
|
|
196
196
|
|
197
|
-
template <> Rays::Shader
|
197
|
+
template <> RAYS_EXPORT Rays::Shader
|
198
198
|
value_to<Rays::Shader> (int argc, const Value* argv, bool convert)
|
199
199
|
{
|
200
200
|
if (argc == 1 && argv->is_array())
|
data/include/rays/defs.h
CHANGED
data/include/rays/image.h
CHANGED
@@ -27,9 +27,11 @@ namespace Rays
|
|
27
27
|
|
28
28
|
Image (
|
29
29
|
int width, int height, const ColorSpace& cs = DEFAULT_COLOR_SPACE,
|
30
|
-
float pixel_density = 1);
|
30
|
+
float pixel_density = 1, bool smooth = false);
|
31
31
|
|
32
|
-
Image (
|
32
|
+
Image (
|
33
|
+
const Bitmap& bitmap,
|
34
|
+
float pixel_density = 1, bool smooth = false);
|
33
35
|
|
34
36
|
~Image ();
|
35
37
|
|
@@ -45,6 +47,10 @@ namespace Rays
|
|
45
47
|
|
46
48
|
float pixel_density () const;
|
47
49
|
|
50
|
+
void set_smooth (bool smooth);
|
51
|
+
|
52
|
+
bool smooth () const;
|
53
|
+
|
48
54
|
Painter painter ();
|
49
55
|
|
50
56
|
Bitmap& bitmap (bool modify = false);
|
data/include/rays/ruby/bitmap.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/bitmap.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_FROM_TO(Rays::Bitmap)
|
12
|
+
RUCY_DECLARE_VALUE_FROM_TO(RAYS_EXPORT, Rays::Bitmap)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class bitmap_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class bitmap_class ();
|
20
20
|
// class Rays::Bitmap
|
21
21
|
|
22
22
|
|
data/include/rays/ruby/bounds.h
CHANGED
@@ -10,14 +10,14 @@
|
|
10
10
|
#include <rays/ruby/point.h>
|
11
11
|
|
12
12
|
|
13
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Bounds)
|
13
|
+
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Bounds)
|
14
14
|
|
15
15
|
|
16
16
|
namespace Rays
|
17
17
|
{
|
18
18
|
|
19
19
|
|
20
|
-
Rucy::Class bounds_class ();
|
20
|
+
RAYS_EXPORT Rucy::Class bounds_class ();
|
21
21
|
// class Rays::Bounds
|
22
22
|
|
23
23
|
|
data/include/rays/ruby/camera.h
CHANGED
@@ -9,14 +9,14 @@
|
|
9
9
|
#include <rays/camera.h>
|
10
10
|
|
11
11
|
|
12
|
-
RUCY_DECLARE_VALUE_FROM_TO(Rays::Camera)
|
12
|
+
RUCY_DECLARE_VALUE_FROM_TO(RAYS_EXPORT, Rays::Camera)
|
13
13
|
|
14
14
|
|
15
15
|
namespace Rays
|
16
16
|
{
|
17
17
|
|
18
18
|
|
19
|
-
Rucy::Class camera_class ();
|
19
|
+
RAYS_EXPORT Rucy::Class camera_class ();
|
20
20
|
// class Rays::Camera
|
21
21
|
|
22
22
|
|