rays 0.1.46 → 0.1.48
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 +499 -0
- data/.doc/ext/rays/camera.cpp +2 -2
- data/.doc/ext/rays/defs.cpp +35 -11
- data/.doc/ext/rays/font.cpp +50 -2
- data/.doc/ext/rays/native.cpp +2 -4
- data/.doc/ext/rays/painter.cpp +111 -6
- data/.doc/ext/rays/polygon.cpp +152 -41
- data/.doc/ext/rays/polyline.cpp +89 -10
- data/.doc/ext/rays/rays.cpp +91 -11
- data/.doc/ext/rays/{noise.cpp → util.cpp} +2 -2
- data/.github/workflows/test.yml +0 -1
- data/ChangeLog.md +38 -0
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +501 -0
- data/ext/rays/camera.cpp +2 -2
- data/ext/rays/defs.cpp +35 -11
- data/ext/rays/defs.h +56 -3
- data/ext/rays/font.cpp +56 -4
- data/ext/rays/native.cpp +2 -4
- data/ext/rays/painter.cpp +125 -11
- data/ext/rays/polygon.cpp +161 -41
- data/ext/rays/polyline.cpp +95 -9
- data/ext/rays/rays.cpp +91 -11
- data/ext/rays/{noise.cpp → util.cpp} +2 -2
- data/include/rays/defs.h +24 -0
- data/include/rays/font.h +17 -3
- data/include/rays/matrix.h +2 -0
- data/include/rays/painter.h +29 -1
- data/include/rays/polygon.h +57 -33
- data/include/rays/polyline.h +20 -1
- data/include/rays/ruby/polygon.h +0 -11
- data/include/rays/ruby/rays.h +4 -0
- data/include/rays/{noise.h → util.h} +2 -2
- data/lib/rays/color.rb +1 -1
- data/lib/rays/font.rb +1 -1
- data/lib/rays/image.rb +1 -1
- data/lib/rays/painter.rb +13 -2
- data/lib/rays/point.rb +1 -1
- data/lib/rays/polygon.rb +54 -16
- data/lib/rays/polyline.rb +54 -8
- data/lib/rays.rb +0 -1
- data/rays.gemspec +2 -2
- data/src/color_space.cpp +2 -2
- data/src/font.cpp +24 -2
- data/src/font.h +8 -1
- data/src/ios/font.mm +88 -27
- data/src/matrix.cpp +8 -0
- data/src/osx/font.mm +90 -28
- data/src/osx/helper.h +2 -2
- data/src/osx/helper.mm +2 -2
- data/src/painter.cpp +227 -90
- data/src/painter.h +11 -3
- data/src/polygon.cpp +588 -205
- data/src/polyline.cpp +154 -28
- data/src/polyline.h +3 -5
- data/src/shader.cpp +36 -4
- data/src/shader.h +1 -1
- data/src/texture.cpp +2 -2
- data/src/{noise.cpp → util.cpp} +1 -1
- data/src/win32/font.cpp +1 -1
- data/test/test_bitmap.rb +16 -2
- data/test/test_color.rb +4 -0
- data/test/test_font.rb +20 -2
- data/test/test_image.rb +18 -18
- data/test/test_point.rb +1 -1
- data/test/test_polygon.rb +52 -45
- data/test/test_polyline.rb +191 -72
- metadata +11 -17
- data/.doc/ext/rays/polygon_line.cpp +0 -97
- data/ext/rays/polygon_line.cpp +0 -100
- data/lib/rays/polygon_line.rb +0 -33
- data/test/test_polygon_line.rb +0 -164
data/.doc/ext/rays/rays.cpp
CHANGED
@@ -9,6 +9,8 @@
|
|
9
9
|
RUCY_DEFINE_CONVERT_TO(Rays::CapType)
|
10
10
|
RUCY_DEFINE_CONVERT_TO(Rays::JoinType)
|
11
11
|
RUCY_DEFINE_CONVERT_TO(Rays::BlendMode)
|
12
|
+
RUCY_DEFINE_CONVERT_TO(Rays::TexCoordMode)
|
13
|
+
RUCY_DEFINE_CONVERT_TO(Rays::TexCoordWrap)
|
12
14
|
|
13
15
|
|
14
16
|
template <typename T>
|
@@ -16,7 +18,7 @@ struct EnumType
|
|
16
18
|
{
|
17
19
|
const char* name;
|
18
20
|
const char* short_name;
|
19
|
-
T
|
21
|
+
T value;
|
20
22
|
};
|
21
23
|
|
22
24
|
static std::vector<EnumType<Rays::CapType>> CAP_TYPES({
|
@@ -43,6 +45,16 @@ static std::vector<EnumType<Rays::BlendMode>> BLEND_MODES({
|
|
43
45
|
{"BLEND_REPLACE", "REPLACE", Rays::BLEND_REPLACE},
|
44
46
|
});
|
45
47
|
|
48
|
+
static std::vector<EnumType<Rays::TexCoordMode>> TEXCOORD_MODES({
|
49
|
+
{"TEXCOORD_IMAGE", "IMAGE", Rays::TEXCOORD_IMAGE},
|
50
|
+
{"TEXCOORD_NORMAL", "NORMAL", Rays::TEXCOORD_NORMAL},
|
51
|
+
});
|
52
|
+
|
53
|
+
static std::vector<EnumType<Rays::TexCoordWrap>> TEXCOORD_WRAPS({
|
54
|
+
{"TEXCOORD_CLAMP", "CLAMP", Rays::TEXCOORD_CLAMP},
|
55
|
+
{"TEXCOORD_REPEAT", "REPEAT", Rays::TEXCOORD_REPEAT},
|
56
|
+
});
|
57
|
+
|
46
58
|
|
47
59
|
static
|
48
60
|
VALUE init(VALUE self)
|
@@ -70,13 +82,19 @@ Init_rays ()
|
|
70
82
|
mRays.define_singleton_method("fin!", fin);
|
71
83
|
|
72
84
|
for (auto it = CAP_TYPES.begin(); it != CAP_TYPES.end(); ++it)
|
73
|
-
mRays.define_const(it->name, it->
|
85
|
+
mRays.define_const(it->name, it->value);
|
74
86
|
|
75
87
|
for (auto it = JOIN_TYPES.begin(); it != JOIN_TYPES.end(); ++it)
|
76
|
-
mRays.define_const(it->name, it->
|
88
|
+
mRays.define_const(it->name, it->value);
|
77
89
|
|
78
90
|
for (auto it = BLEND_MODES.begin(); it != BLEND_MODES.end(); ++it)
|
79
|
-
mRays.define_const(it->name, it->
|
91
|
+
mRays.define_const(it->name, it->value);
|
92
|
+
|
93
|
+
for (auto it = TEXCOORD_MODES.begin(); it != TEXCOORD_MODES.end(); ++it)
|
94
|
+
mRays.define_const(it->name, it->value);
|
95
|
+
|
96
|
+
for (auto it = TEXCOORD_WRAPS.begin(); it != TEXCOORD_WRAPS.end(); ++it)
|
97
|
+
mRays.define_const(it->name, it->value);
|
80
98
|
}
|
81
99
|
|
82
100
|
|
@@ -100,7 +118,7 @@ namespace Rucy
|
|
100
118
|
strcasecmp(str, it->name) == 0 ||
|
101
119
|
strcasecmp(str, it->short_name) == 0)
|
102
120
|
{
|
103
|
-
return it->
|
121
|
+
return it->value;
|
104
122
|
}
|
105
123
|
}
|
106
124
|
argument_error(__FILE__, __LINE__, "invalid cap type -- %s", str);
|
@@ -131,7 +149,7 @@ namespace Rucy
|
|
131
149
|
strcasecmp(str, it->name) == 0 ||
|
132
150
|
strcasecmp(str, it->short_name) == 0)
|
133
151
|
{
|
134
|
-
return it->
|
152
|
+
return it->value;
|
135
153
|
}
|
136
154
|
}
|
137
155
|
argument_error(__FILE__, __LINE__, "invalid join type -- %s", str);
|
@@ -162,18 +180,80 @@ namespace Rucy
|
|
162
180
|
strcasecmp(str, it->name) == 0 ||
|
163
181
|
strcasecmp(str, it->short_name) == 0)
|
164
182
|
{
|
165
|
-
return it->
|
183
|
+
return it->value;
|
166
184
|
}
|
167
185
|
}
|
168
186
|
argument_error(__FILE__, __LINE__, "invalid blend mode -- %s", str);
|
169
187
|
}
|
170
188
|
}
|
171
189
|
|
172
|
-
int
|
173
|
-
if (
|
174
|
-
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d",
|
190
|
+
int mode = value_to<int>(*argv, convert);
|
191
|
+
if (mode < 0 || Rays::BLEND_MAX <= mode)
|
192
|
+
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
193
|
+
|
194
|
+
return (Rays::BlendMode) mode;
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
template <> Rays::TexCoordMode
|
199
|
+
value_to<Rays::TexCoordMode> (int argc, const Value* argv, bool convert)
|
200
|
+
{
|
201
|
+
assert(argc > 0 && argv);
|
202
|
+
|
203
|
+
if (convert)
|
204
|
+
{
|
205
|
+
if (argv->is_s() || argv->is_sym())
|
206
|
+
{
|
207
|
+
const char* str = argv->c_str();
|
208
|
+
for (auto it = TEXCOORD_MODES.begin(); it != TEXCOORD_MODES.end(); ++it)
|
209
|
+
{
|
210
|
+
if (
|
211
|
+
strcasecmp(str, it->name) == 0 ||
|
212
|
+
strcasecmp(str, it->short_name) == 0)
|
213
|
+
{
|
214
|
+
return it->value;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %s", str);
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
221
|
+
int mode = value_to<int>(*argv, convert);
|
222
|
+
if (mode < 0 || Rays::TEXCOORD_MODE_MAX <= mode)
|
223
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %d", mode);
|
224
|
+
|
225
|
+
return (Rays::TexCoordMode) mode;
|
226
|
+
}
|
227
|
+
|
228
|
+
|
229
|
+
template <> Rays::TexCoordWrap
|
230
|
+
value_to<Rays::TexCoordWrap> (int argc, const Value* argv, bool convert)
|
231
|
+
{
|
232
|
+
assert(argc > 0 && argv);
|
233
|
+
|
234
|
+
if (convert)
|
235
|
+
{
|
236
|
+
if (argv->is_s() || argv->is_sym())
|
237
|
+
{
|
238
|
+
const char* str = argv->c_str();
|
239
|
+
for (auto it = TEXCOORD_WRAPS.begin(); it != TEXCOORD_WRAPS.end(); ++it)
|
240
|
+
{
|
241
|
+
if (
|
242
|
+
strcasecmp(str, it->name) == 0 ||
|
243
|
+
strcasecmp(str, it->short_name) == 0)
|
244
|
+
{
|
245
|
+
return it->value;
|
246
|
+
}
|
247
|
+
}
|
248
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %s", str);
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
int wrap = value_to<int>(*argv, convert);
|
253
|
+
if (wrap < 0 || Rays::TEXCOORD_WRAP_MAX <= wrap)
|
254
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %d", wrap);
|
175
255
|
|
176
|
-
return (Rays::
|
256
|
+
return (Rays::TexCoordWrap) wrap;
|
177
257
|
}
|
178
258
|
|
179
259
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#include "rays/
|
1
|
+
#include "rays/util.h"
|
2
2
|
#include "rays/ruby/point.h"
|
3
3
|
#include "defs.h"
|
4
4
|
|
@@ -45,7 +45,7 @@ VALUE simplex(VALUE self)
|
|
45
45
|
|
46
46
|
|
47
47
|
void
|
48
|
-
|
48
|
+
Init_rays_util ()
|
49
49
|
{
|
50
50
|
Module mRays = rb_define_module("Rays");
|
51
51
|
rb_define_singleton_method(mRays, "perlin", RUBY_METHOD_FUNC(perlin), -1);
|
data/.github/workflows/test.yml
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,6 +1,44 @@
|
|
1
1
|
# rays ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.1.48] - 2024-01-08
|
5
|
+
|
6
|
+
- Add Bitmap#pixels=
|
7
|
+
- Add Font#dup, Font#size=, Font.families, and Font.load
|
8
|
+
- Add Polyline#with
|
9
|
+
- Add Painter#texture, Painter#texcoord_mode, and Painter#texcoord_wrap
|
10
|
+
|
11
|
+
- Delete Polygon::Line because it was merged into Polyline
|
12
|
+
|
13
|
+
- Polygon and Polyline can take colors and texcoords for each vertex
|
14
|
+
- Polyline.new can take 'hole' parameter
|
15
|
+
- 'polygonA + polygonB' means Polygon.new(*polygonA.to_a, *polygonB.to_a)
|
16
|
+
- Polygon with only holes raises an ArgumentError
|
17
|
+
- Image delegates 'pixels' accessors to Bitmap
|
18
|
+
- Use GL_CLAMP_TO_EDGE for texturing
|
19
|
+
- Refine Point#inspect(), Color#inspect(), and Font#inspect()
|
20
|
+
- default_font() -> get_default_font()
|
21
|
+
- rays/include/noise.h -> rays/include/util.h
|
22
|
+
|
23
|
+
- Fix Polygon.bezier() returns broken object
|
24
|
+
- Fix get_pixels() does not work with float colors
|
25
|
+
|
26
|
+
|
27
|
+
## [v0.1.47] - 2023-12-09
|
28
|
+
|
29
|
+
- Add Polygon's singleton methods: points(), lines(), triangles(), triangle_strip(), triangle_fan(), quads(), quad_strip()
|
30
|
+
- Add create_polygon(DrawMode, ...)
|
31
|
+
- Add Painter#stroke_outset
|
32
|
+
- Add Bitmap#pixels
|
33
|
+
- Use earcut.hpp for polygon triangulation and delete poly2tri
|
34
|
+
- Painter#polygon() can take x, y, width, and height
|
35
|
+
- Polygon#bounds() caches bounds
|
36
|
+
- Polygon.line() -> Polygon.line_strip()
|
37
|
+
- Rays::Polygon.new() can take DrawMode
|
38
|
+
- Matrix(nullptr) avoids initialization
|
39
|
+
- Trigger github actions on all pull_request
|
40
|
+
|
41
|
+
|
4
42
|
## [v0.1.46] - 2023-11-09
|
5
43
|
|
6
44
|
- Use Gemfile to install gems for development instead of add_development_dependency in gemspec
|
data/Rakefile
CHANGED
@@ -25,10 +25,10 @@ use_external_library 'https://github.com/skyrpex/clipper',
|
|
25
25
|
srcdirs: 'cpp',
|
26
26
|
excludes: 'clipper/cpp/cpp_'
|
27
27
|
|
28
|
-
use_external_library 'https://github.com/
|
29
|
-
|
30
|
-
incdirs: '
|
31
|
-
srcdirs: '
|
28
|
+
use_external_library 'https://github.com/mapbox/earcut.hpp',
|
29
|
+
tag: 'v2.2.4',
|
30
|
+
incdirs: 'include/mapbox',
|
31
|
+
srcdirs: 'NOSRC'
|
32
32
|
|
33
33
|
use_external_library 'https://github.com/andrewwillmott/splines-lib',
|
34
34
|
commit: '11e7240d57b0d22871aec3308186a5fcf915ba77',
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.48
|