rays 0.1.46 → 0.1.48
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 +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/ext/rays/polyline.cpp
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
#include <assert.h>
|
5
5
|
#include <vector>
|
6
|
+
#include "rays/ruby/color.h"
|
6
7
|
#include "rays/ruby/point.h"
|
7
8
|
#include "rays/ruby/bounds.h"
|
8
9
|
#include "rays/ruby/polygon.h"
|
@@ -24,13 +25,15 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
24
25
|
RUCY_END
|
25
26
|
|
26
27
|
static
|
27
|
-
|
28
|
+
RUCY_DEF6(setup, points, loop, fill, colors, texcoords, hole)
|
28
29
|
{
|
29
30
|
CHECK;
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
CreateParams params(points, colors, texcoords);
|
33
|
+
*THIS = Rays::Polyline(
|
34
|
+
params.ppoints(), params.size(), loop, fill,
|
35
|
+
params.pcolors(), params.ptexcoords(),
|
36
|
+
hole);
|
34
37
|
}
|
35
38
|
RUCY_END
|
36
39
|
|
@@ -60,13 +63,29 @@ RUCY_DEF0(bounds)
|
|
60
63
|
RUCY_END
|
61
64
|
|
62
65
|
static
|
63
|
-
RUCY_DEF0(
|
66
|
+
RUCY_DEF0(is_loop)
|
64
67
|
{
|
65
68
|
CHECK;
|
66
69
|
return value(THIS->loop());
|
67
70
|
}
|
68
71
|
RUCY_END
|
69
72
|
|
73
|
+
static
|
74
|
+
RUCY_DEF0(is_fill)
|
75
|
+
{
|
76
|
+
CHECK;
|
77
|
+
return value(THIS->fill());
|
78
|
+
}
|
79
|
+
RUCY_END
|
80
|
+
|
81
|
+
static
|
82
|
+
RUCY_DEF0(is_hole)
|
83
|
+
{
|
84
|
+
CHECK;
|
85
|
+
return value(THIS->hole());
|
86
|
+
}
|
87
|
+
RUCY_END
|
88
|
+
|
70
89
|
static
|
71
90
|
RUCY_DEF0(size)
|
72
91
|
{
|
@@ -100,7 +119,31 @@ RUCY_DEF1(get_at, index)
|
|
100
119
|
RUCY_END
|
101
120
|
|
102
121
|
static
|
103
|
-
RUCY_DEF0(
|
122
|
+
RUCY_DEF0(has_points)
|
123
|
+
{
|
124
|
+
CHECK;
|
125
|
+
return value(THIS->points() && !THIS->empty());
|
126
|
+
}
|
127
|
+
RUCY_END
|
128
|
+
|
129
|
+
static
|
130
|
+
RUCY_DEF0(has_colors)
|
131
|
+
{
|
132
|
+
CHECK;
|
133
|
+
return value(THIS->colors() && !THIS->empty());
|
134
|
+
}
|
135
|
+
RUCY_END
|
136
|
+
|
137
|
+
static
|
138
|
+
RUCY_DEF0(has_texcoords)
|
139
|
+
{
|
140
|
+
CHECK;
|
141
|
+
return value(THIS->texcoords() && !THIS->empty());
|
142
|
+
}
|
143
|
+
RUCY_END
|
144
|
+
|
145
|
+
static
|
146
|
+
RUCY_DEF0(each_point)
|
104
147
|
{
|
105
148
|
CHECK;
|
106
149
|
|
@@ -111,6 +154,42 @@ RUCY_DEF0(each)
|
|
111
154
|
}
|
112
155
|
RUCY_END
|
113
156
|
|
157
|
+
static
|
158
|
+
RUCY_DEF0(each_color)
|
159
|
+
{
|
160
|
+
CHECK;
|
161
|
+
|
162
|
+
const Rays::Color* colors = THIS->colors();
|
163
|
+
|
164
|
+
Value ret = Qnil;
|
165
|
+
if (colors)
|
166
|
+
{
|
167
|
+
size_t size = THIS->size();
|
168
|
+
for (size_t i = 0; i < size; ++i)
|
169
|
+
ret = rb_yield(value(colors[i]));
|
170
|
+
}
|
171
|
+
return ret;
|
172
|
+
}
|
173
|
+
RUCY_END
|
174
|
+
|
175
|
+
static
|
176
|
+
RUCY_DEF0(each_texcoord)
|
177
|
+
{
|
178
|
+
CHECK;
|
179
|
+
|
180
|
+
const Rays::Coord3* texcoords = THIS->texcoords();
|
181
|
+
|
182
|
+
Value ret = Qnil;
|
183
|
+
if (texcoords)
|
184
|
+
{
|
185
|
+
size_t size = THIS->size();
|
186
|
+
for (size_t i = 0; i < size; ++i)
|
187
|
+
ret = rb_yield(value(*(Rays::Point*) &texcoords[i]));
|
188
|
+
}
|
189
|
+
return ret;
|
190
|
+
}
|
191
|
+
RUCY_END
|
192
|
+
|
114
193
|
|
115
194
|
static Class cPolyline;
|
116
195
|
|
@@ -124,11 +203,18 @@ Init_rays_polyline ()
|
|
124
203
|
cPolyline.define_private_method("setup", setup);
|
125
204
|
cPolyline.define_method("expand", expand);
|
126
205
|
cPolyline.define_method("bounds", bounds);
|
127
|
-
cPolyline.define_method("loop?",
|
206
|
+
cPolyline.define_method("loop?", is_loop);
|
207
|
+
cPolyline.define_method("fill?", is_fill);
|
208
|
+
cPolyline.define_method("hole?", is_hole);
|
128
209
|
cPolyline.define_method("size", size);
|
129
210
|
cPolyline.define_method("empty?", is_empty);
|
130
211
|
cPolyline.define_method("[]", get_at);
|
131
|
-
cPolyline.define_method("
|
212
|
+
cPolyline.define_method("points?", has_points);
|
213
|
+
cPolyline.define_method("colors?", has_colors);
|
214
|
+
cPolyline.define_method("texcoords?", has_texcoords);
|
215
|
+
cPolyline.define_private_method("each_point!", each_point);
|
216
|
+
cPolyline.define_private_method("each_color!", each_color);
|
217
|
+
cPolyline.define_private_method("each_texcoord!", each_texcoord);
|
132
218
|
}
|
133
219
|
|
134
220
|
|
@@ -148,7 +234,7 @@ namespace Rucy
|
|
148
234
|
else if (argv->is_num() || argv->is_array())
|
149
235
|
{
|
150
236
|
std::vector<Rays::Point> points;
|
151
|
-
|
237
|
+
get_points(&points, argc, argv);
|
152
238
|
return Rays::Polyline(&points[0], points.size());
|
153
239
|
}
|
154
240
|
}
|
data/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
|
RUCY_DEF0(init)
|
@@ -72,13 +84,19 @@ Init_rays ()
|
|
72
84
|
mRays.define_singleton_method("fin!", fin);
|
73
85
|
|
74
86
|
for (auto it = CAP_TYPES.begin(); it != CAP_TYPES.end(); ++it)
|
75
|
-
mRays.define_const(it->name, it->
|
87
|
+
mRays.define_const(it->name, it->value);
|
76
88
|
|
77
89
|
for (auto it = JOIN_TYPES.begin(); it != JOIN_TYPES.end(); ++it)
|
78
|
-
mRays.define_const(it->name, it->
|
90
|
+
mRays.define_const(it->name, it->value);
|
79
91
|
|
80
92
|
for (auto it = BLEND_MODES.begin(); it != BLEND_MODES.end(); ++it)
|
81
|
-
mRays.define_const(it->name, it->
|
93
|
+
mRays.define_const(it->name, it->value);
|
94
|
+
|
95
|
+
for (auto it = TEXCOORD_MODES.begin(); it != TEXCOORD_MODES.end(); ++it)
|
96
|
+
mRays.define_const(it->name, it->value);
|
97
|
+
|
98
|
+
for (auto it = TEXCOORD_WRAPS.begin(); it != TEXCOORD_WRAPS.end(); ++it)
|
99
|
+
mRays.define_const(it->name, it->value);
|
82
100
|
}
|
83
101
|
|
84
102
|
|
@@ -102,7 +120,7 @@ namespace Rucy
|
|
102
120
|
strcasecmp(str, it->name) == 0 ||
|
103
121
|
strcasecmp(str, it->short_name) == 0)
|
104
122
|
{
|
105
|
-
return it->
|
123
|
+
return it->value;
|
106
124
|
}
|
107
125
|
}
|
108
126
|
argument_error(__FILE__, __LINE__, "invalid cap type -- %s", str);
|
@@ -133,7 +151,7 @@ namespace Rucy
|
|
133
151
|
strcasecmp(str, it->name) == 0 ||
|
134
152
|
strcasecmp(str, it->short_name) == 0)
|
135
153
|
{
|
136
|
-
return it->
|
154
|
+
return it->value;
|
137
155
|
}
|
138
156
|
}
|
139
157
|
argument_error(__FILE__, __LINE__, "invalid join type -- %s", str);
|
@@ -164,18 +182,80 @@ namespace Rucy
|
|
164
182
|
strcasecmp(str, it->name) == 0 ||
|
165
183
|
strcasecmp(str, it->short_name) == 0)
|
166
184
|
{
|
167
|
-
return it->
|
185
|
+
return it->value;
|
168
186
|
}
|
169
187
|
}
|
170
188
|
argument_error(__FILE__, __LINE__, "invalid blend mode -- %s", str);
|
171
189
|
}
|
172
190
|
}
|
173
191
|
|
174
|
-
int
|
175
|
-
if (
|
176
|
-
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d",
|
192
|
+
int mode = value_to<int>(*argv, convert);
|
193
|
+
if (mode < 0 || Rays::BLEND_MAX <= mode)
|
194
|
+
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
195
|
+
|
196
|
+
return (Rays::BlendMode) mode;
|
197
|
+
}
|
198
|
+
|
199
|
+
|
200
|
+
template <> Rays::TexCoordMode
|
201
|
+
value_to<Rays::TexCoordMode> (int argc, const Value* argv, bool convert)
|
202
|
+
{
|
203
|
+
assert(argc > 0 && argv);
|
204
|
+
|
205
|
+
if (convert)
|
206
|
+
{
|
207
|
+
if (argv->is_s() || argv->is_sym())
|
208
|
+
{
|
209
|
+
const char* str = argv->c_str();
|
210
|
+
for (auto it = TEXCOORD_MODES.begin(); it != TEXCOORD_MODES.end(); ++it)
|
211
|
+
{
|
212
|
+
if (
|
213
|
+
strcasecmp(str, it->name) == 0 ||
|
214
|
+
strcasecmp(str, it->short_name) == 0)
|
215
|
+
{
|
216
|
+
return it->value;
|
217
|
+
}
|
218
|
+
}
|
219
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %s", str);
|
220
|
+
}
|
221
|
+
}
|
222
|
+
|
223
|
+
int mode = value_to<int>(*argv, convert);
|
224
|
+
if (mode < 0 || Rays::TEXCOORD_MODE_MAX <= mode)
|
225
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %d", mode);
|
226
|
+
|
227
|
+
return (Rays::TexCoordMode) mode;
|
228
|
+
}
|
229
|
+
|
230
|
+
|
231
|
+
template <> Rays::TexCoordWrap
|
232
|
+
value_to<Rays::TexCoordWrap> (int argc, const Value* argv, bool convert)
|
233
|
+
{
|
234
|
+
assert(argc > 0 && argv);
|
235
|
+
|
236
|
+
if (convert)
|
237
|
+
{
|
238
|
+
if (argv->is_s() || argv->is_sym())
|
239
|
+
{
|
240
|
+
const char* str = argv->c_str();
|
241
|
+
for (auto it = TEXCOORD_WRAPS.begin(); it != TEXCOORD_WRAPS.end(); ++it)
|
242
|
+
{
|
243
|
+
if (
|
244
|
+
strcasecmp(str, it->name) == 0 ||
|
245
|
+
strcasecmp(str, it->short_name) == 0)
|
246
|
+
{
|
247
|
+
return it->value;
|
248
|
+
}
|
249
|
+
}
|
250
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %s", str);
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
254
|
+
int wrap = value_to<int>(*argv, convert);
|
255
|
+
if (wrap < 0 || Rays::TEXCOORD_WRAP_MAX <= wrap)
|
256
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %d", wrap);
|
177
257
|
|
178
|
-
return (Rays::
|
258
|
+
return (Rays::TexCoordWrap) wrap;
|
179
259
|
}
|
180
260
|
|
181
261
|
|
@@ -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
|
|
@@ -47,7 +47,7 @@ RUCY_END
|
|
47
47
|
|
48
48
|
|
49
49
|
void
|
50
|
-
|
50
|
+
Init_rays_util ()
|
51
51
|
{
|
52
52
|
Module mRays = define_module("Rays");
|
53
53
|
mRays.define_singleton_method("perlin", perlin);
|
data/include/rays/defs.h
CHANGED
@@ -82,6 +82,30 @@ namespace Rays
|
|
82
82
|
};// BlendMode
|
83
83
|
|
84
84
|
|
85
|
+
enum TexCoordMode
|
86
|
+
{
|
87
|
+
|
88
|
+
TEXCOORD_IMAGE = 0,
|
89
|
+
|
90
|
+
TEXCOORD_NORMAL,
|
91
|
+
|
92
|
+
TEXCOORD_MODE_MAX
|
93
|
+
|
94
|
+
};// TexCoordMode
|
95
|
+
|
96
|
+
|
97
|
+
enum TexCoordWrap
|
98
|
+
{
|
99
|
+
|
100
|
+
TEXCOORD_CLAMP = 0,
|
101
|
+
|
102
|
+
TEXCOORD_REPEAT,
|
103
|
+
|
104
|
+
TEXCOORD_WRAP_MAX
|
105
|
+
|
106
|
+
};// TexCoordWrap
|
107
|
+
|
108
|
+
|
85
109
|
}// Rays
|
86
110
|
|
87
111
|
|
data/include/rays/font.h
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
#define __RAYS_FONT_H__
|
5
5
|
|
6
6
|
|
7
|
+
#include <vector>
|
8
|
+
#include <map>
|
7
9
|
#include <xot/pimpl.h>
|
8
10
|
#include <rays/defs.h>
|
9
11
|
|
@@ -17,15 +19,21 @@ namespace Rays
|
|
17
19
|
|
18
20
|
public:
|
19
21
|
|
22
|
+
enum {DEFAULT_SIZE = 12};
|
23
|
+
|
20
24
|
Font ();
|
21
25
|
|
22
|
-
Font (const char* name, coord size =
|
26
|
+
Font (const char* name, coord size = DEFAULT_SIZE);
|
23
27
|
|
24
28
|
~Font ();
|
25
29
|
|
30
|
+
Font dup () const;
|
31
|
+
|
26
32
|
String name () const;
|
27
33
|
|
28
|
-
coord size
|
34
|
+
void set_size (coord size);
|
35
|
+
|
36
|
+
coord size () const;
|
29
37
|
|
30
38
|
coord get_width (const char* str) const;
|
31
39
|
|
@@ -45,7 +53,13 @@ namespace Rays
|
|
45
53
|
};// Font
|
46
54
|
|
47
55
|
|
48
|
-
|
56
|
+
typedef std::map<String, std::vector<String>> FontFamilyMap;
|
57
|
+
|
58
|
+
const FontFamilyMap& get_font_families ();
|
59
|
+
|
60
|
+
Font load_font (const char* path, coord size = Font::DEFAULT_SIZE);
|
61
|
+
|
62
|
+
const Font& get_default_font ();
|
49
63
|
|
50
64
|
|
51
65
|
}// Rays
|
data/include/rays/matrix.h
CHANGED
data/include/rays/painter.h
CHANGED
@@ -65,7 +65,17 @@ namespace Rays
|
|
65
65
|
|
66
66
|
void clear ();
|
67
67
|
|
68
|
-
void polygon (
|
68
|
+
void polygon (
|
69
|
+
const Polygon& polygon, coord x = 0, coord y = 0);
|
70
|
+
|
71
|
+
void polygon (
|
72
|
+
const Polygon& polygon, const Point& position);
|
73
|
+
|
74
|
+
void polygon (
|
75
|
+
const Polygon& polygon, coord x, coord y, coord width, coord height);
|
76
|
+
|
77
|
+
void polygon (
|
78
|
+
const Polygon& polygon, const Bounds& bounds);
|
69
79
|
|
70
80
|
void line (coord x1, coord y1, coord x2, coord y2);
|
71
81
|
|
@@ -205,6 +215,10 @@ namespace Rays
|
|
205
215
|
|
206
216
|
coord stroke_width () const;
|
207
217
|
|
218
|
+
void set_stroke_outset (float outset);
|
219
|
+
|
220
|
+
float stroke_outset () const;
|
221
|
+
|
208
222
|
void set_stroke_cap (CapType cap);
|
209
223
|
|
210
224
|
CapType stroke_cap () const;
|
@@ -239,6 +253,20 @@ namespace Rays
|
|
239
253
|
|
240
254
|
const Font& font () const;
|
241
255
|
|
256
|
+
void set_texture (const Image& image);
|
257
|
+
|
258
|
+
void no_texture ();
|
259
|
+
|
260
|
+
const Image& texture () const;
|
261
|
+
|
262
|
+
void set_texcoord_mode (TexCoordMode mode);
|
263
|
+
|
264
|
+
TexCoordMode texcoord_mode () const;
|
265
|
+
|
266
|
+
void set_texcoord_wrap (TexCoordWrap wrap);
|
267
|
+
|
268
|
+
TexCoordWrap texcoord_wrap () const;
|
269
|
+
|
242
270
|
void set_shader (const Shader& shader);
|
243
271
|
|
244
272
|
void no_shader ();
|
data/include/rays/polygon.h
CHANGED
@@ -20,45 +20,19 @@ namespace Rays
|
|
20
20
|
|
21
21
|
public:
|
22
22
|
|
23
|
-
|
24
|
-
{
|
23
|
+
typedef std::vector<Polyline> PolylineList;
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
public:
|
29
|
-
|
30
|
-
Line ();
|
31
|
-
|
32
|
-
Line (
|
33
|
-
const Point* points, size_t size,
|
34
|
-
bool loop = true,
|
35
|
-
bool hole = false);
|
36
|
-
|
37
|
-
Line (const Polyline& polyline, bool hole = false);
|
38
|
-
|
39
|
-
bool hole () const;
|
40
|
-
|
41
|
-
operator bool () const;
|
42
|
-
|
43
|
-
bool operator ! () const;
|
44
|
-
|
45
|
-
private:
|
46
|
-
|
47
|
-
bool hole_;
|
48
|
-
|
49
|
-
};// Line
|
50
|
-
|
51
|
-
typedef std::vector<Line> LineList;
|
52
|
-
|
53
|
-
typedef LineList::const_iterator const_iterator;
|
25
|
+
typedef PolylineList::const_iterator const_iterator;
|
54
26
|
|
55
27
|
Polygon ();
|
56
28
|
|
57
|
-
Polygon (
|
29
|
+
Polygon (
|
30
|
+
const Point* points, size_t size, bool loop = true,
|
31
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
58
32
|
|
59
33
|
Polygon (const Polyline& polyline);
|
60
34
|
|
61
|
-
Polygon (const
|
35
|
+
Polygon (const Polyline* polylines, size_t size);
|
62
36
|
|
63
37
|
~Polygon ();
|
64
38
|
|
@@ -79,12 +53,14 @@ namespace Rays
|
|
79
53
|
|
80
54
|
const_iterator end () const;
|
81
55
|
|
82
|
-
const
|
56
|
+
const Polyline& operator [] (size_t index) const;
|
83
57
|
|
84
58
|
operator bool () const;
|
85
59
|
|
86
60
|
bool operator ! () const;
|
87
61
|
|
62
|
+
friend Polygon operator + (const Polygon& lhs, const Polyline& rhs);
|
63
|
+
|
88
64
|
friend Polygon operator + (const Polygon& lhs, const Polygon& rhs);
|
89
65
|
|
90
66
|
friend Polygon operator - (const Polygon& lhs, const Polygon& rhs);
|
@@ -110,6 +86,13 @@ namespace Rays
|
|
110
86
|
};// Polygon
|
111
87
|
|
112
88
|
|
89
|
+
Polygon create_point (coord x, coord y);
|
90
|
+
|
91
|
+
Polygon create_point (const Point& point);
|
92
|
+
|
93
|
+
Polygon create_points (const Point* points, size_t size);
|
94
|
+
|
95
|
+
|
113
96
|
Polygon create_line (coord x1, coord y1, coord x2, coord y2);
|
114
97
|
|
115
98
|
Polygon create_line (const Point& p1, const Point& p2);
|
@@ -118,6 +101,29 @@ namespace Rays
|
|
118
101
|
|
119
102
|
Polygon create_line (const Polyline& polyline);
|
120
103
|
|
104
|
+
Polygon create_lines (const Point* points, size_t size);
|
105
|
+
|
106
|
+
|
107
|
+
Polygon create_triangle (
|
108
|
+
coord x1, coord y1, coord x2, coord y2, coord x3, coord y3,
|
109
|
+
bool loop = true);
|
110
|
+
|
111
|
+
Polygon create_triangle (
|
112
|
+
const Point& p1, const Point& p2, const Point& p3,
|
113
|
+
bool loop = true);
|
114
|
+
|
115
|
+
Polygon create_triangles (
|
116
|
+
const Point* points, size_t size, bool loop = true,
|
117
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
118
|
+
|
119
|
+
Polygon create_triangle_strip (
|
120
|
+
const Point* points, size_t size,
|
121
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
122
|
+
|
123
|
+
Polygon create_triangle_fan (
|
124
|
+
const Point* points, size_t size,
|
125
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
126
|
+
|
121
127
|
|
122
128
|
Polygon create_rect (
|
123
129
|
coord x, coord y, coord width, coord height,
|
@@ -142,6 +148,24 @@ namespace Rays
|
|
142
148
|
uint nsegment = 0);
|
143
149
|
|
144
150
|
|
151
|
+
Polygon create_quad (
|
152
|
+
coord x1, coord y1, coord x2, coord y2,
|
153
|
+
coord x3, coord y3, coord x4, coord y4,
|
154
|
+
bool loop = true);
|
155
|
+
|
156
|
+
Polygon create_quad (
|
157
|
+
const Point& p1, const Point& p2, const Point& p3, const Point& p4,
|
158
|
+
bool loop = true);
|
159
|
+
|
160
|
+
Polygon create_quads (
|
161
|
+
const Point* points, size_t size, bool loop = true,
|
162
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
163
|
+
|
164
|
+
Polygon create_quad_strip (
|
165
|
+
const Point* points, size_t size,
|
166
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
167
|
+
|
168
|
+
|
145
169
|
Polygon create_ellipse (
|
146
170
|
coord x, coord y, coord width, coord height = 0,
|
147
171
|
const Point& hole_size = 0,
|
data/include/rays/polyline.h
CHANGED
@@ -15,6 +15,7 @@ namespace Rays
|
|
15
15
|
{
|
16
16
|
|
17
17
|
|
18
|
+
struct Color;
|
18
19
|
class Polygon;
|
19
20
|
|
20
21
|
|
@@ -29,7 +30,15 @@ namespace Rays
|
|
29
30
|
|
30
31
|
Polyline ();
|
31
32
|
|
32
|
-
Polyline (
|
33
|
+
Polyline (
|
34
|
+
const Point* points, size_t size, bool loop = false,
|
35
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL,
|
36
|
+
bool hole = false);
|
37
|
+
|
38
|
+
Polyline (
|
39
|
+
const Point* points, size_t size, bool loop, bool fill,
|
40
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL,
|
41
|
+
bool hole = false);
|
33
42
|
|
34
43
|
~Polyline ();
|
35
44
|
|
@@ -44,6 +53,16 @@ namespace Rays
|
|
44
53
|
|
45
54
|
bool loop () const;
|
46
55
|
|
56
|
+
bool fill () const;
|
57
|
+
|
58
|
+
bool hole () const;
|
59
|
+
|
60
|
+
const Point* points () const;
|
61
|
+
|
62
|
+
const Color* colors () const;
|
63
|
+
|
64
|
+
const Coord3* texcoords () const;
|
65
|
+
|
47
66
|
size_t size () const;
|
48
67
|
|
49
68
|
bool empty () const;
|
data/include/rays/ruby/polygon.h
CHANGED
@@ -11,8 +11,6 @@
|
|
11
11
|
|
12
12
|
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon)
|
13
13
|
|
14
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon::Line)
|
15
|
-
|
16
14
|
|
17
15
|
namespace Rays
|
18
16
|
{
|
@@ -21,9 +19,6 @@ namespace Rays
|
|
21
19
|
Rucy::Class polygon_class ();
|
22
20
|
// class Rays::Polygon
|
23
21
|
|
24
|
-
Rucy::Class polygon_line_class ();
|
25
|
-
// class Rays::Polygon::Line
|
26
|
-
|
27
22
|
|
28
23
|
}// Rays
|
29
24
|
|
@@ -38,12 +33,6 @@ namespace Rucy
|
|
38
33
|
return Rays::polygon_class();
|
39
34
|
}
|
40
35
|
|
41
|
-
template <> inline Class
|
42
|
-
get_ruby_class<Rays::Polygon::Line> ()
|
43
|
-
{
|
44
|
-
return Rays::polygon_line_class();
|
45
|
-
}
|
46
|
-
|
47
36
|
|
48
37
|
}// Rucy
|
49
38
|
|
data/include/rays/ruby/rays.h
CHANGED