rays 0.3.16 → 0.4.0
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 +4 -4
- data/.doc/ext/rays/bitmap.cpp +1 -1
- data/.doc/ext/rays/bounds.cpp +1 -4
- data/.doc/ext/rays/camera.cpp +10 -2
- data/.doc/ext/rays/color.cpp +1 -3
- data/.doc/ext/rays/color_space.cpp +3 -3
- data/.doc/ext/rays/font.cpp +1 -4
- data/.doc/ext/rays/image.cpp +4 -3
- data/.doc/ext/rays/matrix.cpp +1 -4
- data/.doc/ext/rays/painter.cpp +8 -0
- data/.doc/ext/rays/point.cpp +1 -4
- data/.doc/ext/rays/polygon.cpp +11 -3
- data/.doc/ext/rays/polyline.cpp +13 -8
- data/.doc/ext/rays/rays.cpp +10 -6
- data/.doc/ext/rays/shader.cpp +13 -5
- data/.github/workflows/release-gem.yml +10 -1
- data/.github/workflows/test.yml +9 -0
- data/ChangeLog.md +10 -0
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +1 -1
- data/ext/rays/bounds.cpp +1 -4
- data/ext/rays/camera.cpp +11 -2
- data/ext/rays/color.cpp +1 -3
- data/ext/rays/color_space.cpp +3 -3
- data/ext/rays/font.cpp +1 -4
- data/ext/rays/image.cpp +4 -3
- data/ext/rays/matrix.cpp +1 -4
- data/ext/rays/painter.cpp +9 -0
- data/ext/rays/point.cpp +1 -4
- data/ext/rays/polygon.cpp +12 -3
- data/ext/rays/polyline.cpp +14 -8
- data/ext/rays/rays.cpp +10 -6
- data/ext/rays/shader.cpp +14 -5
- data/include/rays/bitmap.h +1 -1
- data/include/rays/color_space.h +6 -2
- data/include/rays/defs.h +14 -4
- data/include/rays/image.h +2 -2
- data/lib/rays/camera.rb +1 -1
- data/lib/rays/extension.rb +1 -1
- data/lib/rays/image.rb +2 -2
- data/lib/rays/polygon.rb +1 -1
- data/lib/rays/polyline.rb +1 -1
- data/lib/rays/shader.rb +1 -1
- data/rays.gemspec +2 -2
- data/src/color_space.cpp +5 -5
- data/src/image.cpp +2 -2
- data/src/ios/bitmap.mm +3 -3
- data/src/ios/font.mm +3 -3
- data/src/opengl/bitmap.cpp +1 -1
- data/src/opengl/color_space.cpp +11 -2
- data/src/opengl/color_space.h +1 -1
- data/src/opengl/texture.cpp +5 -5
- data/src/osx/bitmap.mm +14 -3
- data/src/osx/font.mm +3 -3
- data/src/sdl/bitmap.cpp +28 -9
- data/src/texture.h +1 -1
- data/src/win32/bitmap.cpp +73 -35
- metadata +6 -6
data/ext/rays/font.cpp
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#include "rays/ruby/font.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
#include <assert.h>
|
|
5
4
|
#include "defs.h"
|
|
6
5
|
|
|
7
6
|
|
|
@@ -191,14 +190,12 @@ namespace Rucy
|
|
|
191
190
|
template <> RAYS_EXPORT Rays::Font
|
|
192
191
|
value_to<Rays::Font> (int argc, const Value* argv, bool convert)
|
|
193
192
|
{
|
|
194
|
-
if (argc == 1 && argv->is_array())
|
|
193
|
+
if (argc == 1 && argv && argv->is_array())
|
|
195
194
|
{
|
|
196
195
|
argc = argv->size();
|
|
197
196
|
argv = argv->as_array();
|
|
198
197
|
}
|
|
199
198
|
|
|
200
|
-
assert(argc == 0 || (argc > 0 && argv));
|
|
201
|
-
|
|
202
199
|
if (convert)
|
|
203
200
|
{
|
|
204
201
|
if (argc == 0)
|
data/ext/rays/image.cpp
CHANGED
|
@@ -42,7 +42,7 @@ RUCY_DEF3(initialize, args, pixel_density, smooth)
|
|
|
42
42
|
{
|
|
43
43
|
int width = to<int>(args[0]);
|
|
44
44
|
int height = to<int>(args[1]);
|
|
45
|
-
auto cs = (argc >= 3) ? to<Rays::ColorSpace>(args[2]) : Rays::
|
|
45
|
+
auto cs = (argc >= 3) ? to<Rays::ColorSpace>(args[2]) : Rays::DEFAULT_COLORSPACE;
|
|
46
46
|
*THIS = Rays::Image(width, height, cs, pd, smooth);
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -145,9 +145,10 @@ RUCY_DEF1(compare, other)
|
|
|
145
145
|
RUCY_END
|
|
146
146
|
|
|
147
147
|
static
|
|
148
|
-
|
|
148
|
+
RUCY_DEF3(load, path, pixel_density, smooth)
|
|
149
149
|
{
|
|
150
|
-
return value(Rays::load_image(
|
|
150
|
+
return value(Rays::load_image(
|
|
151
|
+
path.c_str(), to<float>(pixel_density), to<bool>(smooth)));
|
|
151
152
|
}
|
|
152
153
|
RUCY_END
|
|
153
154
|
|
data/ext/rays/matrix.cpp
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#include "rays/ruby/matrix.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
#include <assert.h>
|
|
5
4
|
#include "rays/ruby/point.h"
|
|
6
5
|
#include "defs.h"
|
|
7
6
|
|
|
@@ -304,14 +303,12 @@ namespace Rucy
|
|
|
304
303
|
template <> RAYS_EXPORT Rays::Matrix
|
|
305
304
|
value_to<Rays::Matrix> (int argc, const Value* argv, bool convert)
|
|
306
305
|
{
|
|
307
|
-
if (argc == 1 && argv->is_array())
|
|
306
|
+
if (argc == 1 && argv && argv->is_array())
|
|
308
307
|
{
|
|
309
308
|
argc = argv->size();
|
|
310
309
|
argv = argv->as_array();
|
|
311
310
|
}
|
|
312
311
|
|
|
313
|
-
assert(argc == 0 || (argc > 0 && argv));
|
|
314
|
-
|
|
315
312
|
if (convert)
|
|
316
313
|
{
|
|
317
314
|
if (argc == 0)
|
data/ext/rays/painter.cpp
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
#include <vector>
|
|
5
|
+
#include "rays/exception.h"
|
|
5
6
|
#include "rays/ruby/point.h"
|
|
6
7
|
#include "rays/ruby/bounds.h"
|
|
7
8
|
#include "rays/ruby/color.h"
|
|
@@ -26,6 +27,13 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
|
26
27
|
}
|
|
27
28
|
RUCY_END
|
|
28
29
|
|
|
30
|
+
static
|
|
31
|
+
RUCY_DEF1(initialize_copy, obj)
|
|
32
|
+
{
|
|
33
|
+
Rays::rays_error(__FILE__, __LINE__, "can not duplicate Painter");
|
|
34
|
+
}
|
|
35
|
+
RUCY_END
|
|
36
|
+
|
|
29
37
|
static
|
|
30
38
|
RUCY_DEFN(canvas)
|
|
31
39
|
{
|
|
@@ -865,6 +873,7 @@ Init_rays_painter ()
|
|
|
865
873
|
|
|
866
874
|
cPainter = mRays.define_class("Painter");
|
|
867
875
|
cPainter.define_alloc_func(alloc);
|
|
876
|
+
cPainter.define_private_method("initialize_copy", initialize_copy);
|
|
868
877
|
|
|
869
878
|
cPainter.define_method("canvas", canvas);
|
|
870
879
|
cPainter.define_method("bounds", bounds);
|
data/ext/rays/point.cpp
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#include "rays/ruby/point.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
#include <assert.h>
|
|
5
4
|
#include "defs.h"
|
|
6
5
|
|
|
7
6
|
|
|
@@ -306,14 +305,12 @@ namespace Rucy
|
|
|
306
305
|
template <> RAYS_EXPORT Rays::Point
|
|
307
306
|
value_to<Rays::Point> (int argc, const Value* argv, bool convert)
|
|
308
307
|
{
|
|
309
|
-
if (argc == 1 && argv->is_array())
|
|
308
|
+
if (argc == 1 && argv && argv->is_array())
|
|
310
309
|
{
|
|
311
310
|
argc = argv->size();
|
|
312
311
|
argv = argv->as_array();
|
|
313
312
|
}
|
|
314
313
|
|
|
315
|
-
assert(argc == 0 || (argc > 0 && argv));
|
|
316
|
-
|
|
317
314
|
if (convert)
|
|
318
315
|
{
|
|
319
316
|
if (argc == 0)
|
data/ext/rays/polygon.cpp
CHANGED
|
@@ -23,7 +23,7 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
|
23
23
|
RUCY_END
|
|
24
24
|
|
|
25
25
|
static
|
|
26
|
-
RUCY_DEF4(
|
|
26
|
+
RUCY_DEF4(initialize, args, loop, colors, texcoords)
|
|
27
27
|
{
|
|
28
28
|
CHECK;
|
|
29
29
|
|
|
@@ -39,6 +39,14 @@ RUCY_DEF4(setup, args, loop, colors, texcoords)
|
|
|
39
39
|
}
|
|
40
40
|
RUCY_END
|
|
41
41
|
|
|
42
|
+
static
|
|
43
|
+
RUCY_DEF1(initialize_copy, obj)
|
|
44
|
+
{
|
|
45
|
+
CHECK;
|
|
46
|
+
*THIS = to<Rays::Polygon&>(obj);
|
|
47
|
+
}
|
|
48
|
+
RUCY_END
|
|
49
|
+
|
|
42
50
|
static
|
|
43
51
|
RUCY_DEFN(expand)
|
|
44
52
|
{
|
|
@@ -105,7 +113,7 @@ RUCY_DEF0(each)
|
|
|
105
113
|
|
|
106
114
|
Value ret = Qnil;
|
|
107
115
|
for (const auto& polyline : *THIS)
|
|
108
|
-
ret =
|
|
116
|
+
ret = yield(value(polyline));
|
|
109
117
|
return ret;
|
|
110
118
|
}
|
|
111
119
|
RUCY_END
|
|
@@ -371,7 +379,8 @@ Init_rays_polygon ()
|
|
|
371
379
|
|
|
372
380
|
cPolygon = mRays.define_class("Polygon");
|
|
373
381
|
cPolygon.define_alloc_func(alloc);
|
|
374
|
-
cPolygon.define_private_method("
|
|
382
|
+
cPolygon.define_private_method("initialize!", initialize);
|
|
383
|
+
cPolygon.define_private_method("initialize_copy", initialize_copy);
|
|
375
384
|
cPolygon.define_method("expand", expand);
|
|
376
385
|
cPolygon.define_method("bounds", bounds);
|
|
377
386
|
cPolygon.define_method("size", size);
|
data/ext/rays/polyline.cpp
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#include "rays/ruby/polyline.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
#include <assert.h>
|
|
5
4
|
#include <vector>
|
|
6
5
|
#include "rays/ruby/color.h"
|
|
7
6
|
#include "rays/ruby/point.h"
|
|
@@ -25,7 +24,7 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
|
25
24
|
RUCY_END
|
|
26
25
|
|
|
27
26
|
static
|
|
28
|
-
RUCY_DEF6(
|
|
27
|
+
RUCY_DEF6(initialize, points, loop, fill, colors, texcoords, hole)
|
|
29
28
|
{
|
|
30
29
|
CHECK;
|
|
31
30
|
|
|
@@ -37,6 +36,14 @@ RUCY_DEF6(setup, points, loop, fill, colors, texcoords, hole)
|
|
|
37
36
|
}
|
|
38
37
|
RUCY_END
|
|
39
38
|
|
|
39
|
+
static
|
|
40
|
+
RUCY_DEF1(initialize_copy, obj)
|
|
41
|
+
{
|
|
42
|
+
CHECK;
|
|
43
|
+
*THIS = to<Rays::Polyline&>(obj);
|
|
44
|
+
}
|
|
45
|
+
RUCY_END
|
|
46
|
+
|
|
40
47
|
static
|
|
41
48
|
RUCY_DEFN(expand)
|
|
42
49
|
{
|
|
@@ -151,7 +158,7 @@ RUCY_DEF0(each_point)
|
|
|
151
158
|
|
|
152
159
|
Value ret = Qnil;
|
|
153
160
|
for (const auto& point : *THIS)
|
|
154
|
-
ret =
|
|
161
|
+
ret = yield(value(point));
|
|
155
162
|
return ret;
|
|
156
163
|
}
|
|
157
164
|
RUCY_END
|
|
@@ -168,7 +175,7 @@ RUCY_DEF0(each_color)
|
|
|
168
175
|
{
|
|
169
176
|
size_t size = THIS->size();
|
|
170
177
|
for (size_t i = 0; i < size; ++i)
|
|
171
|
-
ret =
|
|
178
|
+
ret = yield(value(colors[i]));
|
|
172
179
|
}
|
|
173
180
|
return ret;
|
|
174
181
|
}
|
|
@@ -186,7 +193,7 @@ RUCY_DEF0(each_texcoord)
|
|
|
186
193
|
{
|
|
187
194
|
size_t size = THIS->size();
|
|
188
195
|
for (size_t i = 0; i < size; ++i)
|
|
189
|
-
ret =
|
|
196
|
+
ret = yield(value(*(Rays::Point*) &texcoords[i]));
|
|
190
197
|
}
|
|
191
198
|
return ret;
|
|
192
199
|
}
|
|
@@ -202,7 +209,8 @@ Init_rays_polyline ()
|
|
|
202
209
|
|
|
203
210
|
cPolyline = mRays.define_class("Polyline");
|
|
204
211
|
cPolyline.define_alloc_func(alloc);
|
|
205
|
-
cPolyline.define_private_method("
|
|
212
|
+
cPolyline.define_private_method("initialize!", initialize);
|
|
213
|
+
cPolyline.define_private_method("initialize_copy", initialize_copy);
|
|
206
214
|
cPolyline.define_method("expand", expand);
|
|
207
215
|
cPolyline.define_method("bounds", bounds);
|
|
208
216
|
cPolyline.define_method("loop?", is_loop);
|
|
@@ -227,8 +235,6 @@ namespace Rucy
|
|
|
227
235
|
template <> RAYS_EXPORT Rays::Polyline
|
|
228
236
|
value_to<Rays::Polyline> (int argc, const Value* argv, bool convert)
|
|
229
237
|
{
|
|
230
|
-
assert(argc == 0 || (argc > 0 && argv));
|
|
231
|
-
|
|
232
238
|
if (convert)
|
|
233
239
|
{
|
|
234
240
|
if (argc <= 0)
|
data/ext/rays/rays.cpp
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#include "rays/ruby/rays.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
#include <assert.h>
|
|
5
4
|
#include <vector>
|
|
6
5
|
#include "defs.h"
|
|
7
6
|
|
|
@@ -115,7 +114,8 @@ namespace Rucy
|
|
|
115
114
|
template <> RAYS_EXPORT Rays::CapType
|
|
116
115
|
value_to<Rays::CapType> (int argc, const Value* argv, bool convert)
|
|
117
116
|
{
|
|
118
|
-
|
|
117
|
+
if (argc <= 0 || !argv)
|
|
118
|
+
argument_error(__FILE__, __LINE__);
|
|
119
119
|
|
|
120
120
|
if (convert)
|
|
121
121
|
{
|
|
@@ -148,7 +148,8 @@ namespace Rucy
|
|
|
148
148
|
template <> RAYS_EXPORT Rays::JoinType
|
|
149
149
|
value_to<Rays::JoinType> (int argc, const Value* argv, bool convert)
|
|
150
150
|
{
|
|
151
|
-
|
|
151
|
+
if (argc <= 0 || !argv)
|
|
152
|
+
argument_error(__FILE__, __LINE__);
|
|
152
153
|
|
|
153
154
|
if (convert)
|
|
154
155
|
{
|
|
@@ -181,7 +182,8 @@ namespace Rucy
|
|
|
181
182
|
template <> RAYS_EXPORT Rays::BlendMode
|
|
182
183
|
value_to<Rays::BlendMode> (int argc, const Value* argv, bool convert)
|
|
183
184
|
{
|
|
184
|
-
|
|
185
|
+
if (argc <= 0 || !argv)
|
|
186
|
+
argument_error(__FILE__, __LINE__);
|
|
185
187
|
|
|
186
188
|
if (convert)
|
|
187
189
|
{
|
|
@@ -214,7 +216,8 @@ namespace Rucy
|
|
|
214
216
|
template <> RAYS_EXPORT Rays::TexCoordMode
|
|
215
217
|
value_to<Rays::TexCoordMode> (int argc, const Value* argv, bool convert)
|
|
216
218
|
{
|
|
217
|
-
|
|
219
|
+
if (argc <= 0 || !argv)
|
|
220
|
+
argument_error(__FILE__, __LINE__);
|
|
218
221
|
|
|
219
222
|
if (convert)
|
|
220
223
|
{
|
|
@@ -247,7 +250,8 @@ namespace Rucy
|
|
|
247
250
|
template <> RAYS_EXPORT Rays::TexCoordWrap
|
|
248
251
|
value_to<Rays::TexCoordWrap> (int argc, const Value* argv, bool convert)
|
|
249
252
|
{
|
|
250
|
-
|
|
253
|
+
if (argc <= 0 || !argv)
|
|
254
|
+
argument_error(__FILE__, __LINE__);
|
|
251
255
|
|
|
252
256
|
if (convert)
|
|
253
257
|
{
|
data/ext/rays/shader.cpp
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#include "rays/ruby/shader.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
#include
|
|
4
|
+
#include "rays/exception.h"
|
|
5
5
|
#include "rays/ruby/image.h"
|
|
6
6
|
#include "defs.h"
|
|
7
7
|
|
|
@@ -20,6 +20,13 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
|
20
20
|
}
|
|
21
21
|
RUCY_END
|
|
22
22
|
|
|
23
|
+
static
|
|
24
|
+
RUCY_DEF1(initialize_copy, obj)
|
|
25
|
+
{
|
|
26
|
+
Rays::rays_error(__FILE__, __LINE__, "can not duplicate Shader");
|
|
27
|
+
}
|
|
28
|
+
RUCY_END
|
|
29
|
+
|
|
23
30
|
static const char*
|
|
24
31
|
to_name (const Value& names, size_t index)
|
|
25
32
|
{
|
|
@@ -82,7 +89,7 @@ make_env (const Value& names, const Value& ignore_no_uniform_location_error)
|
|
|
82
89
|
}
|
|
83
90
|
|
|
84
91
|
static
|
|
85
|
-
RUCY_DEF4(
|
|
92
|
+
RUCY_DEF4(initialize,
|
|
86
93
|
fragment_shader_source, vertex_shader_source,
|
|
87
94
|
builtin_variable_names, ignore_no_uniform_location_error)
|
|
88
95
|
{
|
|
@@ -185,7 +192,8 @@ Init_rays_shader ()
|
|
|
185
192
|
|
|
186
193
|
cShader = mRays.define_class("Shader");
|
|
187
194
|
cShader.define_alloc_func(alloc);
|
|
188
|
-
cShader.define_private_method("
|
|
195
|
+
cShader.define_private_method("initialize!", initialize);
|
|
196
|
+
cShader.define_private_method("initialize_copy", initialize_copy);
|
|
189
197
|
cShader.define_private_method("set_uniform", set_uniform);
|
|
190
198
|
cShader.define_method( "vertex_shader_source", get_vertex_shader_source);
|
|
191
199
|
cShader.define_method("fragment_shader_source", get_fragment_shader_source);
|
|
@@ -199,13 +207,14 @@ namespace Rucy
|
|
|
199
207
|
template <> RAYS_EXPORT Rays::Shader
|
|
200
208
|
value_to<Rays::Shader> (int argc, const Value* argv, bool convert)
|
|
201
209
|
{
|
|
202
|
-
if (argc == 1 && argv->is_array())
|
|
210
|
+
if (argc == 1 && argv && argv->is_array())
|
|
203
211
|
{
|
|
204
212
|
argc = argv->size();
|
|
205
213
|
argv = argv->as_array();
|
|
206
214
|
}
|
|
207
215
|
|
|
208
|
-
|
|
216
|
+
if (argc <= 0 || !argv)
|
|
217
|
+
argument_error(__FILE__, __LINE__);
|
|
209
218
|
|
|
210
219
|
if (convert)
|
|
211
220
|
{
|
data/include/rays/bitmap.h
CHANGED
data/include/rays/color_space.h
CHANGED
|
@@ -14,7 +14,7 @@ namespace Rays
|
|
|
14
14
|
enum ColorSpaceType
|
|
15
15
|
{
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
COLORSPACE_NONE = 0,
|
|
18
18
|
|
|
19
19
|
GRAY_8, GRAY_16, GRAY_24, GRAY_32, GRAY_float,
|
|
20
20
|
|
|
@@ -40,7 +40,11 @@ namespace Rays
|
|
|
40
40
|
|
|
41
41
|
BGRA = BGRA_8888, BGRX = BGRX_8888, ABGR = ABGR_8888, XBGR = XBGR_8888,
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
#ifdef WIN32
|
|
44
|
+
DEFAULT_COLORSPACE = BGRA,
|
|
45
|
+
#else
|
|
46
|
+
DEFAULT_COLORSPACE = RGBA,
|
|
47
|
+
#endif
|
|
44
48
|
|
|
45
49
|
};// ColorSpaceType
|
|
46
50
|
|
data/include/rays/defs.h
CHANGED
|
@@ -22,14 +22,24 @@ namespace Rays
|
|
|
22
22
|
{
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
namespace Types
|
|
26
|
+
{
|
|
26
27
|
|
|
27
|
-
using Xot::String;
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
typedef float coord;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
}// Types
|
|
33
|
+
|
|
30
34
|
|
|
35
|
+
using namespace Xot ::Types;
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
using namespace Rays::Types;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
using Xot::String;
|
|
41
|
+
|
|
42
|
+
using Xot::StringList;
|
|
33
43
|
|
|
34
44
|
|
|
35
45
|
enum CapType
|
data/include/rays/image.h
CHANGED
|
@@ -26,7 +26,7 @@ namespace Rays
|
|
|
26
26
|
Image ();
|
|
27
27
|
|
|
28
28
|
Image (
|
|
29
|
-
int width, int height, const ColorSpace& cs =
|
|
29
|
+
int width, int height, const ColorSpace& cs = DEFAULT_COLORSPACE,
|
|
30
30
|
float pixel_density = 1, bool smooth = false);
|
|
31
31
|
|
|
32
32
|
Image (
|
|
@@ -78,7 +78,7 @@ namespace Rays
|
|
|
78
78
|
};// Image
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
Image load_image (const char* path);
|
|
81
|
+
Image load_image (const char* path, float pixel_density = 1, bool smooth = false);
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
}// Rays
|
data/lib/rays/camera.rb
CHANGED
|
@@ -11,7 +11,7 @@ module Rays
|
|
|
11
11
|
min_width = -1, min_height = -1,
|
|
12
12
|
device_name: nil, resize: true, crop: true, &block)
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
initialize! device_name, min_width, min_height, resize, crop
|
|
15
15
|
Xot::BlockUtil.instance_eval_or_block_call self, &block if block
|
|
16
16
|
end
|
|
17
17
|
|
data/lib/rays/extension.rb
CHANGED
data/lib/rays/image.rb
CHANGED
|
@@ -39,9 +39,9 @@ module Rays
|
|
|
39
39
|
get_bitmap true
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
def self.load(path)
|
|
42
|
+
def self.load(path, pixel_density: 1, smooth: false)
|
|
43
43
|
raise Errno::ENOENT, "no such file: '#{path}'" unless File.exist? path
|
|
44
|
-
load! path
|
|
44
|
+
load! path, pixel_density, smooth
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
end# Image
|
data/lib/rays/polygon.rb
CHANGED
data/lib/rays/polyline.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Rays
|
|
|
12
12
|
def initialize(
|
|
13
13
|
*points, loop: false, fill: nil, colors: nil, texcoords: nil, hole: false)
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
initialize! points, loop, (fill != nil ? fill : loop), colors, texcoords, hole
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def with(**kwargs)
|
data/lib/rays/shader.rb
CHANGED
data/rays.gemspec
CHANGED
|
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
|
27
27
|
|
|
28
|
-
s.add_dependency 'xot', '~> 0.
|
|
29
|
-
s.add_dependency 'rucy', '~> 0.
|
|
28
|
+
s.add_dependency 'xot', '~> 0.4.0'
|
|
29
|
+
s.add_dependency 'rucy', '~> 0.4.0'
|
|
30
30
|
|
|
31
31
|
s.files = `git ls-files`.split $/
|
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/color_space.cpp
CHANGED
|
@@ -26,7 +26,7 @@ namespace Rays
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
ColorSpace::ColorSpace ()
|
|
29
|
-
: type_(
|
|
29
|
+
: type_(COLORSPACE_NONE), premult(false)
|
|
30
30
|
{
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -46,7 +46,7 @@ namespace Rays
|
|
|
46
46
|
{
|
|
47
47
|
static const int BPPS[] =
|
|
48
48
|
{
|
|
49
|
-
0, //
|
|
49
|
+
0, // NONE
|
|
50
50
|
8, 16, 24, 32, 32, // GRAY
|
|
51
51
|
8, 16, 24, 32, 32, // ALPHA
|
|
52
52
|
8, 8, 8, 8, 8, // RGB(A),
|
|
@@ -54,7 +54,7 @@ namespace Rays
|
|
|
54
54
|
32, 32, 32, // RGB(A) float
|
|
55
55
|
32, 32, 32, // BGR(A) float
|
|
56
56
|
};
|
|
57
|
-
if (type_ < 0 || COLORSPACE_MAX <= type_) return BPPS[
|
|
57
|
+
if (type_ < 0 || COLORSPACE_MAX <= type_) return BPPS[COLORSPACE_NONE];
|
|
58
58
|
return BPPS[type_];
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -69,7 +69,7 @@ namespace Rays
|
|
|
69
69
|
{
|
|
70
70
|
static const int BPPS[] =
|
|
71
71
|
{
|
|
72
|
-
0, //
|
|
72
|
+
0, // NONE
|
|
73
73
|
8, 16, 24, 32, 32, // GRAY
|
|
74
74
|
8, 16, 24, 32, 32, // ALPHA
|
|
75
75
|
24, 32, 32, 32, 32, // RGB(A)
|
|
@@ -77,7 +77,7 @@ namespace Rays
|
|
|
77
77
|
96, 128, 128, // RGB(A) float
|
|
78
78
|
96, 128, 128, // BGR(A) float
|
|
79
79
|
};
|
|
80
|
-
if (type_ < 0 || COLORSPACE_MAX <= type_) return BPPS[
|
|
80
|
+
if (type_ < 0 || COLORSPACE_MAX <= type_) return BPPS[COLORSPACE_NONE];
|
|
81
81
|
return BPPS[type_];
|
|
82
82
|
}
|
|
83
83
|
|
data/src/image.cpp
CHANGED
|
@@ -178,9 +178,9 @@ namespace Rays
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
Image
|
|
181
|
-
load_image (const char* path)
|
|
181
|
+
load_image (const char* path, float pixel_density, bool smooth)
|
|
182
182
|
{
|
|
183
|
-
return Image(Bitmap_load(path));
|
|
183
|
+
return Image(Bitmap_load(path), pixel_density, smooth);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
186
|
|
data/src/ios/bitmap.mm
CHANGED
|
@@ -120,7 +120,7 @@ namespace Rays
|
|
|
120
120
|
if (pixels) delete [] (uchar*) pixels;
|
|
121
121
|
|
|
122
122
|
width = height = 0;
|
|
123
|
-
color_space =
|
|
123
|
+
color_space = COLORSPACE_NONE;
|
|
124
124
|
pixels = NULL;
|
|
125
125
|
context = NULL;
|
|
126
126
|
modified = false;
|
|
@@ -323,8 +323,8 @@ namespace Rays
|
|
|
323
323
|
{
|
|
324
324
|
if (!*this)
|
|
325
325
|
{
|
|
326
|
-
static const ColorSpace
|
|
327
|
-
return
|
|
326
|
+
static const ColorSpace NONE = COLORSPACE_NONE;
|
|
327
|
+
return NONE;
|
|
328
328
|
}
|
|
329
329
|
return self->color_space;
|
|
330
330
|
}
|
data/src/ios/font.mm
CHANGED
|
@@ -67,7 +67,7 @@ namespace Rays
|
|
|
67
67
|
CFRelease);
|
|
68
68
|
|
|
69
69
|
CFAttributedStringPtr attrstr(
|
|
70
|
-
CFAttributedStringCreate(NULL, Xot::
|
|
70
|
+
CFAttributedStringCreate(NULL, Xot::String(str).to_cfstr().get(), attr.get()),
|
|
71
71
|
CFRelease);
|
|
72
72
|
|
|
73
73
|
return CTLinePtr(
|
|
@@ -129,7 +129,7 @@ namespace Rays
|
|
|
129
129
|
RawFont::RawFont (const char* name, coord size)
|
|
130
130
|
{
|
|
131
131
|
self->font = name
|
|
132
|
-
? CTFontCreateWithName(Xot::
|
|
132
|
+
? CTFontCreateWithName(Xot::String(name).to_cfstr().get(), size, NULL)
|
|
133
133
|
: CTFontCreateUIFontForLanguage(kCTFontSystemFontType, size, NULL);
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -139,7 +139,7 @@ namespace Rays
|
|
|
139
139
|
if (path)
|
|
140
140
|
*this = RawFont_load(path, size);
|
|
141
141
|
else
|
|
142
|
-
self->font = CTFontCreateWithName(
|
|
142
|
+
self->font = CTFontCreateWithName(obj.name().to_cfstr().get(), size, NULL);
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
RawFont::~RawFont ()
|
data/src/opengl/bitmap.cpp
CHANGED
|
@@ -23,7 +23,7 @@ namespace Rays
|
|
|
23
23
|
&bmp, tex.width(), tex.height(), tex.color_space(), NULL, false);
|
|
24
24
|
|
|
25
25
|
GLenum format, type;
|
|
26
|
-
ColorSpace_get_gl_format_and_type(&format, &type, tex.color_space());
|
|
26
|
+
ColorSpace_get_gl_format_and_type(NULL, &format, &type, tex.color_space());
|
|
27
27
|
|
|
28
28
|
FrameBuffer fb(tex);
|
|
29
29
|
FrameBufferBinder binder(fb.id());
|
data/src/opengl/color_space.cpp
CHANGED
|
@@ -10,14 +10,23 @@ namespace Rays
|
|
|
10
10
|
|
|
11
11
|
void
|
|
12
12
|
ColorSpace_get_gl_format_and_type (
|
|
13
|
-
GLenum* format, GLenum* type, const ColorSpace& cs)
|
|
13
|
+
GLenum* internalformat, GLenum* format, GLenum* type, const ColorSpace& cs)
|
|
14
14
|
{
|
|
15
|
-
if (!format && !type)
|
|
15
|
+
if (!internalformat && !format && !type)
|
|
16
16
|
argument_error(__FILE__, __LINE__);
|
|
17
17
|
|
|
18
18
|
if (!cs)
|
|
19
19
|
invalid_state_error(__FILE__, __LINE__);
|
|
20
20
|
|
|
21
|
+
if (internalformat)
|
|
22
|
+
{
|
|
23
|
+
if (cs.is_rgb() || cs.is_bgr()) *internalformat = cs.has_alpha() ? GL_RGBA : GL_RGB;
|
|
24
|
+
else if (cs.is_gray()) *internalformat = GL_LUMINANCE;
|
|
25
|
+
else if (cs.is_alpha()) *internalformat = GL_ALPHA;
|
|
26
|
+
else
|
|
27
|
+
rays_error(__FILE__, __LINE__, "invalid color space.");
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
if (format)
|
|
22
31
|
{
|
|
23
32
|
if (cs.is_rgb()) *format = cs.has_alpha() ? GL_RGBA : GL_RGB;
|