rays 0.4.0 → 0.5.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 +28 -8
- data/.doc/ext/rays/bounds.cpp +1 -1
- data/.doc/ext/rays/camera.cpp +5 -5
- data/.doc/ext/rays/color.cpp +1 -1
- data/.doc/ext/rays/color_space.cpp +10 -6
- data/.doc/ext/rays/font.cpp +116 -18
- data/.doc/ext/rays/image.cpp +27 -4
- data/.doc/ext/rays/matrix.cpp +1 -1
- data/.doc/ext/rays/painter.cpp +5 -5
- data/.doc/ext/rays/point.cpp +1 -1
- data/.doc/ext/rays/polygon.cpp +4 -4
- data/.doc/ext/rays/polyline.cpp +2 -2
- data/.doc/ext/rays/shader.cpp +2 -2
- data/.github/workflows/release-gem.yml +2 -49
- data/.github/workflows/tag.yml +5 -28
- data/.github/workflows/test.yml +1 -37
- data/ChangeLog.md +21 -0
- data/Gemfile.lock +13 -8
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +28 -8
- data/ext/rays/bounds.cpp +1 -1
- data/ext/rays/camera.cpp +5 -5
- data/ext/rays/color.cpp +1 -1
- data/ext/rays/color_space.cpp +10 -6
- data/ext/rays/defs.h +3 -3
- data/ext/rays/extconf.rb +6 -5
- data/ext/rays/font.cpp +120 -18
- data/ext/rays/image.cpp +27 -4
- data/ext/rays/matrix.cpp +1 -1
- data/ext/rays/painter.cpp +5 -5
- data/ext/rays/point.cpp +1 -1
- data/ext/rays/polygon.cpp +4 -4
- data/ext/rays/polyline.cpp +2 -2
- data/ext/rays/shader.cpp +2 -2
- data/include/rays/bitmap.h +2 -0
- data/include/rays/font.h +46 -4
- data/include/rays/image.h +9 -5
- data/include/rays/painter.h +3 -1
- data/include/rays/ruby/color_space.h +2 -0
- data/include/rays/shader.h +3 -0
- data/lib/rays/font.rb +4 -1
- data/lib/rays/image.rb +2 -0
- data/lib/rays/painter.rb +5 -5
- data/rays.gemspec +3 -3
- data/src/bitmap.cpp +107 -0
- data/src/color.cpp +17 -0
- data/src/font.cpp +121 -25
- data/src/font.h +7 -5
- data/src/image.cpp +102 -100
- data/src/ios/font.mm +77 -24
- data/src/opengl/color_space.cpp +4 -1
- data/src/opengl/painter.cpp +86 -18
- data/src/opengl/shader.cpp +15 -13
- data/src/opengl/texture.cpp +2 -2
- data/src/opengl/win32/opengl.cpp +17 -12
- data/src/osx/font.mm +77 -24
- data/src/painter.cpp +12 -12
- data/src/painter.h +5 -1
- data/src/polygon.cpp +21 -21
- data/src/polyline.cpp +4 -4
- data/src/sdl/bitmap.cpp +16 -10
- data/src/sdl/font.cpp +56 -50
- data/src/win32/bitmap.cpp +22 -13
- data/src/win32/font.cpp +43 -44
- data/src/win32/gdi.cpp +43 -46
- data/src/win32/gdi.h +6 -1
- data/src/win32/rays.cpp +18 -1
- data/test/test_bitmap.rb +28 -10
- data/test/test_font.rb +58 -0
- data/test/test_image.rb +29 -6
- data/test/test_painter.rb +39 -0
- metadata +8 -8
- data/.github/workflows/utils.rb +0 -127
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db829b19cf715370698a98bcf00a47430aeb4896d366eee24a0448db4ac4f58e
|
|
4
|
+
data.tar.gz: 42630c214769a8cf8cea42f39815f6125464b2dcc1b58da4036ef22a4df3e963
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40b9c27b937d402a12717ae93a8485fc1c1b1052cafcdeb739c6b679a1e07d23f253b9e5566f94fb2d844f043cb54b6500bf73a4a97f9a7639bf79f1d7f87e45
|
|
7
|
+
data.tar.gz: 3514007e11230a8d5b323026ad0fd2a1102fb066c65072ed05eb6ce91964975df06cf8fa6a315880ce5f6212b2659aa6cede56f7e6240b73854d9d685142e1ce
|
data/.doc/ext/rays/bitmap.cpp
CHANGED
|
@@ -11,7 +11,7 @@ RUCY_DEFINE_VALUE_FROM_TO(RAYS_EXPORT, Rays::Bitmap)
|
|
|
11
11
|
|
|
12
12
|
#define THIS to<Rays::Bitmap*>(self)
|
|
13
13
|
|
|
14
|
-
#define CHECK
|
|
14
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Bitmap, self)
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
static
|
|
@@ -23,7 +23,7 @@ VALUE alloc(VALUE klass)
|
|
|
23
23
|
static
|
|
24
24
|
VALUE initialize(VALUE self)
|
|
25
25
|
{
|
|
26
|
-
|
|
26
|
+
RUCY_CHECK_PTR(Rays::Bitmap, self);
|
|
27
27
|
check_arg_count(__FILE__, __LINE__, "Bitmap#initialize", argc, 2, 3);
|
|
28
28
|
|
|
29
29
|
*THIS = Rays::Bitmap(
|
|
@@ -36,7 +36,7 @@ VALUE initialize(VALUE self)
|
|
|
36
36
|
static
|
|
37
37
|
VALUE initialize_copy(VALUE self, VALUE obj)
|
|
38
38
|
{
|
|
39
|
-
|
|
39
|
+
RUCY_CHECK_PTR(Rays::Bitmap, self);
|
|
40
40
|
|
|
41
41
|
*THIS = to<Rays::Bitmap&>(obj).dup();
|
|
42
42
|
return self;
|
|
@@ -67,7 +67,7 @@ VALUE color_space(VALUE self)
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
static void
|
|
70
|
-
|
|
70
|
+
set_raw_pixels (Rays::Bitmap* bmp, Value pixels)
|
|
71
71
|
{
|
|
72
72
|
int w = bmp->width(), h = bmp->height();
|
|
73
73
|
const auto& cs = bmp->color_space();
|
|
@@ -317,6 +317,23 @@ set_pixels (Rays::Bitmap* bmp, Value pixels)
|
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
|
|
320
|
+
static void
|
|
321
|
+
set_pixels (Rays::Bitmap* bmp, Value pixels)
|
|
322
|
+
{
|
|
323
|
+
const auto& cs = bmp->color_space();
|
|
324
|
+
if (!cs.has_alpha() || !cs.is_premult())
|
|
325
|
+
return set_raw_pixels(bmp, pixels);
|
|
326
|
+
|
|
327
|
+
int w = bmp->width(), h = bmp->height();
|
|
328
|
+
Rays::Bitmap straight(w, h, Rays::ColorSpace(cs.type(), false));
|
|
329
|
+
set_raw_pixels(&straight, pixels);
|
|
330
|
+
|
|
331
|
+
Rays::Bitmap premult = straight.dup(true);
|
|
332
|
+
size_t size = w * cs.Bpp();
|
|
333
|
+
for (int y = 0; y < h; ++y)
|
|
334
|
+
memcpy(bmp->at<uint8_t>(0, y), premult.at<uint8_t>(0, y), size);
|
|
335
|
+
}
|
|
336
|
+
|
|
320
337
|
static inline uint32_t
|
|
321
338
|
to_rgb (uint8_t r, uint8_t g, uint8_t b)
|
|
322
339
|
{
|
|
@@ -602,7 +619,7 @@ get_32bit_pixels_string (const Rays::Bitmap& bmp)
|
|
|
602
619
|
}
|
|
603
620
|
|
|
604
621
|
return value(
|
|
605
|
-
(const char*)
|
|
622
|
+
(const char*) pixels.data(), pixels.size() * sizeof(uint32_t),
|
|
606
623
|
rb_ascii8bit_encoding());
|
|
607
624
|
}
|
|
608
625
|
|
|
@@ -620,14 +637,17 @@ VALUE get_pixels(VALUE self)
|
|
|
620
637
|
{
|
|
621
638
|
CHECK;
|
|
622
639
|
|
|
640
|
+
const auto& cs = THIS->color_space();
|
|
641
|
+
Rays::Bitmap bmp = cs.has_alpha() && cs.is_premult() ? THIS->dup(false) : *THIS;
|
|
642
|
+
|
|
623
643
|
#ifdef RAYS_32BIT_PIXELS_STRING
|
|
624
|
-
Value str = get_32bit_pixels_string(
|
|
644
|
+
Value str = get_32bit_pixels_string(bmp);
|
|
625
645
|
if (str) return str;
|
|
626
646
|
#endif
|
|
627
647
|
|
|
628
648
|
std::vector<VALUE> pixels;
|
|
629
|
-
get_pixels(&pixels,
|
|
630
|
-
return array((const Value*)
|
|
649
|
+
get_pixels(&pixels, bmp);
|
|
650
|
+
return array((const Value*) pixels.data(), pixels.size());
|
|
631
651
|
}
|
|
632
652
|
|
|
633
653
|
static
|
data/.doc/ext/rays/bounds.cpp
CHANGED
data/.doc/ext/rays/camera.cpp
CHANGED
|
@@ -10,7 +10,7 @@ RUCY_DEFINE_VALUE_FROM_TO(RAYS_EXPORT, Rays::Camera)
|
|
|
10
10
|
|
|
11
11
|
#define THIS to<Rays::Camera*>(self)
|
|
12
12
|
|
|
13
|
-
#define CHECK
|
|
13
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Camera, self)
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
static
|
|
@@ -22,7 +22,7 @@ VALUE alloc(VALUE klass)
|
|
|
22
22
|
static
|
|
23
23
|
VALUE initialize(VALUE self, VALUE device_name, VALUE min_width, VALUE min_height, VALUE resize, VALUE crop)
|
|
24
24
|
{
|
|
25
|
-
|
|
25
|
+
RUCY_CHECK_PTR(Rays::Camera, self);
|
|
26
26
|
|
|
27
27
|
*THIS = Rays::Camera(
|
|
28
28
|
device_name ? device_name.c_str() : NULL,
|
|
@@ -131,10 +131,10 @@ VALUE device_names(VALUE self)
|
|
|
131
131
|
{
|
|
132
132
|
auto names = Rays::get_camera_device_names();
|
|
133
133
|
|
|
134
|
-
|
|
134
|
+
Value v = array(NULL, names.size());
|
|
135
135
|
for (const auto& name : names)
|
|
136
|
-
v.
|
|
137
|
-
return
|
|
136
|
+
v.push(name.c_str());
|
|
137
|
+
return v;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
|
data/.doc/ext/rays/color.cpp
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::ColorSpace)
|
|
8
8
|
|
|
9
|
+
RUCY_DEFINE_CONVERT_TO(RAYS_EXPORT, Rays::ColorSpaceType)
|
|
10
|
+
|
|
9
11
|
#define THIS to<Rays::ColorSpace*>(self)
|
|
10
12
|
|
|
11
|
-
#define CHECK
|
|
13
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::ColorSpace, self)
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
static struct ColorSpaceEnum
|
|
@@ -71,7 +73,7 @@ VALUE alloc(VALUE klass)
|
|
|
71
73
|
static
|
|
72
74
|
VALUE initialize(VALUE self)
|
|
73
75
|
{
|
|
74
|
-
|
|
76
|
+
RUCY_CHECK_PTR(Rays::ColorSpace, self);
|
|
75
77
|
check_arg_count(__FILE__, __LINE__, "ColorSpace#initialize", argc, 1, 2);
|
|
76
78
|
|
|
77
79
|
*THIS = to<Rays::ColorSpace>(argc, argv);
|
|
@@ -235,13 +237,15 @@ namespace Rucy
|
|
|
235
237
|
|
|
236
238
|
|
|
237
239
|
template <> RAYS_EXPORT Rays::ColorSpaceType
|
|
238
|
-
value_to<Rays::ColorSpaceType> (Value
|
|
240
|
+
value_to<Rays::ColorSpaceType> (int argc, const Value* argv, bool convert)
|
|
239
241
|
{
|
|
242
|
+
assert(argc > 0 && argv);
|
|
243
|
+
|
|
240
244
|
if (convert)
|
|
241
245
|
{
|
|
242
|
-
if (
|
|
246
|
+
if (argv->is_s() || argv->is_sym())
|
|
243
247
|
{
|
|
244
|
-
const char* str =
|
|
248
|
+
const char* str = argv->c_str();
|
|
245
249
|
for (size_t i = 0; i < COLOR_SPACES_SIZE; ++i)
|
|
246
250
|
{
|
|
247
251
|
if (strcasecmp(str, COLOR_SPACES[i].name) == 0)
|
|
@@ -250,7 +254,7 @@ namespace Rucy
|
|
|
250
254
|
}
|
|
251
255
|
}
|
|
252
256
|
|
|
253
|
-
uint type = value_to<uint>(
|
|
257
|
+
uint type = value_to<uint>(*argv, convert);
|
|
254
258
|
if (type >= Rays::COLORSPACE_MAX)
|
|
255
259
|
argument_error(__FILE__, __LINE__, "invalid color space type -- %d", type);
|
|
256
260
|
|
data/.doc/ext/rays/font.cpp
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#include "rays/ruby/font.h"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
+
#include <strings.h>
|
|
4
5
|
#include "defs.h"
|
|
5
6
|
|
|
6
7
|
|
|
@@ -8,7 +9,7 @@ RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Font)
|
|
|
8
9
|
|
|
9
10
|
#define THIS to<Rays::Font*>(self)
|
|
10
11
|
|
|
11
|
-
#define CHECK
|
|
12
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Font, self)
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
static
|
|
@@ -20,7 +21,7 @@ VALUE alloc(VALUE klass)
|
|
|
20
21
|
static
|
|
21
22
|
VALUE initialize(VALUE self)
|
|
22
23
|
{
|
|
23
|
-
|
|
24
|
+
RUCY_CHECK_PTR(Rays::Font, self);
|
|
24
25
|
check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2, 3);
|
|
25
26
|
|
|
26
27
|
*THIS = to<Rays::Font>(argc, argv);
|
|
@@ -30,7 +31,7 @@ VALUE initialize(VALUE self)
|
|
|
30
31
|
static
|
|
31
32
|
VALUE initialize_copy(VALUE self, VALUE obj)
|
|
32
33
|
{
|
|
33
|
-
|
|
34
|
+
RUCY_CHECK_PTR(Rays::Font, self);
|
|
34
35
|
|
|
35
36
|
*THIS = to<Rays::Font&>(obj).dup();
|
|
36
37
|
return self;
|
|
@@ -40,7 +41,10 @@ static
|
|
|
40
41
|
VALUE name(VALUE self)
|
|
41
42
|
{
|
|
42
43
|
CHECK;
|
|
43
|
-
|
|
44
|
+
check_arg_count(__FILE__, __LINE__, "Font#name", argc, 0, 1);
|
|
45
|
+
|
|
46
|
+
bool resolved = argc >= 1 ? to<bool>(argv[0]) : false;
|
|
47
|
+
return value(THIS->name(resolved).c_str());
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
static
|
|
@@ -58,6 +62,70 @@ VALUE size(VALUE self)
|
|
|
58
62
|
return value(THIS->size());
|
|
59
63
|
}
|
|
60
64
|
|
|
65
|
+
static int
|
|
66
|
+
to_font_weight (Value weight)
|
|
67
|
+
{
|
|
68
|
+
if (weight.is_s() || weight.is_sym())
|
|
69
|
+
{
|
|
70
|
+
static const struct {const char* name; int weight;} WEIGHTS[] =
|
|
71
|
+
{
|
|
72
|
+
// most used first
|
|
73
|
+
{"normal", Rays::Font::WEIGHT_NORMAL},
|
|
74
|
+
{"regular", Rays::Font::WEIGHT_NORMAL},
|
|
75
|
+
{"bold", Rays::Font::WEIGHT_BOLD},
|
|
76
|
+
|
|
77
|
+
{"thin", Rays::Font::WEIGHT_THIN},
|
|
78
|
+
{"extralight", Rays::Font::WEIGHT_EXTRALIGHT},
|
|
79
|
+
{"light", Rays::Font::WEIGHT_LIGHT},
|
|
80
|
+
{"medium", Rays::Font::WEIGHT_MEDIUM},
|
|
81
|
+
{"semibold", Rays::Font::WEIGHT_SEMIBOLD},
|
|
82
|
+
{"extrabold", Rays::Font::WEIGHT_EXTRABOLD},
|
|
83
|
+
{"black", Rays::Font::WEIGHT_BLACK},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const char* name = weight.c_str();
|
|
87
|
+
for (const auto& w : WEIGHTS)
|
|
88
|
+
{
|
|
89
|
+
if (strcasecmp(name, w.name) == 0)
|
|
90
|
+
return w.weight;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
argument_error(
|
|
94
|
+
__FILE__, __LINE__, "unknown font weight: %s", weight.inspect().c_str());
|
|
95
|
+
}
|
|
96
|
+
return to<int>(weight);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
static
|
|
100
|
+
VALUE set_weight(VALUE self, VALUE weight)
|
|
101
|
+
{
|
|
102
|
+
CHECK;
|
|
103
|
+
THIS->set_weight(to_font_weight(weight));
|
|
104
|
+
return weight;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
static
|
|
108
|
+
VALUE weight(VALUE self)
|
|
109
|
+
{
|
|
110
|
+
CHECK;
|
|
111
|
+
return value(THIS->weight());
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static
|
|
115
|
+
VALUE set_italic(VALUE self, VALUE italic)
|
|
116
|
+
{
|
|
117
|
+
CHECK;
|
|
118
|
+
THIS->set_italic(to<bool>(italic));
|
|
119
|
+
return italic;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static
|
|
123
|
+
VALUE get_italic(VALUE self)
|
|
124
|
+
{
|
|
125
|
+
CHECK;
|
|
126
|
+
return value(THIS->italic());
|
|
127
|
+
}
|
|
128
|
+
|
|
61
129
|
static
|
|
62
130
|
VALUE set_smooth(VALUE self, VALUE smooth)
|
|
63
131
|
{
|
|
@@ -67,7 +135,7 @@ VALUE set_smooth(VALUE self, VALUE smooth)
|
|
|
67
135
|
}
|
|
68
136
|
|
|
69
137
|
static
|
|
70
|
-
VALUE
|
|
138
|
+
VALUE get_smooth(VALUE self)
|
|
71
139
|
{
|
|
72
140
|
CHECK;
|
|
73
141
|
return value(THIS->smooth());
|
|
@@ -120,10 +188,10 @@ VALUE families(VALUE self)
|
|
|
120
188
|
Hash hash;
|
|
121
189
|
for (const auto& family : Rays::get_font_families())
|
|
122
190
|
{
|
|
123
|
-
|
|
191
|
+
Value members = array(NULL, family.second.size());
|
|
124
192
|
for (const auto& member : family.second)
|
|
125
|
-
members.
|
|
126
|
-
hash.set(family.first.c_str(),
|
|
193
|
+
members.push(member.c_str());
|
|
194
|
+
hash.set(family.first.c_str(), members);
|
|
127
195
|
}
|
|
128
196
|
return hash;
|
|
129
197
|
}
|
|
@@ -153,11 +221,15 @@ Init_rays_font ()
|
|
|
153
221
|
rb_define_alloc_func(cFont, alloc);
|
|
154
222
|
rb_define_private_method(cFont, "initialize", RUBY_METHOD_FUNC(initialize), -1);
|
|
155
223
|
rb_define_private_method(cFont, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
|
156
|
-
rb_define_method(cFont, "name", RUBY_METHOD_FUNC(name),
|
|
224
|
+
rb_define_method(cFont, "name", RUBY_METHOD_FUNC(name), -1);
|
|
157
225
|
rb_define_method(cFont, "size=", RUBY_METHOD_FUNC(set_size), 1);
|
|
158
226
|
rb_define_method(cFont, "size", RUBY_METHOD_FUNC(size), 0);
|
|
227
|
+
rb_define_method(cFont, "weight=", RUBY_METHOD_FUNC(set_weight), 1);
|
|
228
|
+
rb_define_method(cFont, "weight", RUBY_METHOD_FUNC(weight), 0);
|
|
229
|
+
rb_define_method(cFont, "italic=", RUBY_METHOD_FUNC(set_italic), 1);
|
|
230
|
+
rb_define_method(cFont, "italic", RUBY_METHOD_FUNC(get_italic), 0);
|
|
159
231
|
rb_define_method(cFont, "smooth=", RUBY_METHOD_FUNC(set_smooth), 1);
|
|
160
|
-
rb_define_method(cFont, "smooth", RUBY_METHOD_FUNC(
|
|
232
|
+
rb_define_method(cFont, "smooth", RUBY_METHOD_FUNC(get_smooth), 0);
|
|
161
233
|
rb_define_method(cFont, "width", RUBY_METHOD_FUNC(width), 1);
|
|
162
234
|
rb_define_method(cFont, "height", RUBY_METHOD_FUNC(height), 0);
|
|
163
235
|
rb_define_method(cFont, "ascent", RUBY_METHOD_FUNC(ascent), 0);
|
|
@@ -165,6 +237,18 @@ Init_rays_font ()
|
|
|
165
237
|
rb_define_method(cFont, "leading", RUBY_METHOD_FUNC(leading), 0);
|
|
166
238
|
rb_define_module_function(cFont, "families", RUBY_METHOD_FUNC(families), 0);
|
|
167
239
|
rb_define_module_function(cFont, "load", RUBY_METHOD_FUNC(load), -1);
|
|
240
|
+
|
|
241
|
+
cFont.define_const("WEIGHT_MIN", Rays::Font::WEIGHT_MIN);
|
|
242
|
+
cFont.define_const("WEIGHT_THIN", Rays::Font::WEIGHT_THIN);
|
|
243
|
+
cFont.define_const("WEIGHT_EXTRALIGHT", Rays::Font::WEIGHT_EXTRALIGHT);
|
|
244
|
+
cFont.define_const("WEIGHT_LIGHT", Rays::Font::WEIGHT_LIGHT);
|
|
245
|
+
cFont.define_const("WEIGHT_NORMAL", Rays::Font::WEIGHT_NORMAL);
|
|
246
|
+
cFont.define_const("WEIGHT_MEDIUM", Rays::Font::WEIGHT_MEDIUM);
|
|
247
|
+
cFont.define_const("WEIGHT_SEMIBOLD", Rays::Font::WEIGHT_SEMIBOLD);
|
|
248
|
+
cFont.define_const("WEIGHT_BOLD", Rays::Font::WEIGHT_BOLD);
|
|
249
|
+
cFont.define_const("WEIGHT_EXTRABOLD", Rays::Font::WEIGHT_EXTRABOLD);
|
|
250
|
+
cFont.define_const("WEIGHT_BLACK", Rays::Font::WEIGHT_BLACK);
|
|
251
|
+
cFont.define_const("WEIGHT_MAX", Rays::Font::WEIGHT_MAX);
|
|
168
252
|
}
|
|
169
253
|
|
|
170
254
|
|
|
@@ -183,16 +267,30 @@ namespace Rucy
|
|
|
183
267
|
|
|
184
268
|
if (convert)
|
|
185
269
|
{
|
|
186
|
-
|
|
270
|
+
Value options = argc >= 1 && argv[argc - 1].is_hash() ? argv[--argc] : nil();
|
|
271
|
+
if (argc == 0 && !options)
|
|
187
272
|
return Rays::get_default_font();
|
|
188
273
|
|
|
189
|
-
|
|
190
|
-
bool
|
|
191
|
-
|
|
192
|
-
if (
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
274
|
+
int weight = Rays::Font::DEFAULT_WEIGHT;
|
|
275
|
+
bool italic = false;
|
|
276
|
+
bool smooth = true;
|
|
277
|
+
if (options)
|
|
278
|
+
{
|
|
279
|
+
RUCY_SYMBOL(weight_sym, "weight");
|
|
280
|
+
RUCY_SYMBOL(italic_sym, "italic");
|
|
281
|
+
RUCY_SYMBOL(smooth_sym, "smooth");
|
|
282
|
+
Value v;
|
|
283
|
+
if (!(v = options.get(weight_sym.value())).is_nil()) weight = to_font_weight(v);
|
|
284
|
+
if (!(v = options.get(italic_sym.value())).is_nil()) italic = to<bool>(v);
|
|
285
|
+
if (!(v = options.get(smooth_sym.value())).is_nil()) smooth = to<bool>(v);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (argc == 0 || argv->is_nil() || argv->is_s() || argv->is_sym())
|
|
289
|
+
{
|
|
290
|
+
const char* name = argc >= 1 && !argv[0].is_nil() ? argv[0].c_str() : NULL;
|
|
291
|
+
coord size = argc >= 2 ? to<coord>(argv[1]) : (coord) Rays::Font::DEFAULT_SIZE;
|
|
292
|
+
return Rays::Font(name, size, weight, italic, smooth);
|
|
293
|
+
}
|
|
196
294
|
}
|
|
197
295
|
|
|
198
296
|
if (argc != 1)
|
data/.doc/ext/rays/image.cpp
CHANGED
|
@@ -7,11 +7,31 @@
|
|
|
7
7
|
#include "defs.h"
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
RUCY_DEFINE_VALUE_TO(RAYS_EXPORT, Rays::Image)
|
|
11
|
+
|
|
12
|
+
namespace Rucy
|
|
13
|
+
{
|
|
14
|
+
|
|
15
|
+
// An image with a loader is read-only, so its ruby object is frozen
|
|
16
|
+
RAYS_EXPORT Value
|
|
17
|
+
value (const Rays::Image& obj)
|
|
18
|
+
{
|
|
19
|
+
Value v = new_type(get_ruby_class<Rays::Image>(), new Rays::Image(obj));
|
|
20
|
+
if (obj.loader()) v.freeze();
|
|
21
|
+
return v;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
RAYS_EXPORT Value
|
|
25
|
+
value (const Rays::Image* obj)
|
|
26
|
+
{
|
|
27
|
+
return obj ? value(*obj) : nil();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}// Rucy
|
|
11
31
|
|
|
12
32
|
#define THIS to<Rays::Image*>(self)
|
|
13
33
|
|
|
14
|
-
#define CHECK
|
|
34
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Image, self)
|
|
15
35
|
|
|
16
36
|
|
|
17
37
|
static
|
|
@@ -23,7 +43,7 @@ VALUE alloc(VALUE klass)
|
|
|
23
43
|
static
|
|
24
44
|
VALUE initialize(VALUE self, VALUE args, VALUE pixel_density, VALUE smooth)
|
|
25
45
|
{
|
|
26
|
-
|
|
46
|
+
RUCY_CHECK_PTR(Rays::Image, self);
|
|
27
47
|
|
|
28
48
|
size_t argc = args.size();
|
|
29
49
|
check_arg_count(__FILE__, __LINE__, "Image#initialize!", argc, 1, 2, 3);
|
|
@@ -51,7 +71,7 @@ VALUE initialize(VALUE self, VALUE args, VALUE pixel_density, VALUE smooth)
|
|
|
51
71
|
static
|
|
52
72
|
VALUE initialize_copy(VALUE self, VALUE obj)
|
|
53
73
|
{
|
|
54
|
-
|
|
74
|
+
RUCY_CHECK_PTR(Rays::Image, self);
|
|
55
75
|
|
|
56
76
|
*THIS = to<Rays::Image&>(obj).dup();
|
|
57
77
|
return self;
|
|
@@ -97,6 +117,7 @@ static
|
|
|
97
117
|
VALUE painter(VALUE self)
|
|
98
118
|
{
|
|
99
119
|
CHECK;
|
|
120
|
+
self.check_frozen();
|
|
100
121
|
return value(THIS->painter());
|
|
101
122
|
}
|
|
102
123
|
|
|
@@ -104,6 +125,7 @@ static
|
|
|
104
125
|
VALUE get_bitmap(VALUE self, VALUE modify)
|
|
105
126
|
{
|
|
106
127
|
CHECK;
|
|
128
|
+
if (modify) self.check_frozen();
|
|
107
129
|
return value(THIS->bitmap(modify));
|
|
108
130
|
}
|
|
109
131
|
|
|
@@ -111,6 +133,7 @@ static
|
|
|
111
133
|
VALUE set_smooth(VALUE self, VALUE smooth)
|
|
112
134
|
{
|
|
113
135
|
CHECK;
|
|
136
|
+
self.check_frozen();
|
|
114
137
|
THIS->set_smooth(smooth);
|
|
115
138
|
return smooth;
|
|
116
139
|
}
|
data/.doc/ext/rays/matrix.cpp
CHANGED
data/.doc/ext/rays/painter.cpp
CHANGED
|
@@ -17,7 +17,7 @@ RUCY_DEFINE_VALUE_FROM_TO(RAYS_EXPORT, Rays::Painter)
|
|
|
17
17
|
|
|
18
18
|
#define THIS to<Rays::Painter*>(self)
|
|
19
19
|
|
|
20
|
-
#define CHECK
|
|
20
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Painter, self)
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
static
|
|
@@ -162,7 +162,7 @@ VALUE point(VALUE self)
|
|
|
162
162
|
std::vector<Rays::Point> points;
|
|
163
163
|
get_points(&points, argc, argv);
|
|
164
164
|
|
|
165
|
-
THIS->points(
|
|
165
|
+
THIS->points(points.data(), points.size());
|
|
166
166
|
return self;
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -174,7 +174,7 @@ VALUE line(VALUE self, VALUE args, VALUE loop)
|
|
|
174
174
|
std::vector<Rays::Point> points;
|
|
175
175
|
get_points(&points, args.size(), args.as_array());
|
|
176
176
|
|
|
177
|
-
THIS->line(
|
|
177
|
+
THIS->line(points.data(), points.size(), loop);
|
|
178
178
|
return self;
|
|
179
179
|
}
|
|
180
180
|
|
|
@@ -232,7 +232,7 @@ VALUE curve(VALUE self, VALUE args, VALUE loop)
|
|
|
232
232
|
std::vector<Rays::Point> points;
|
|
233
233
|
get_points(&points, args.size(), args.as_array());
|
|
234
234
|
|
|
235
|
-
THIS->curve(
|
|
235
|
+
THIS->curve(points.data(), points.size(), loop);
|
|
236
236
|
return self;
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -247,7 +247,7 @@ VALUE bezier(VALUE self, VALUE args, VALUE loop)
|
|
|
247
247
|
std::vector<Rays::Point> points;
|
|
248
248
|
get_points(&points, args.size(), args.as_array());
|
|
249
249
|
|
|
250
|
-
THIS->bezier(
|
|
250
|
+
THIS->bezier(points.data(), points.size(), loop);
|
|
251
251
|
return self;
|
|
252
252
|
}
|
|
253
253
|
|
data/.doc/ext/rays/point.cpp
CHANGED
data/.doc/ext/rays/polygon.cpp
CHANGED
|
@@ -12,7 +12,7 @@ RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Polygon)
|
|
|
12
12
|
|
|
13
13
|
#define THIS to<Rays::Polygon*>(self)
|
|
14
14
|
|
|
15
|
-
#define CHECK
|
|
15
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Polygon, self)
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
static
|
|
@@ -156,7 +156,7 @@ VALUE op_add(VALUE self, VALUE obj)
|
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
return value(Rays::Polygon(
|
|
159
|
+
return value(Rays::Polygon(polylines.data(), polylines.size()));
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
static
|
|
@@ -402,14 +402,14 @@ namespace Rucy
|
|
|
402
402
|
polylines.reserve(argc);
|
|
403
403
|
for (int i = 0; i < argc; ++i)
|
|
404
404
|
polylines.emplace_back(to<Rays::Polyline&>(argv[i]));
|
|
405
|
-
return Rays::Polygon(
|
|
405
|
+
return Rays::Polygon(polylines.data(), polylines.size());
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
408
|
else if (argv->is_num() || argv->is_array())
|
|
409
409
|
{
|
|
410
410
|
std::vector<Rays::Point> points;
|
|
411
411
|
get_points(&points, argc, argv);
|
|
412
|
-
return Rays::Polygon(
|
|
412
|
+
return Rays::Polygon(points.data(), points.size());
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
|
data/.doc/ext/rays/polyline.cpp
CHANGED
|
@@ -13,7 +13,7 @@ RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Polyline)
|
|
|
13
13
|
|
|
14
14
|
#define THIS to<Rays::Polyline*>(self)
|
|
15
15
|
|
|
16
|
-
#define CHECK
|
|
16
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Polyline, self)
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
static
|
|
@@ -226,7 +226,7 @@ namespace Rucy
|
|
|
226
226
|
{
|
|
227
227
|
std::vector<Rays::Point> points;
|
|
228
228
|
get_points(&points, argc, argv);
|
|
229
|
-
return Rays::Polyline(
|
|
229
|
+
return Rays::Polyline(points.data(), points.size());
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
data/.doc/ext/rays/shader.cpp
CHANGED
|
@@ -10,7 +10,7 @@ RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Shader)
|
|
|
10
10
|
|
|
11
11
|
#define THIS to<Rays::Shader*>(self)
|
|
12
12
|
|
|
13
|
-
#define CHECK
|
|
13
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Shader, self)
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
static
|
|
@@ -91,7 +91,7 @@ VALUE initialize(VALUE self, VALUE
|
|
|
91
91
|
fragment_shader_source, VALUE vertex_shader_source, VALUE
|
|
92
92
|
builtin_variable_names, VALUE ignore_no_uniform_location_error)
|
|
93
93
|
{
|
|
94
|
-
|
|
94
|
+
RUCY_CHECK_PTR(Rays::Shader, self);
|
|
95
95
|
|
|
96
96
|
if (fragment_shader_source.is_nil())
|
|
97
97
|
argument_error(__FILE__, __LINE__);
|
|
@@ -9,52 +9,5 @@ permissions:
|
|
|
9
9
|
|
|
10
10
|
jobs:
|
|
11
11
|
release:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- name: ruby 3.2
|
|
16
|
-
uses: ruby/setup-ruby@v1
|
|
17
|
-
with:
|
|
18
|
-
ruby-version: 3.2
|
|
19
|
-
|
|
20
|
-
- name: checkout
|
|
21
|
-
uses: actions/checkout@v4
|
|
22
|
-
|
|
23
|
-
- name: setup gems
|
|
24
|
-
run: bundle install
|
|
25
|
-
|
|
26
|
-
- name: setup dependencies
|
|
27
|
-
run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
|
|
28
|
-
|
|
29
|
-
- name: packages
|
|
30
|
-
run: bundle exec rake packages
|
|
31
|
-
|
|
32
|
-
- name: setup zig
|
|
33
|
-
if: github.event.repository.name == 'reflex-terminal'
|
|
34
|
-
uses: mlugg/setup-zig@v2
|
|
35
|
-
with:
|
|
36
|
-
version: 0.16.0
|
|
37
|
-
|
|
38
|
-
- name: test
|
|
39
|
-
run: bundle exec rake test
|
|
40
|
-
|
|
41
|
-
- name: create gem
|
|
42
|
-
id: gem
|
|
43
|
-
run: |
|
|
44
|
-
bundle exec rake gem
|
|
45
|
-
echo path=$(ruby -e 'print Dir.glob("*.gem").first') >> $GITHUB_OUTPUT
|
|
46
|
-
|
|
47
|
-
- name: create github release
|
|
48
|
-
env:
|
|
49
|
-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
50
|
-
run: ruby -I.github/workflows -rutils -e 'release(*ARGV)' ./${{ steps.gem.outputs.path }}
|
|
51
|
-
|
|
52
|
-
- name: upload to rubygems
|
|
53
|
-
env:
|
|
54
|
-
GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
|
|
55
|
-
run: |
|
|
56
|
-
mkdir -p $HOME/.gem
|
|
57
|
-
touch $HOME/.gem/credentials
|
|
58
|
-
chmod 0600 $HOME/.gem/credentials
|
|
59
|
-
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
60
|
-
bundle exec rake upload
|
|
12
|
+
uses: xord/xot/.github/workflows/release-gem.yml@master
|
|
13
|
+
secrets: inherit
|