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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9afd571fda027a889bb3d2ba60886e08ee8de5b825690d28838d10e729e5097d
|
4
|
+
data.tar.gz: 2bd0652be52c0f2f135cad35abe6b1b7140e90185ef9ec725e673aec2563f041
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94278334d219aebbaa3bd11b51f87555b230e8cd296115ccc06476b76f4240c0d5c4d976949b7bd04ce4b11aa056b738e7c9e5247dec8d75d14d36d5c7e388a0
|
7
|
+
data.tar.gz: 9ffd24082a1f0f37d6fbbb5ce016395069de981ba3c1ff0538392de790029f7ed69d50b739fa6a0debe7b5461b8624704c46b5e36967342c22250f8c655bbf0e
|
data/.doc/ext/rays/bitmap.cpp
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
#include "defs.h"
|
8
8
|
|
9
9
|
|
10
|
-
RUCY_DEFINE_VALUE_FROM_TO(Rays::Bitmap)
|
10
|
+
RUCY_DEFINE_VALUE_FROM_TO(RAYS_EXPORT, Rays::Bitmap)
|
11
11
|
|
12
12
|
#define THIS to<Rays::Bitmap*>(self)
|
13
13
|
|
@@ -317,23 +317,23 @@ set_pixels (Rays::Bitmap* bmp, Value pixels)
|
|
317
317
|
}
|
318
318
|
}
|
319
319
|
|
320
|
-
static inline
|
321
|
-
|
320
|
+
static inline uint32_t
|
321
|
+
to_rgb (uint8_t r, uint8_t g, uint8_t b)
|
322
322
|
{
|
323
|
-
return
|
324
|
-
((
|
325
|
-
((
|
326
|
-
((
|
323
|
+
return
|
324
|
+
((uint32_t) r) << 16 |
|
325
|
+
((uint32_t) g) << 8 |
|
326
|
+
((uint32_t) b);
|
327
327
|
}
|
328
328
|
|
329
|
-
static inline
|
330
|
-
|
329
|
+
static inline uint32_t
|
330
|
+
to_argb (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
|
331
331
|
{
|
332
|
-
return
|
333
|
-
((
|
334
|
-
((
|
335
|
-
((
|
336
|
-
((
|
332
|
+
return
|
333
|
+
((uint32_t) a) << 24 |
|
334
|
+
((uint32_t) r) << 16 |
|
335
|
+
((uint32_t) g) << 8 |
|
336
|
+
((uint32_t) b);
|
337
337
|
}
|
338
338
|
|
339
339
|
static void
|
@@ -392,7 +392,7 @@ get_pixels (auto* pixels, const Rays::Bitmap& bmp)
|
|
392
392
|
{
|
393
393
|
const auto* p = bmp.at<uint8_t>(0, y);
|
394
394
|
for (int x = 0; x < w; ++x, p += 3)
|
395
|
-
pixels->push_back(
|
395
|
+
pixels->push_back(value(to_rgb(p[0], p[1], p[2])));
|
396
396
|
}
|
397
397
|
break;
|
398
398
|
|
@@ -402,7 +402,7 @@ get_pixels (auto* pixels, const Rays::Bitmap& bmp)
|
|
402
402
|
{
|
403
403
|
const auto* p = bmp.at<uint8_t>(0, y);
|
404
404
|
for (int x = 0; x < w; ++x, p += 4)
|
405
|
-
pixels->push_back(
|
405
|
+
pixels->push_back(value(to_argb(p[0], p[1], p[2], p[3])));
|
406
406
|
}
|
407
407
|
break;
|
408
408
|
|
@@ -412,7 +412,7 @@ get_pixels (auto* pixels, const Rays::Bitmap& bmp)
|
|
412
412
|
{
|
413
413
|
const auto* p = bmp.at<uint8_t>(0, y);
|
414
414
|
for (int x = 0; x < w; ++x, p += 4)
|
415
|
-
pixels->push_back(
|
415
|
+
pixels->push_back(value(to_argb(p[1], p[2], p[3], p[0])));
|
416
416
|
}
|
417
417
|
break;
|
418
418
|
|
@@ -421,7 +421,7 @@ get_pixels (auto* pixels, const Rays::Bitmap& bmp)
|
|
421
421
|
{
|
422
422
|
const auto* p = bmp.at<uint8_t>(0, y);
|
423
423
|
for (int x = 0; x < w; ++x, p += 3)
|
424
|
-
pixels->push_back(
|
424
|
+
pixels->push_back(value(to_rgb(p[2], p[1], p[0])));
|
425
425
|
}
|
426
426
|
break;
|
427
427
|
|
@@ -431,7 +431,7 @@ get_pixels (auto* pixels, const Rays::Bitmap& bmp)
|
|
431
431
|
{
|
432
432
|
const auto* p = bmp.at<uint8_t>(0, y);
|
433
433
|
for (int x = 0; x < w; ++x, p += 4)
|
434
|
-
pixels->push_back(
|
434
|
+
pixels->push_back(value(to_argb(p[2], p[1], p[0], p[3])));
|
435
435
|
}
|
436
436
|
break;
|
437
437
|
|
@@ -441,7 +441,7 @@ get_pixels (auto* pixels, const Rays::Bitmap& bmp)
|
|
441
441
|
{
|
442
442
|
const auto* p = bmp.at<uint8_t>(0, y);
|
443
443
|
for (int x = 0; x < w; ++x, p += 4)
|
444
|
-
pixels->push_back(
|
444
|
+
pixels->push_back(value(to_argb(p[3], p[2], p[1], p[0])));
|
445
445
|
}
|
446
446
|
break;
|
447
447
|
|
@@ -532,17 +532,85 @@ get_pixels (auto* pixels, const Rays::Bitmap& bmp)
|
|
532
532
|
}
|
533
533
|
}
|
534
534
|
|
535
|
-
static
|
536
|
-
|
535
|
+
static Value
|
536
|
+
get_32bit_pixels_string (const Rays::Bitmap& bmp)
|
537
537
|
{
|
538
|
-
|
538
|
+
// avoid SEGV caused by 32bit argb value on 'x64-mingw-ucrt' platform.
|
539
|
+
|
540
|
+
const auto& cs = bmp.color_space();
|
541
|
+
if (cs.bpp() != 32) return nil();
|
542
|
+
|
543
|
+
int w = bmp.width(), h = bmp.height();
|
539
544
|
|
540
|
-
|
545
|
+
std::vector<uint32_t> pixels;
|
546
|
+
pixels.reserve(w * h);
|
547
|
+
|
548
|
+
switch (cs.type())
|
541
549
|
{
|
542
|
-
|
543
|
-
|
550
|
+
case Rays::GRAY_32:
|
551
|
+
case Rays::ALPHA_32:
|
552
|
+
for (int y = 0; y < h; ++y)
|
553
|
+
{
|
554
|
+
const auto* p = bmp.at<uint32_t>(0, y);
|
555
|
+
for (int x = 0; x < w; ++x, ++p)
|
556
|
+
pixels.push_back(*p);
|
557
|
+
}
|
558
|
+
break;
|
559
|
+
|
560
|
+
case Rays::RGBA_8888:
|
561
|
+
case Rays::RGBX_8888:
|
562
|
+
for (int y = 0; y < h; ++y)
|
563
|
+
{
|
564
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
565
|
+
for (int x = 0; x < w; ++x, p += 4)
|
566
|
+
pixels.push_back(to_argb(p[0], p[1], p[2], p[3]));
|
567
|
+
}
|
568
|
+
break;
|
569
|
+
|
570
|
+
case Rays::ARGB_8888:
|
571
|
+
case Rays::XRGB_8888:
|
572
|
+
for (int y = 0; y < h; ++y)
|
573
|
+
{
|
574
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
575
|
+
for (int x = 0; x < w; ++x, p += 4)
|
576
|
+
pixels.push_back(to_argb(p[1], p[2], p[3], p[0]));
|
577
|
+
}
|
578
|
+
break;
|
579
|
+
|
580
|
+
case Rays::BGRA_8888:
|
581
|
+
case Rays::BGRX_8888:
|
582
|
+
for (int y = 0; y < h; ++y)
|
583
|
+
{
|
584
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
585
|
+
for (int x = 0; x < w; ++x, p += 4)
|
586
|
+
pixels.push_back(to_argb(p[2], p[1], p[0], p[3]));
|
587
|
+
}
|
588
|
+
break;
|
589
|
+
|
590
|
+
case Rays::ABGR_8888:
|
591
|
+
case Rays::XBGR_8888:
|
592
|
+
for (int y = 0; y < h; ++y)
|
593
|
+
{
|
594
|
+
const auto* p = bmp.at<uint8_t>(0, y);
|
595
|
+
for (int x = 0; x < w; ++x, p += 4)
|
596
|
+
pixels.push_back(to_argb(p[3], p[2], p[1], p[0]));
|
597
|
+
}
|
598
|
+
break;
|
599
|
+
|
600
|
+
default:
|
601
|
+
return nil();
|
544
602
|
}
|
545
603
|
|
604
|
+
return value(
|
605
|
+
(const char*) &pixels[0], pixels.size() * sizeof(uint32_t),
|
606
|
+
rb_ascii8bit_encoding());
|
607
|
+
}
|
608
|
+
|
609
|
+
static
|
610
|
+
VALUE set_pixels(VALUE self, VALUE pixels)
|
611
|
+
{
|
612
|
+
CHECK;
|
613
|
+
|
546
614
|
set_pixels(THIS, pixels);
|
547
615
|
return pixels;
|
548
616
|
}
|
@@ -552,11 +620,10 @@ VALUE get_pixels(VALUE self)
|
|
552
620
|
{
|
553
621
|
CHECK;
|
554
622
|
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
}
|
623
|
+
#ifdef RAYS_32BIT_PIXELS_STRING
|
624
|
+
Value str = get_32bit_pixels_string(*THIS);
|
625
|
+
if (str) return str;
|
626
|
+
#endif
|
560
627
|
|
561
628
|
std::vector<VALUE> pixels;
|
562
629
|
get_pixels(&pixels, *THIS);
|
@@ -603,7 +670,7 @@ Init_rays_bitmap ()
|
|
603
670
|
rb_define_method(cBitmap, "height", RUBY_METHOD_FUNC(height), 0);
|
604
671
|
rb_define_method(cBitmap, "color_space", RUBY_METHOD_FUNC(color_space), 0);
|
605
672
|
rb_define_method(cBitmap, "pixels=", RUBY_METHOD_FUNC(set_pixels), 1);
|
606
|
-
|
673
|
+
cBitmap.define_method("pixels!", get_pixels);
|
607
674
|
cBitmap.define_method("[]=", set_at);
|
608
675
|
cBitmap.define_method("[]", get_at);
|
609
676
|
}
|
data/.doc/ext/rays/bounds.cpp
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
#include "defs.h"
|
7
7
|
|
8
8
|
|
9
|
-
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(Rays::Bounds)
|
9
|
+
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Bounds)
|
10
10
|
|
11
11
|
#define THIS to<Rays::Bounds*>(self)
|
12
12
|
|
@@ -70,7 +70,7 @@ VALUE move_to(VALUE self)
|
|
70
70
|
CHECK;
|
71
71
|
check_arg_count(__FILE__, __LINE__, "Bounds#move_to", argc, 1, 2, 3);
|
72
72
|
|
73
|
-
if (argv[0].
|
73
|
+
if (argv[0].is_a(Rays::point_class()))
|
74
74
|
THIS->move_to(to<Rays::Point&>(argv[0]));
|
75
75
|
else
|
76
76
|
{
|
@@ -96,7 +96,7 @@ VALUE move_by(VALUE self)
|
|
96
96
|
CHECK;
|
97
97
|
check_arg_count(__FILE__, __LINE__, "Bounds#move_by", argc, 1, 2, 3);
|
98
98
|
|
99
|
-
if (argv[0].
|
99
|
+
if (argv[0].is_a(Rays::point_class()))
|
100
100
|
THIS->move_by(to<Rays::Point&>(argv[0]));
|
101
101
|
else
|
102
102
|
{
|
@@ -121,7 +121,7 @@ VALUE resize_to(VALUE self)
|
|
121
121
|
CHECK;
|
122
122
|
check_arg_count(__FILE__, __LINE__, "Bounds#resize_to", argc, 1, 2, 3);
|
123
123
|
|
124
|
-
if (argv[0].
|
124
|
+
if (argv[0].is_a(Rays::point_class()))
|
125
125
|
THIS->resize_to(to<Rays::Point&>(argv[0]));
|
126
126
|
else
|
127
127
|
{
|
@@ -147,7 +147,7 @@ VALUE resize_by(VALUE self)
|
|
147
147
|
CHECK;
|
148
148
|
check_arg_count(__FILE__, __LINE__, "Bounds#resize_by", argc, 1, 2, 3);
|
149
149
|
|
150
|
-
if (argv[0].
|
150
|
+
if (argv[0].is_a(Rays::point_class()))
|
151
151
|
THIS->resize_by(to<Rays::Point&>(argv[0]));
|
152
152
|
else
|
153
153
|
{
|
@@ -172,7 +172,7 @@ VALUE inset_by(VALUE self)
|
|
172
172
|
CHECK;
|
173
173
|
check_arg_count(__FILE__, __LINE__, "Bounds#inset_by", argc, 1, 2, 3);
|
174
174
|
|
175
|
-
if (argv[0].
|
175
|
+
if (argv[0].is_a(Rays::point_class()))
|
176
176
|
THIS->inset_by(to<Rays::Point&>(argv[0]));
|
177
177
|
else
|
178
178
|
{
|
@@ -460,7 +460,9 @@ VALUE set_at(VALUE self, VALUE index, VALUE value)
|
|
460
460
|
CHECK;
|
461
461
|
|
462
462
|
int i = index.as_i();
|
463
|
-
if (i < 0
|
463
|
+
if (i < 0)
|
464
|
+
index_error(__FILE__, __LINE__);
|
465
|
+
if (i > 1)
|
464
466
|
index_error(__FILE__, __LINE__);
|
465
467
|
|
466
468
|
(*THIS)[i] = to<Rays::Point&>(value);
|
@@ -473,7 +475,9 @@ VALUE get_at(VALUE self, VALUE index)
|
|
473
475
|
CHECK;
|
474
476
|
|
475
477
|
int i = index.as_i();
|
476
|
-
if (i < 0
|
478
|
+
if (i < 0)
|
479
|
+
index_error(__FILE__, __LINE__);
|
480
|
+
if (i > 1)
|
477
481
|
index_error(__FILE__, __LINE__);
|
478
482
|
|
479
483
|
return value((*THIS)[i]);
|
@@ -495,9 +499,9 @@ VALUE op_or(VALUE self, VALUE arg)
|
|
495
499
|
CHECK;
|
496
500
|
|
497
501
|
Rays::Bounds b = *THIS;
|
498
|
-
if (arg.
|
502
|
+
if (arg.is_a(Rays::bounds_class()))
|
499
503
|
b |= to<Rays::Bounds&>(arg);
|
500
|
-
else if (arg.
|
504
|
+
else if (arg.is_a(Rays::point_class()))
|
501
505
|
b |= to<Rays::Point&>(arg);
|
502
506
|
else
|
503
507
|
argument_error(__FILE__, __LINE__);
|
@@ -582,7 +586,7 @@ namespace Rucy
|
|
582
586
|
{
|
583
587
|
|
584
588
|
|
585
|
-
template <> Rays::Bounds
|
589
|
+
template <> RAYS_EXPORT Rays::Bounds
|
586
590
|
value_to<Rays::Bounds> (int argc, const Value* argv, bool convert)
|
587
591
|
{
|
588
592
|
if (argc == 1 && argv->is_array())
|
@@ -597,7 +601,7 @@ namespace Rucy
|
|
597
601
|
{
|
598
602
|
if (argc == 0)
|
599
603
|
return Rays::Bounds();
|
600
|
-
else if (argv->
|
604
|
+
else if (argv->is_a(Rays::point_class()))
|
601
605
|
{
|
602
606
|
switch (argc)
|
603
607
|
{
|
data/.doc/ext/rays/camera.cpp
CHANGED
data/.doc/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
|
|
@@ -330,7 +330,7 @@ namespace Rucy
|
|
330
330
|
return find_color(str_.c_str());
|
331
331
|
}
|
332
332
|
|
333
|
-
template <> Rays::Color
|
333
|
+
template <> RAYS_EXPORT Rays::Color
|
334
334
|
value_to<Rays::Color> (int argc, const Value*argv, bool convert)
|
335
335
|
{
|
336
336
|
if (argc == 1 && argv->is_array())
|
@@ -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
|
|
@@ -206,7 +206,7 @@ namespace Rucy
|
|
206
206
|
{
|
207
207
|
|
208
208
|
|
209
|
-
template <> Rays::ColorSpace
|
209
|
+
template <> RAYS_EXPORT Rays::ColorSpace
|
210
210
|
value_to<Rays::ColorSpace> (int argc, const Value* argv, bool convert)
|
211
211
|
{
|
212
212
|
if (argc == 1 && argv->is_array())
|
@@ -234,7 +234,7 @@ namespace Rucy
|
|
234
234
|
}
|
235
235
|
|
236
236
|
|
237
|
-
template <> Rays::ColorSpaceType
|
237
|
+
template <> RAYS_EXPORT Rays::ColorSpaceType
|
238
238
|
value_to<Rays::ColorSpaceType> (Value value, bool convert)
|
239
239
|
{
|
240
240
|
if (convert)
|
data/.doc/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/.doc/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
|
|
@@ -156,7 +156,7 @@ namespace Rucy
|
|
156
156
|
{
|
157
157
|
|
158
158
|
|
159
|
-
template <> Rays::Font
|
159
|
+
template <> RAYS_EXPORT Rays::Font
|
160
160
|
value_to<Rays::Font> (int argc, const Value* argv, bool convert)
|
161
161
|
{
|
162
162
|
if (argc == 1 && argv->is_array())
|
@@ -172,7 +172,8 @@ namespace Rucy
|
|
172
172
|
if (argc == 0)
|
173
173
|
return Rays::get_default_font();
|
174
174
|
|
175
|
-
coord size =
|
175
|
+
coord size =
|
176
|
+
argc >= 2 ? to<coord>(argv[1]) : (coord) Rays::Font::DEFAULT_SIZE;
|
176
177
|
if (argv->is_nil())
|
177
178
|
return Rays::Font(NULL, size);
|
178
179
|
else if (argv->is_s() || argv->is_sym())
|
data/.doc/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
|
|
@@ -21,31 +21,28 @@ VALUE alloc(VALUE klass)
|
|
21
21
|
}
|
22
22
|
|
23
23
|
static
|
24
|
-
VALUE initialize(VALUE self)
|
24
|
+
VALUE initialize(VALUE self, VALUE args, VALUE pixel_density, VALUE smooth)
|
25
25
|
{
|
26
26
|
RUCY_CHECK_OBJ(Rays::Image, self);
|
27
|
-
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3, 4);
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2);
|
28
|
+
size_t argc = args.size();
|
29
|
+
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3);
|
32
30
|
|
33
|
-
|
34
|
-
|
31
|
+
float pd = to<float>(pixel_density);
|
32
|
+
if (args[0].is_a(Rays::bitmap_class()))
|
33
|
+
{
|
34
|
+
const Rays::Bitmap* bmp = to<Rays::Bitmap*>(args[0]);
|
35
|
+
if (!bmp)
|
35
36
|
argument_error(__FILE__, __LINE__);
|
36
37
|
|
37
|
-
|
38
|
-
*THIS = Rays::Image(*bitmap, pixel_density);
|
38
|
+
*THIS = Rays::Image(*bmp, pd, smooth);
|
39
39
|
}
|
40
40
|
else
|
41
41
|
{
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
Rays::ColorSpace cs = (argc >= 3) ? to<Rays::ColorSpace>(argv[2]) : Rays::RGBA;
|
47
|
-
float pixel_density = (argc >= 4) ? to<float>(argv[3]) : 1;
|
48
|
-
*THIS = Rays::Image(width, height, cs, pixel_density);
|
42
|
+
int width = to<int>(args[0]);
|
43
|
+
int height = to<int>(args[1]);
|
44
|
+
auto cs = (argc >= 3) ? to<Rays::ColorSpace>(args[2]) : Rays::RGBA;
|
45
|
+
*THIS = Rays::Image(width, height, cs, pd, smooth);
|
49
46
|
}
|
50
47
|
|
51
48
|
return self;
|
@@ -110,6 +107,21 @@ VALUE get_bitmap(VALUE self, VALUE modify)
|
|
110
107
|
return value(THIS->bitmap(modify));
|
111
108
|
}
|
112
109
|
|
110
|
+
static
|
111
|
+
VALUE set_smooth(VALUE self, VALUE smooth)
|
112
|
+
{
|
113
|
+
CHECK;
|
114
|
+
THIS->set_smooth(smooth);
|
115
|
+
return smooth;
|
116
|
+
}
|
117
|
+
|
118
|
+
static
|
119
|
+
VALUE get_smooth(VALUE self)
|
120
|
+
{
|
121
|
+
CHECK;
|
122
|
+
return value(THIS->smooth());
|
123
|
+
}
|
124
|
+
|
113
125
|
static
|
114
126
|
VALUE load(VALUE self, VALUE path)
|
115
127
|
{
|
@@ -126,7 +138,7 @@ Init_rays_image ()
|
|
126
138
|
|
127
139
|
cImage = rb_define_class_under(mRays, "Image", rb_cObject);
|
128
140
|
rb_define_alloc_func(cImage, alloc);
|
129
|
-
|
141
|
+
cImage.define_private_method("initialize!", initialize);
|
130
142
|
rb_define_private_method(cImage, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
131
143
|
rb_define_method(cImage, "save", RUBY_METHOD_FUNC(save), 1);
|
132
144
|
rb_define_method(cImage, "width", RUBY_METHOD_FUNC(width), 0);
|
@@ -135,6 +147,8 @@ Init_rays_image ()
|
|
135
147
|
rb_define_method(cImage, "pixel_density", RUBY_METHOD_FUNC(pixel_density), 0);
|
136
148
|
rb_define_method(cImage, "painter", RUBY_METHOD_FUNC(painter), 0);
|
137
149
|
rb_define_private_method(cImage, "get_bitmap", RUBY_METHOD_FUNC(get_bitmap), 1);
|
150
|
+
rb_define_method(cImage, "smooth=", RUBY_METHOD_FUNC(set_smooth), 1);
|
151
|
+
rb_define_method(cImage, "smooth", RUBY_METHOD_FUNC(get_smooth), 0);
|
138
152
|
rb_define_module_function(cImage, "load", RUBY_METHOD_FUNC(load), 1);
|
139
153
|
}
|
140
154
|
|
data/.doc/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
|
|
@@ -127,10 +127,10 @@ VALUE mult(VALUE self, VALUE val)
|
|
127
127
|
{
|
128
128
|
CHECK;
|
129
129
|
|
130
|
-
if (val.
|
130
|
+
if (val.is_a(Rays::matrix_class()))
|
131
131
|
return value(*THIS * to<Rays::Matrix&>(val));
|
132
132
|
|
133
|
-
if (val.
|
133
|
+
if (val.is_a(Rays::point_class()))
|
134
134
|
return value(*THIS * to<Rays::Point&>(val));
|
135
135
|
|
136
136
|
if (val.is_array())
|
@@ -214,10 +214,10 @@ VALUE s_ortho(VALUE self)
|
|
214
214
|
}
|
215
215
|
|
216
216
|
static
|
217
|
-
VALUE s_perspective(VALUE self, VALUE fov_y, VALUE aspect_ratio, VALUE
|
217
|
+
VALUE s_perspective(VALUE self, VALUE fov_y, VALUE aspect_ratio, VALUE near_, VALUE far_)
|
218
218
|
{
|
219
219
|
return value(Rays::perspective(
|
220
|
-
to<float>(fov_y), to<float>(aspect_ratio), to<coord>(
|
220
|
+
to<float>(fov_y), to<float>(aspect_ratio), to<coord>(near_), to<coord>(far_)));
|
221
221
|
}
|
222
222
|
|
223
223
|
static
|
@@ -281,7 +281,7 @@ namespace Rucy
|
|
281
281
|
{
|
282
282
|
|
283
283
|
|
284
|
-
template <> Rays::Matrix
|
284
|
+
template <> RAYS_EXPORT Rays::Matrix
|
285
285
|
value_to<Rays::Matrix> (int argc, const Value* argv, bool convert)
|
286
286
|
{
|
287
287
|
if (argc == 1 && argv->is_array())
|
data/.doc/ext/rays/painter.cpp
CHANGED
data/.doc/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
|
|
@@ -44,7 +44,7 @@ VALUE move_to(VALUE self)
|
|
44
44
|
CHECK;
|
45
45
|
check_arg_count(__FILE__, __LINE__, "Point#move_to", argc, 1, 2, 3);
|
46
46
|
|
47
|
-
if (argv[0].
|
47
|
+
if (argv[0].is_a(Rays::point_class()))
|
48
48
|
THIS->move_to(to<Rays::Point&>(argv[0]));
|
49
49
|
else
|
50
50
|
{
|
@@ -64,7 +64,7 @@ VALUE move_by(VALUE self)
|
|
64
64
|
CHECK;
|
65
65
|
check_arg_count(__FILE__, __LINE__, "Point#move_by", argc, 1, 2, 3);
|
66
66
|
|
67
|
-
if (argv[0].
|
67
|
+
if (argv[0].is_a(Rays::point_class()))
|
68
68
|
THIS->move_by(to<Rays::Point&>(argv[0]));
|
69
69
|
else
|
70
70
|
{
|
@@ -204,7 +204,9 @@ VALUE set_at(VALUE self, VALUE index, VALUE value)
|
|
204
204
|
CHECK;
|
205
205
|
|
206
206
|
int i = index.as_i();
|
207
|
-
if (i < 0
|
207
|
+
if (i < 0)
|
208
|
+
index_error(__FILE__, __LINE__);
|
209
|
+
if (i > 2)
|
208
210
|
index_error(__FILE__, __LINE__);
|
209
211
|
|
210
212
|
(*THIS)[i] = to<coord>(value);
|
@@ -217,7 +219,9 @@ VALUE get_at(VALUE self, VALUE index)
|
|
217
219
|
CHECK;
|
218
220
|
|
219
221
|
int i = index.as_i();
|
220
|
-
if (i < 0
|
222
|
+
if (i < 0)
|
223
|
+
index_error(__FILE__, __LINE__);
|
224
|
+
if (i > 2)
|
221
225
|
index_error(__FILE__, __LINE__);
|
222
226
|
|
223
227
|
return value((*THIS)[i]);
|
@@ -275,7 +279,7 @@ namespace Rucy
|
|
275
279
|
{
|
276
280
|
|
277
281
|
|
278
|
-
template <> Rays::Point
|
282
|
+
template <> RAYS_EXPORT Rays::Point
|
279
283
|
value_to<Rays::Point> (int argc, const Value* argv, bool convert)
|
280
284
|
{
|
281
285
|
if (argc == 1 && argv->is_array())
|