rays 0.1.46 → 0.1.47
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 +258 -0
- data/.doc/ext/rays/defs.cpp +3 -3
- data/.doc/ext/rays/painter.cpp +38 -3
- data/.doc/ext/rays/polygon.cpp +81 -4
- data/.doc/ext/rays/rays.cpp +11 -11
- data/.github/workflows/test.yml +0 -1
- data/ChangeLog.md +15 -0
- data/Rakefile +4 -4
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +259 -0
- data/ext/rays/defs.cpp +3 -3
- data/ext/rays/painter.cpp +45 -8
- data/ext/rays/polygon.cpp +89 -4
- data/ext/rays/rays.cpp +11 -11
- data/include/rays/defs.h +26 -0
- data/include/rays/matrix.h +2 -0
- data/include/rays/painter.h +15 -1
- data/include/rays/polygon.h +6 -1
- data/include/rays/polyline.h +4 -0
- data/lib/rays/painter.rb +1 -1
- data/lib/rays/polygon.rb +36 -7
- data/rays.gemspec +2 -2
- data/src/color_space.cpp +2 -2
- data/src/matrix.cpp +8 -0
- data/src/painter.cpp +72 -5
- data/src/polygon.cpp +385 -91
- data/src/polyline.cpp +33 -18
- data/src/polyline.h +2 -2
- data/test/test_bitmap.rb +7 -0
- data/test/test_polygon.rb +2 -2
- data/test/test_polygon_line.rb +5 -5
- data/test/test_polyline.rb +7 -7
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d27dc838757afd56a521719cf178e3fc21accf98d1e5041c3afa8df730e998c3
|
4
|
+
data.tar.gz: 2745744e4dc2b11d5771c1deb94fa949c7d2d27a5903c2b0acca2887678330f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 400f74e76fd7c1db1edfee49d6a68fb7d721fec8dc8e247bc99bdee65b27688b7c6e96962f8a9c95aaa2a87ed045ab2fd0419478cb1aaf118098bf5fefbf7298
|
7
|
+
data.tar.gz: 367ed1df9b709b7c5ac7091ea1d38bbe14da8ab72d2dd049bb1c4a9acf994a45971bcef3b599525f25bdccb420ee032d8036ca58656bbc1401a2becc383a7e7a
|
data/.doc/ext/rays/bitmap.cpp
CHANGED
@@ -66,6 +66,263 @@ VALUE color_space(VALUE self)
|
|
66
66
|
return value(THIS->color_space());
|
67
67
|
}
|
68
68
|
|
69
|
+
static inline Value
|
70
|
+
to_rgb_value (uint8_t r, uint8_t g, uint8_t b)
|
71
|
+
{
|
72
|
+
return value(
|
73
|
+
((uint) r) << 16 |
|
74
|
+
((uint) g) << 8 |
|
75
|
+
((uint) b));
|
76
|
+
}
|
77
|
+
|
78
|
+
static inline Value
|
79
|
+
to_rgba_value (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
80
|
+
{
|
81
|
+
return value(
|
82
|
+
((uint) a) << 24 |
|
83
|
+
((uint) r) << 16 |
|
84
|
+
((uint) g) << 8 |
|
85
|
+
((uint) b));
|
86
|
+
}
|
87
|
+
|
88
|
+
static void
|
89
|
+
get_pixels (auto* pixels, const Rays::Bitmap& bmp)
|
90
|
+
{
|
91
|
+
int w = bmp.width(), h = bmp.height();
|
92
|
+
|
93
|
+
const auto& cs = bmp.color_space();
|
94
|
+
pixels->clear();
|
95
|
+
pixels->reserve(w * h * (cs.is_float() ? cs.Bpp() / cs.Bpc() : 1));
|
96
|
+
|
97
|
+
switch (cs.type())
|
98
|
+
{
|
99
|
+
case Rays::GRAY_8:
|
100
|
+
case Rays::ALPHA_8:
|
101
|
+
for (int y = 0; y < h; ++y)
|
102
|
+
{
|
103
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
104
|
+
for (int x = 0; x < w; ++x, ++p)
|
105
|
+
pixels->push_back(value(*p));
|
106
|
+
}
|
107
|
+
break;
|
108
|
+
|
109
|
+
case Rays::GRAY_16:
|
110
|
+
case Rays::ALPHA_16:
|
111
|
+
for (int y = 0; y < h; ++y)
|
112
|
+
{
|
113
|
+
const auto* p = bmp.at<uint16_t>(0, y);
|
114
|
+
for (int x = 0; x < w; ++x, ++p)
|
115
|
+
pixels->push_back(value(*p));
|
116
|
+
}
|
117
|
+
break;
|
118
|
+
|
119
|
+
case Rays::GRAY_32:
|
120
|
+
case Rays::ALPHA_32:
|
121
|
+
for (int y = 0; y < h; ++y)
|
122
|
+
{
|
123
|
+
const auto* p = bmp.at<uint32_t>(0, y);
|
124
|
+
for (int x = 0; x < w; ++x, ++p)
|
125
|
+
pixels->push_back(value(*p));
|
126
|
+
}
|
127
|
+
break;
|
128
|
+
|
129
|
+
case Rays::GRAY_float:
|
130
|
+
case Rays::ALPHA_float:
|
131
|
+
for (int y = 0; y < h; ++y)
|
132
|
+
{
|
133
|
+
const auto* p = bmp.at<float>(0, y);
|
134
|
+
for (int x = 0; x < w; ++x, ++p)
|
135
|
+
pixels->push_back(value(*p));
|
136
|
+
}
|
137
|
+
break;
|
138
|
+
|
139
|
+
case Rays::RGB_888:
|
140
|
+
for (int y = 0; y < h; ++y)
|
141
|
+
{
|
142
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
143
|
+
for (int x = 0; x < w; ++x, p += 3)
|
144
|
+
pixels->push_back(to_rgb_value(p[0], p[1], p[2]));
|
145
|
+
}
|
146
|
+
break;
|
147
|
+
|
148
|
+
case Rays::RGBA_8888:
|
149
|
+
for (int y = 0; y < h; ++y)
|
150
|
+
{
|
151
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
152
|
+
for (int x = 0; x < w; ++x, p += 4)
|
153
|
+
pixels->push_back(to_rgba_value(p[0], p[1], p[2], p[3]));
|
154
|
+
}
|
155
|
+
break;
|
156
|
+
|
157
|
+
case Rays::RGBX_8888:
|
158
|
+
for (int y = 0; y < h; ++y)
|
159
|
+
{
|
160
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
161
|
+
for (int x = 0; x < w; ++x, p += 4)
|
162
|
+
pixels->push_back(to_rgb_value(p[0], p[1], p[2]));
|
163
|
+
}
|
164
|
+
break;
|
165
|
+
|
166
|
+
case Rays::ARGB_8888:
|
167
|
+
for (int y = 0; y < h; ++y)
|
168
|
+
{
|
169
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
170
|
+
for (int x = 0; x < w; ++x, p += 4)
|
171
|
+
pixels->push_back(to_rgba_value(p[1], p[2], p[3], p[0]));
|
172
|
+
}
|
173
|
+
break;
|
174
|
+
|
175
|
+
case Rays::XRGB_8888:
|
176
|
+
for (int y = 0; y < h; ++y)
|
177
|
+
{
|
178
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
179
|
+
for (int x = 0; x < w; ++x, p += 4)
|
180
|
+
pixels->push_back(to_rgb_value(p[1], p[2], p[3]));
|
181
|
+
}
|
182
|
+
break;
|
183
|
+
|
184
|
+
case Rays::BGR_888:
|
185
|
+
for (int y = 0; y < h; ++y)
|
186
|
+
{
|
187
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
188
|
+
for (int x = 0; x < w; ++x, p += 3)
|
189
|
+
pixels->push_back(to_rgb_value(p[2], p[1], p[0]));
|
190
|
+
}
|
191
|
+
break;
|
192
|
+
|
193
|
+
case Rays::BGRA_8888:
|
194
|
+
for (int y = 0; y < h; ++y)
|
195
|
+
{
|
196
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
197
|
+
for (int x = 0; x < w; ++x, p += 4)
|
198
|
+
pixels->push_back(to_rgba_value(p[2], p[1], p[0], p[3]));
|
199
|
+
}
|
200
|
+
break;
|
201
|
+
|
202
|
+
case Rays::BGRX_8888:
|
203
|
+
for (int y = 0; y < h; ++y)
|
204
|
+
{
|
205
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
206
|
+
for (int x = 0; x < w; ++x, p += 4)
|
207
|
+
pixels->push_back(to_rgb_value(p[2], p[1], p[0]));
|
208
|
+
}
|
209
|
+
break;
|
210
|
+
|
211
|
+
case Rays::ABGR_8888:
|
212
|
+
for (int y = 0; y < h; ++y)
|
213
|
+
{
|
214
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
215
|
+
for (int x = 0; x < w; ++x, p += 4)
|
216
|
+
pixels->push_back(to_rgba_value(p[3], p[2], p[1], p[0]));
|
217
|
+
}
|
218
|
+
break;
|
219
|
+
|
220
|
+
case Rays::XBGR_8888:
|
221
|
+
for (int y = 0; y < h; ++y)
|
222
|
+
{
|
223
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
224
|
+
for (int x = 0; x < w; ++x, p += 4)
|
225
|
+
pixels->push_back(to_rgb_value(p[3], p[2], p[1]));
|
226
|
+
}
|
227
|
+
break;
|
228
|
+
|
229
|
+
case Rays::RGB_float:
|
230
|
+
for (int y = 0; y < h; ++y)
|
231
|
+
{
|
232
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
233
|
+
for (int x = 0; x < w; ++x, p += 3)
|
234
|
+
{
|
235
|
+
pixels->push_back(value(p[0]));
|
236
|
+
pixels->push_back(value(p[1]));
|
237
|
+
pixels->push_back(value(p[2]));
|
238
|
+
}
|
239
|
+
}
|
240
|
+
break;
|
241
|
+
|
242
|
+
case Rays::RGBA_float:
|
243
|
+
for (int y = 0; y < h; ++y)
|
244
|
+
{
|
245
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
246
|
+
for (int x = 0; x < w; ++x, p += 4)
|
247
|
+
{
|
248
|
+
pixels->push_back(value(p[0]));
|
249
|
+
pixels->push_back(value(p[1]));
|
250
|
+
pixels->push_back(value(p[2]));
|
251
|
+
pixels->push_back(value(p[3]));
|
252
|
+
}
|
253
|
+
}
|
254
|
+
break;
|
255
|
+
|
256
|
+
case Rays::ARGB_float:
|
257
|
+
for (int y = 0; y < h; ++y)
|
258
|
+
{
|
259
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
260
|
+
for (int x = 0; x < w; ++x, p += 4)
|
261
|
+
{
|
262
|
+
pixels->push_back(value(p[1]));
|
263
|
+
pixels->push_back(value(p[2]));
|
264
|
+
pixels->push_back(value(p[3]));
|
265
|
+
pixels->push_back(value(p[0]));
|
266
|
+
}
|
267
|
+
}
|
268
|
+
break;
|
269
|
+
|
270
|
+
case Rays::BGR_float:
|
271
|
+
for (int y = 0; y < h; ++y)
|
272
|
+
{
|
273
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
274
|
+
for (int x = 0; x < w; ++x, p += 3)
|
275
|
+
{
|
276
|
+
pixels->push_back(value(p[2]));
|
277
|
+
pixels->push_back(value(p[1]));
|
278
|
+
pixels->push_back(value(p[0]));
|
279
|
+
}
|
280
|
+
}
|
281
|
+
break;
|
282
|
+
|
283
|
+
case Rays::BGRA_float:
|
284
|
+
for (int y = 0; y < h; ++y)
|
285
|
+
{
|
286
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
287
|
+
for (int x = 0; x < w; ++x, p += 4)
|
288
|
+
{
|
289
|
+
pixels->push_back(value(p[2]));
|
290
|
+
pixels->push_back(value(p[1]));
|
291
|
+
pixels->push_back(value(p[0]));
|
292
|
+
pixels->push_back(value(p[3]));
|
293
|
+
}
|
294
|
+
}
|
295
|
+
break;
|
296
|
+
|
297
|
+
case Rays::ABGR_float:
|
298
|
+
for (int y = 0; y < h; ++y)
|
299
|
+
{
|
300
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
301
|
+
for (int x = 0; x < w; ++x, p += 4)
|
302
|
+
{
|
303
|
+
pixels->push_back(value(p[3]));
|
304
|
+
pixels->push_back(value(p[2]));
|
305
|
+
pixels->push_back(value(p[1]));
|
306
|
+
pixels->push_back(value(p[0]));
|
307
|
+
}
|
308
|
+
}
|
309
|
+
break;
|
310
|
+
|
311
|
+
default:
|
312
|
+
argument_error(__FILE__, __LINE__);
|
313
|
+
}
|
314
|
+
}
|
315
|
+
|
316
|
+
static
|
317
|
+
VALUE pixels(VALUE self)
|
318
|
+
{
|
319
|
+
CHECK;
|
320
|
+
|
321
|
+
std::vector<VALUE> pixels;
|
322
|
+
get_pixels(&pixels, *THIS);
|
323
|
+
return value(pixels.size(), (const Value*) &pixels[0]);
|
324
|
+
}
|
325
|
+
|
69
326
|
static
|
70
327
|
VALUE set_at(VALUE self, VALUE x, VALUE y, VALUE color)
|
71
328
|
{
|
@@ -105,6 +362,7 @@ Init_rays_bitmap ()
|
|
105
362
|
rb_define_method(cBitmap, "width", RUBY_METHOD_FUNC(width), 0);
|
106
363
|
rb_define_method(cBitmap, "height", RUBY_METHOD_FUNC(height), 0);
|
107
364
|
rb_define_method(cBitmap, "color_space", RUBY_METHOD_FUNC(color_space), 0);
|
365
|
+
rb_define_method(cBitmap, "pixels", RUBY_METHOD_FUNC(pixels), 0);
|
108
366
|
cBitmap.define_method("[]=", set_at);
|
109
367
|
cBitmap.define_method("[]", get_at);
|
110
368
|
}
|
data/.doc/ext/rays/defs.cpp
CHANGED
@@ -24,9 +24,9 @@ get_line_args (std::vector<Rays::Point>* points, int argc, const Value* argv)
|
|
24
24
|
points->reserve(argc / 2);
|
25
25
|
for (int i = 0; i < argc; i += 2)
|
26
26
|
{
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
points->emplace_back(
|
28
|
+
to<coord>(argv[i + 0]),
|
29
|
+
to<coord>(argv[i + 1]));
|
30
30
|
}
|
31
31
|
}
|
32
32
|
else
|
data/.doc/ext/rays/painter.cpp
CHANGED
@@ -121,11 +121,29 @@ VALUE clear(VALUE self)
|
|
121
121
|
}
|
122
122
|
|
123
123
|
static
|
124
|
-
VALUE polygon(VALUE self
|
124
|
+
VALUE polygon(VALUE self)
|
125
125
|
{
|
126
126
|
CHECK;
|
127
|
+
check_arg_count(__FILE__, __LINE__, "Painter#polygon", argc, 1, 3, 5);
|
128
|
+
|
129
|
+
const Rays::Polygon* polygon = to<Rays::Polygon*>(argv[0]);
|
130
|
+
if (!polygon)
|
131
|
+
argument_error(__FILE__, __LINE__, "%s is not a polygon.", argv[0].inspect().c_str());
|
132
|
+
|
133
|
+
if (argc == 1)
|
134
|
+
THIS->polygon(*polygon);
|
135
|
+
else if (argc == 3)
|
136
|
+
{
|
137
|
+
coord x = to<coord>(argv[1]), y = to<coord>(argv[2]);
|
138
|
+
THIS->polygon(*polygon, x, y);
|
139
|
+
}
|
140
|
+
else if (argc == 5)
|
141
|
+
{
|
142
|
+
coord x = to<coord>(argv[1]), w = to<coord>(argv[3]);
|
143
|
+
coord y = to<coord>(argv[2]), h = to<coord>(argv[4]);
|
144
|
+
THIS->polygon(*polygon, x, y, w, h);
|
145
|
+
}
|
127
146
|
|
128
|
-
THIS->polygon(to<Rays::Polygon&>(poly));
|
129
147
|
return self;
|
130
148
|
}
|
131
149
|
|
@@ -365,6 +383,21 @@ VALUE get_stroke_width(VALUE self)
|
|
365
383
|
return value(THIS->stroke_width());
|
366
384
|
}
|
367
385
|
|
386
|
+
static
|
387
|
+
VALUE set_stroke_outset(VALUE self, VALUE outset)
|
388
|
+
{
|
389
|
+
CHECK;
|
390
|
+
THIS->set_stroke_outset(to<float>(outset));
|
391
|
+
return self;
|
392
|
+
}
|
393
|
+
|
394
|
+
static
|
395
|
+
VALUE get_stroke_outset(VALUE self)
|
396
|
+
{
|
397
|
+
CHECK;
|
398
|
+
return value(THIS->stroke_outset());
|
399
|
+
}
|
400
|
+
|
368
401
|
static
|
369
402
|
VALUE set_stroke_cap(VALUE self, VALUE cap)
|
370
403
|
{
|
@@ -624,7 +657,7 @@ Init_rays_painter ()
|
|
624
657
|
rb_define_private_method(cPainter, "end_paint", RUBY_METHOD_FUNC(end_paint), 0);
|
625
658
|
cPainter.define_method( "painting?", is_painting);
|
626
659
|
rb_define_method(cPainter, "clear", RUBY_METHOD_FUNC(clear), 0);
|
627
|
-
rb_define_method(cPainter, "polygon", RUBY_METHOD_FUNC(polygon), 1);
|
660
|
+
rb_define_method(cPainter, "polygon", RUBY_METHOD_FUNC(polygon), -1);
|
628
661
|
rb_define_private_method(cPainter, "draw_line", RUBY_METHOD_FUNC(line), 2);
|
629
662
|
rb_define_private_method(cPainter, "draw_polyline", RUBY_METHOD_FUNC(polyline), 1);
|
630
663
|
rb_define_private_method(cPainter, "draw_rect", RUBY_METHOD_FUNC(rect), 6);
|
@@ -645,6 +678,8 @@ Init_rays_painter ()
|
|
645
678
|
rb_define_method(cPainter, "no_stroke", RUBY_METHOD_FUNC(no_stroke), 0);
|
646
679
|
rb_define_method(cPainter, "stroke_width=", RUBY_METHOD_FUNC(set_stroke_width), 1);
|
647
680
|
rb_define_method(cPainter, "stroke_width", RUBY_METHOD_FUNC(get_stroke_width), 0);
|
681
|
+
rb_define_method(cPainter, "stroke_outset=", RUBY_METHOD_FUNC(set_stroke_outset), 1);
|
682
|
+
rb_define_method(cPainter, "stroke_outset", RUBY_METHOD_FUNC(get_stroke_outset), 0);
|
648
683
|
rb_define_method(cPainter, "stroke_cap=", RUBY_METHOD_FUNC(set_stroke_cap), 1);
|
649
684
|
rb_define_method(cPainter, "stroke_cap", RUBY_METHOD_FUNC(get_stroke_cap), 0);
|
650
685
|
rb_define_method(cPainter, "stroke_join=", RUBY_METHOD_FUNC(set_stroke_join), 1);
|
data/.doc/ext/rays/polygon.cpp
CHANGED
@@ -182,6 +182,31 @@ VALUE op_xor(VALUE self, VALUE obj)
|
|
182
182
|
return value(*THIS ^ to<Rays::Polygon&>(obj));
|
183
183
|
}
|
184
184
|
|
185
|
+
static
|
186
|
+
VALUE create_points(VALUE self, VALUE args)
|
187
|
+
{
|
188
|
+
std::vector<Rays::Point> points;
|
189
|
+
get_line_args(&points, args.size(), args.as_array());
|
190
|
+
return value(Rays::Polygon(Rays::DRAW_POINTS, &points[0], points.size()));
|
191
|
+
}
|
192
|
+
|
193
|
+
static
|
194
|
+
VALUE create_lines(VALUE self, VALUE args)
|
195
|
+
{
|
196
|
+
std::vector<Rays::Point> points;
|
197
|
+
get_line_args(&points, args.size(), args.as_array());
|
198
|
+
return value(Rays::Polygon(Rays::DRAW_LINES, &points[0], points.size()));
|
199
|
+
}
|
200
|
+
|
201
|
+
static
|
202
|
+
VALUE create_line_strip(VALUE self, VALUE args, VALUE loop)
|
203
|
+
{
|
204
|
+
std::vector<Rays::Point> points;
|
205
|
+
get_line_args(&points, args.size(), args.as_array());
|
206
|
+
return value(
|
207
|
+
Rays::Polygon(Rays::DRAW_LINE_STRIP, &points[0], points.size(), loop));
|
208
|
+
}
|
209
|
+
|
185
210
|
static
|
186
211
|
VALUE create_rect(VALUE self, VALUE
|
187
212
|
args, VALUE round, VALUE lefttop, VALUE righttop, VALUE leftbottom, VALUE rightbottom, VALUE nsegment)
|
@@ -212,6 +237,50 @@ VALUE create_ellipse(VALUE self, VALUE
|
|
212
237
|
return value(Rays::create_ellipse(x, y, w, h, hole_size, from, to_, nseg));
|
213
238
|
}
|
214
239
|
|
240
|
+
static
|
241
|
+
VALUE create_triangles(VALUE self, VALUE args, VALUE loop)
|
242
|
+
{
|
243
|
+
std::vector<Rays::Point> points;
|
244
|
+
get_line_args(&points, args.size(), args.as_array());
|
245
|
+
return value(
|
246
|
+
Rays::Polygon(Rays::DRAW_TRIANGLES, &points[0], points.size(), loop));
|
247
|
+
}
|
248
|
+
|
249
|
+
static
|
250
|
+
VALUE create_triangle_strip(VALUE self, VALUE args)
|
251
|
+
{
|
252
|
+
std::vector<Rays::Point> points;
|
253
|
+
get_line_args(&points, args.size(), args.as_array());
|
254
|
+
return value(
|
255
|
+
Rays::Polygon(Rays::DRAW_TRIANGLE_STRIP, &points[0], points.size()));
|
256
|
+
}
|
257
|
+
|
258
|
+
static
|
259
|
+
VALUE create_triangle_fan(VALUE self, VALUE args)
|
260
|
+
{
|
261
|
+
std::vector<Rays::Point> points;
|
262
|
+
get_line_args(&points, args.size(), args.as_array());
|
263
|
+
return value(
|
264
|
+
Rays::Polygon(Rays::DRAW_TRIANGLE_FAN, &points[0], points.size()));
|
265
|
+
}
|
266
|
+
|
267
|
+
static
|
268
|
+
VALUE create_quads(VALUE self, VALUE args, VALUE loop)
|
269
|
+
{
|
270
|
+
std::vector<Rays::Point> points;
|
271
|
+
get_line_args(&points, args.size(), args.as_array());
|
272
|
+
return value(
|
273
|
+
Rays::Polygon(Rays::DRAW_QUADS, &points[0], points.size(), loop));
|
274
|
+
}
|
275
|
+
|
276
|
+
static
|
277
|
+
VALUE create_quad_strip(VALUE self, VALUE args)
|
278
|
+
{
|
279
|
+
std::vector<Rays::Point> points;
|
280
|
+
get_line_args(&points, args.size(), args.as_array());
|
281
|
+
return value(Rays::Polygon(Rays::DRAW_QUAD_STRIP, &points[0], points.size()));
|
282
|
+
}
|
283
|
+
|
215
284
|
static
|
216
285
|
VALUE create_curve(VALUE self, VALUE args, VALUE loop)
|
217
286
|
{
|
@@ -252,10 +321,18 @@ Init_rays_polygon ()
|
|
252
321
|
cPolygon.define_method("&", op_and);
|
253
322
|
cPolygon.define_method("|", op_or);
|
254
323
|
cPolygon.define_method("^", op_xor);
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
324
|
+
cPolygon.define_singleton_method("points!", create_points);
|
325
|
+
cPolygon.define_singleton_method("lines!", create_lines);
|
326
|
+
cPolygon.define_singleton_method("line_strip!", create_line_strip);
|
327
|
+
cPolygon.define_singleton_method("rect!", create_rect);
|
328
|
+
cPolygon.define_singleton_method("ellipse!", create_ellipse);
|
329
|
+
cPolygon.define_singleton_method("triangles!", create_triangles);
|
330
|
+
cPolygon.define_singleton_method("triangle_strip!", create_triangle_strip);
|
331
|
+
cPolygon.define_singleton_method("triangle_fan!", create_triangle_fan);
|
332
|
+
cPolygon.define_singleton_method("quads!", create_quads);
|
333
|
+
cPolygon.define_singleton_method("quad_strip!", create_quad_strip);
|
334
|
+
cPolygon.define_singleton_method("curve!", create_curve);
|
335
|
+
cPolygon.define_singleton_method("bezier!", create_bezier);
|
259
336
|
}
|
260
337
|
|
261
338
|
|
data/.doc/ext/rays/rays.cpp
CHANGED
@@ -16,7 +16,7 @@ struct EnumType
|
|
16
16
|
{
|
17
17
|
const char* name;
|
18
18
|
const char* short_name;
|
19
|
-
T
|
19
|
+
T value;
|
20
20
|
};
|
21
21
|
|
22
22
|
static std::vector<EnumType<Rays::CapType>> CAP_TYPES({
|
@@ -70,13 +70,13 @@ Init_rays ()
|
|
70
70
|
mRays.define_singleton_method("fin!", fin);
|
71
71
|
|
72
72
|
for (auto it = CAP_TYPES.begin(); it != CAP_TYPES.end(); ++it)
|
73
|
-
mRays.define_const(it->name, it->
|
73
|
+
mRays.define_const(it->name, it->value);
|
74
74
|
|
75
75
|
for (auto it = JOIN_TYPES.begin(); it != JOIN_TYPES.end(); ++it)
|
76
|
-
mRays.define_const(it->name, it->
|
76
|
+
mRays.define_const(it->name, it->value);
|
77
77
|
|
78
78
|
for (auto it = BLEND_MODES.begin(); it != BLEND_MODES.end(); ++it)
|
79
|
-
mRays.define_const(it->name, it->
|
79
|
+
mRays.define_const(it->name, it->value);
|
80
80
|
}
|
81
81
|
|
82
82
|
|
@@ -100,7 +100,7 @@ namespace Rucy
|
|
100
100
|
strcasecmp(str, it->name) == 0 ||
|
101
101
|
strcasecmp(str, it->short_name) == 0)
|
102
102
|
{
|
103
|
-
return it->
|
103
|
+
return it->value;
|
104
104
|
}
|
105
105
|
}
|
106
106
|
argument_error(__FILE__, __LINE__, "invalid cap type -- %s", str);
|
@@ -131,7 +131,7 @@ namespace Rucy
|
|
131
131
|
strcasecmp(str, it->name) == 0 ||
|
132
132
|
strcasecmp(str, it->short_name) == 0)
|
133
133
|
{
|
134
|
-
return it->
|
134
|
+
return it->value;
|
135
135
|
}
|
136
136
|
}
|
137
137
|
argument_error(__FILE__, __LINE__, "invalid join type -- %s", str);
|
@@ -162,18 +162,18 @@ namespace Rucy
|
|
162
162
|
strcasecmp(str, it->name) == 0 ||
|
163
163
|
strcasecmp(str, it->short_name) == 0)
|
164
164
|
{
|
165
|
-
return it->
|
165
|
+
return it->value;
|
166
166
|
}
|
167
167
|
}
|
168
168
|
argument_error(__FILE__, __LINE__, "invalid blend mode -- %s", str);
|
169
169
|
}
|
170
170
|
}
|
171
171
|
|
172
|
-
int
|
173
|
-
if (
|
174
|
-
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d",
|
172
|
+
int mode = value_to<int>(*argv, convert);
|
173
|
+
if (mode < 0 || Rays::BLEND_MAX <= mode)
|
174
|
+
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
175
175
|
|
176
|
-
return (Rays::BlendMode)
|
176
|
+
return (Rays::BlendMode) mode;
|
177
177
|
}
|
178
178
|
|
179
179
|
|
data/.github/workflows/test.yml
CHANGED
data/ChangeLog.md
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# rays ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.1.47] - 2023-12-09
|
5
|
+
|
6
|
+
- Add Polygon's singleton methods: points(), lines(), triangles(), triangle_strip(), triangle_fan(), quads(), quad_strip()
|
7
|
+
- Add create_polygon(DrawMode, ...)
|
8
|
+
- Add Painter#stroke_outset
|
9
|
+
- Add Bitmap#pixels
|
10
|
+
- Use earcut.hpp for polygon triangulation and delete poly2tri
|
11
|
+
- Painter#polygon() can take x, y, width, and height
|
12
|
+
- Polygon#bounds() caches bounds
|
13
|
+
- Polygon.line() -> Polygon.line_strip()
|
14
|
+
- Rays::Polygon.new() can take DrawMode
|
15
|
+
- Matrix(nullptr) avoids initialization
|
16
|
+
- Trigger github actions on all pull_request
|
17
|
+
|
18
|
+
|
4
19
|
## [v0.1.46] - 2023-11-09
|
5
20
|
|
6
21
|
- 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.47
|