rays 0.3.3 → 0.3.5
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/color.cpp +73 -54
- data/.doc/ext/rays/painter.cpp +8 -2
- data/.doc/ext/rays/rays.cpp +3 -3
- data/.github/PULL_REQUEST_TEMPLATE.md +12 -0
- data/CONTRIBUTING.md +7 -0
- data/ChangeLog.md +21 -0
- data/README.md +45 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/ext/rays/color.cpp +73 -54
- data/ext/rays/defs.h +3 -0
- data/ext/rays/painter.cpp +8 -2
- data/ext/rays/rays.cpp +3 -3
- data/include/rays/defs.h +3 -3
- data/rays.gemspec +4 -2
- data/src/color.cpp +1 -1
- data/src/coord.h +1 -2
- data/src/glm.h +18 -0
- data/src/matrix.cpp +0 -2
- data/src/matrix.h +1 -1
- data/src/painter.cpp +51 -40
- data/src/point.cpp +1 -2
- data/src/polygon.cpp +2 -2
- data/src/shader_source.cpp +2 -0
- data/src/util.cpp +1 -1
- data/test/test_painter.rb +10 -8
- metadata +15 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a66614f6ea052aeafe775d0bd3096b06103ea8dbc08a94ee60c7172f726ff745
|
4
|
+
data.tar.gz: c6020c9ccf843bbf051660d851ed494d032a9a4db564d774de94ab67d906ad44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3f366d4930acff032af41d0eb8bd96cc3e57f6e48028a2279b6f40d0cee9773bd6fb596c0a5131cad07abc4f7fe1373fecd9297133c11e3ae889988e291f845
|
7
|
+
data.tar.gz: 2fd35000dbdb686a54f09653a4a97ed599ac16432b1ab801f0bfb7c07bcfd1d36a19bb39393b78a4c6b09d1fd8c48a81aec2a7f4140816a4f26ffca35ca7365f
|
data/.doc/ext/rays/color.cpp
CHANGED
@@ -13,6 +13,79 @@ RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Color)
|
|
13
13
|
#define CHECK RUCY_CHECK_OBJ(Rays::Color, self)
|
14
14
|
|
15
15
|
|
16
|
+
static const char* NIL_COLOR_NO = "no";
|
17
|
+
static const char* NIL_COLOR_NONE = "none";
|
18
|
+
|
19
|
+
typedef std::map<Rays::String, Rays::Color> ColorMap;
|
20
|
+
|
21
|
+
static ColorMap&
|
22
|
+
get_color_map ()
|
23
|
+
{
|
24
|
+
static ColorMap map;
|
25
|
+
if (map.empty())
|
26
|
+
{
|
27
|
+
map[NIL_COLOR_NO] =
|
28
|
+
map[NIL_COLOR_NONE] =
|
29
|
+
map["transp"] =
|
30
|
+
map["transparent"] = Rays::gray(0, 0);
|
31
|
+
|
32
|
+
map["black"] = Rays::rgb8( 0, 0, 0);
|
33
|
+
map["white"] = Rays::rgb8(255, 241, 232);
|
34
|
+
map["gray"] =
|
35
|
+
map["lightgray"] = Rays::rgb8(194, 195, 199);
|
36
|
+
map["darkgray"] = Rays::rgb8( 95, 87, 79);
|
37
|
+
map["brown"] = Rays::rgb8(171, 82, 54);
|
38
|
+
map["red"] = Rays::rgb8(255, 0, 77);
|
39
|
+
map["orange"] = Rays::rgb8(255, 163, 0);
|
40
|
+
map["yellow"] = Rays::rgb8(255, 236, 39);
|
41
|
+
map["green"] = Rays::rgb8( 0, 228, 54);
|
42
|
+
map["darkgreen"] = Rays::rgb8( 0, 135, 81);
|
43
|
+
map["blue"] = Rays::rgb8( 41, 173, 255);
|
44
|
+
map["darkblue"] = Rays::rgb8( 29, 43, 83);
|
45
|
+
map["indigo"] = Rays::rgb8(131, 118, 156);
|
46
|
+
map["pink"] = Rays::rgb8(255, 119, 168);
|
47
|
+
map["peach"] = Rays::rgb8(255, 204, 170);
|
48
|
+
map["darkpurple"] = Rays::rgb8(126, 37, 83);
|
49
|
+
}
|
50
|
+
return map;
|
51
|
+
}
|
52
|
+
|
53
|
+
static const Rays::String
|
54
|
+
to_color_name (const char* name)
|
55
|
+
{
|
56
|
+
return Rays::String(name).downcase();
|
57
|
+
}
|
58
|
+
|
59
|
+
static const Rays::Color&
|
60
|
+
find_color (const char* name)
|
61
|
+
{
|
62
|
+
assert(name);
|
63
|
+
|
64
|
+
const ColorMap& map = get_color_map();
|
65
|
+
ColorMap::const_iterator it = map.find(to_color_name(name));
|
66
|
+
if (it == map.end())
|
67
|
+
argument_error(__FILE__, __LINE__, "color '%s' is not found.", name);
|
68
|
+
|
69
|
+
return it->second;
|
70
|
+
}
|
71
|
+
|
72
|
+
bool
|
73
|
+
is_nil_color (Value value)
|
74
|
+
{
|
75
|
+
if (value.is_nil())
|
76
|
+
return true;
|
77
|
+
|
78
|
+
const char* name = NULL;
|
79
|
+
if (value.is_s()) name = value.as_s();
|
80
|
+
if (value.is_sym()) name = value.as_s(true);
|
81
|
+
if (!name) return false;
|
82
|
+
|
83
|
+
return
|
84
|
+
strcmp(name, NIL_COLOR_NO) == 0 ||
|
85
|
+
strcmp(name, NIL_COLOR_NONE) == 0;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
16
89
|
static
|
17
90
|
VALUE alloc(VALUE klass)
|
18
91
|
{
|
@@ -113,60 +186,6 @@ VALUE to_hsv(VALUE self)
|
|
113
186
|
return array(h, s, v, THIS->alpha);
|
114
187
|
}
|
115
188
|
|
116
|
-
|
117
|
-
typedef std::map<Rays::String, Rays::Color> ColorMap;
|
118
|
-
|
119
|
-
static ColorMap&
|
120
|
-
get_color_map ()
|
121
|
-
{
|
122
|
-
static ColorMap map;
|
123
|
-
if (map.empty())
|
124
|
-
{
|
125
|
-
map["no"] =
|
126
|
-
map["none"] =
|
127
|
-
map["transp"] =
|
128
|
-
map["transparent"] = Rays::gray(0, 0);
|
129
|
-
|
130
|
-
map["black"] = Rays::rgb8( 0, 0, 0);
|
131
|
-
map["white"] = Rays::rgb8(255, 241, 232);
|
132
|
-
map["gray"] =
|
133
|
-
map["lightgray"] = Rays::rgb8(194, 195, 199);
|
134
|
-
map["darkgray"] = Rays::rgb8( 95, 87, 79);
|
135
|
-
map["brown"] = Rays::rgb8(171, 82, 54);
|
136
|
-
map["red"] = Rays::rgb8(255, 0, 77);
|
137
|
-
map["orange"] = Rays::rgb8(255, 163, 0);
|
138
|
-
map["yellow"] = Rays::rgb8(255, 236, 39);
|
139
|
-
map["green"] = Rays::rgb8( 0, 228, 54);
|
140
|
-
map["darkgreen"] = Rays::rgb8( 0, 135, 81);
|
141
|
-
map["blue"] = Rays::rgb8( 41, 173, 255);
|
142
|
-
map["darkblue"] = Rays::rgb8( 29, 43, 83);
|
143
|
-
map["indigo"] = Rays::rgb8(131, 118, 156);
|
144
|
-
map["pink"] = Rays::rgb8(255, 119, 168);
|
145
|
-
map["peach"] = Rays::rgb8(255, 204, 170);
|
146
|
-
map["darkpurple"] = Rays::rgb8(126, 37, 83);
|
147
|
-
}
|
148
|
-
return map;
|
149
|
-
}
|
150
|
-
|
151
|
-
static const Rays::String
|
152
|
-
to_color_name (const char* name)
|
153
|
-
{
|
154
|
-
return Rays::String(name).downcase();
|
155
|
-
}
|
156
|
-
|
157
|
-
static const Rays::Color&
|
158
|
-
find_color (const char* name)
|
159
|
-
{
|
160
|
-
assert(name);
|
161
|
-
|
162
|
-
const ColorMap& map = get_color_map();
|
163
|
-
ColorMap::const_iterator it = map.find(to_color_name(name));
|
164
|
-
if (it == map.end())
|
165
|
-
argument_error(__FILE__, __LINE__, "color '%s' is not found.", name);
|
166
|
-
|
167
|
-
return it->second;
|
168
|
-
}
|
169
|
-
|
170
189
|
static
|
171
190
|
VALUE hsv(VALUE self)
|
172
191
|
{
|
data/.doc/ext/rays/painter.cpp
CHANGED
@@ -338,7 +338,10 @@ static
|
|
338
338
|
VALUE set_fill(VALUE self)
|
339
339
|
{
|
340
340
|
CHECK;
|
341
|
-
|
341
|
+
if (argc >= 1 && is_nil_color(argv[0]))
|
342
|
+
THIS->no_fill();
|
343
|
+
else
|
344
|
+
THIS->set_fill(to<Rays::Color>(argc, argv));
|
342
345
|
return self;
|
343
346
|
}
|
344
347
|
|
@@ -361,7 +364,10 @@ static
|
|
361
364
|
VALUE set_stroke(VALUE self)
|
362
365
|
{
|
363
366
|
CHECK;
|
364
|
-
|
367
|
+
if (argc >= 1 && is_nil_color(argv[0]))
|
368
|
+
THIS->no_stroke();
|
369
|
+
else
|
370
|
+
THIS->set_stroke(to<Rays::Color>(argc, argv));
|
365
371
|
return self;
|
366
372
|
}
|
367
373
|
|
data/.doc/ext/rays/rays.cpp
CHANGED
@@ -135,7 +135,7 @@ namespace Rucy
|
|
135
135
|
int type = value_to<int>(*argv, convert);
|
136
136
|
if (type < 0)
|
137
137
|
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
|
138
|
-
if (type >= Rays::
|
138
|
+
if (type >= Rays::CAP_TYPE_MAX)
|
139
139
|
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
|
140
140
|
|
141
141
|
return (Rays::CapType) type;
|
@@ -168,7 +168,7 @@ namespace Rucy
|
|
168
168
|
int type = value_to<int>(*argv, convert);
|
169
169
|
if (type < 0)
|
170
170
|
argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
|
171
|
-
if (type >= Rays::
|
171
|
+
if (type >= Rays::JOIN_TYPE_MAX)
|
172
172
|
argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
|
173
173
|
|
174
174
|
return (Rays::JoinType) type;
|
@@ -201,7 +201,7 @@ namespace Rucy
|
|
201
201
|
int mode = value_to<int>(*argv, convert);
|
202
202
|
if (mode < 0)
|
203
203
|
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
204
|
-
if (mode >= Rays::
|
204
|
+
if (mode >= Rays::BLEND_MODE_MAX)
|
205
205
|
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
206
206
|
|
207
207
|
return (Rays::BlendMode) mode;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
## Pull Requests Not Accepted 🚫
|
2
|
+
|
3
|
+
Thank you for your interest in contributing!
|
4
|
+
However, this repository does not accept pull requests directly.
|
5
|
+
|
6
|
+
### Where to Contribute?
|
7
|
+
|
8
|
+
Please submit your changes to the [xord/all](https://github.com/xord/all) monorepo, which serves as the primary repository for all our main libraries.
|
9
|
+
|
10
|
+
For more details, please refer to our [contribution guidelines](../CONTRIBUTING.md).
|
11
|
+
|
12
|
+
Thanks for your understanding! 🙌
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Contribution Guide
|
2
|
+
|
3
|
+
Thank you for your interest in contributing!
|
4
|
+
However, this repository does not accept pull requests.
|
5
|
+
Instead, please submit your changes to the [xord/all](https://github.com/xord/all) monorepo, which serves as the primary repository for all our main libraries.
|
6
|
+
|
7
|
+
For any questions, feel free to open an issue.
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
# rays ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.3.5] - 2025-03-24
|
5
|
+
|
6
|
+
- Add PULL_REQUEST_TEMPLATE.md
|
7
|
+
- Add CONTRIBUTING.md
|
8
|
+
|
9
|
+
- Fix shader error on iOS
|
10
|
+
|
11
|
+
|
12
|
+
## [v0.3.4] - 2025-03-07
|
13
|
+
|
14
|
+
- Add msys2_mingw_dependencies for openal and glew
|
15
|
+
|
16
|
+
- Update glm library
|
17
|
+
- Painter: no stroke by default
|
18
|
+
- Passing :no or :none to Painter::set_fill()/set_stroke() is equivalent to calling no_fill()/no_stroke()
|
19
|
+
- BLEND_REPLACE disables fill/stroke only on calling no_fill/no_stroke (alpha 0 does not mean to no_fill/no_stroke)
|
20
|
+
|
21
|
+
- Fix a bug that both fill and stroke were drawn even with blend_mode REPLACE, no_fill, and no_stroke combinations
|
22
|
+
- Fix problem of not drawing when BLEND_REPLACE is combined with alpha 0
|
23
|
+
|
24
|
+
|
4
25
|
## [v0.3.3] - 2025-01-23
|
5
26
|
|
6
27
|
- Add '#version 120' line to shader source
|
data/README.md
CHANGED
@@ -1,4 +1,47 @@
|
|
1
|
-
|
2
1
|
# Rays - A Drawing Engine using OpenGL.
|
3
2
|
|
4
|
-
|
3
|
+

|
4
|
+

|
5
|
+

|
6
|
+
|
7
|
+
## ⚠️ Notice
|
8
|
+
|
9
|
+
This repository is a read-only mirror of our monorepo.
|
10
|
+
We do not accept pull requests or direct contributions here.
|
11
|
+
|
12
|
+
### 🔄 Where to Contribute?
|
13
|
+
|
14
|
+
All development happens in our [xord/all](https://github.com/xord/all) monorepo, which contains all our main libraries.
|
15
|
+
If you'd like to contribute, please submit your changes there.
|
16
|
+
|
17
|
+
For more details, check out our [Contribution Guidelines](./CONTRIBUTING.md).
|
18
|
+
|
19
|
+
Thanks for your support! 🙌
|
20
|
+
|
21
|
+
## 🚀 About
|
22
|
+
|
23
|
+
**Rays** is a drawing engine that utilizes OpenGL for 2D rendering.
|
24
|
+
|
25
|
+
It is designed to provide efficient graphics capabilities, making it ideal for creating complex visualizations and graphics applications.
|
26
|
+
|
27
|
+
## 📦 Installation
|
28
|
+
|
29
|
+
Add this line to your Gemfile:
|
30
|
+
```ruby
|
31
|
+
$ gem 'rays'
|
32
|
+
```
|
33
|
+
|
34
|
+
Then, install gem:
|
35
|
+
```bash
|
36
|
+
$ bundle install
|
37
|
+
```
|
38
|
+
|
39
|
+
Or install it directly:
|
40
|
+
```bash
|
41
|
+
$ gem install rays
|
42
|
+
```
|
43
|
+
|
44
|
+
## 📜 License
|
45
|
+
|
46
|
+
**Rays** is licensed under the MIT License.
|
47
|
+
See the [LICENSE](./LICENSE) file for details.
|
data/Rakefile
CHANGED
@@ -17,7 +17,7 @@ TESTS_ALONE = ['test/test_rays_init.rb']
|
|
17
17
|
install_packages win32: %w[MINGW_PACKAGE_PREFIX-glew]
|
18
18
|
|
19
19
|
use_external_library 'https://github.com/g-truc/glm',
|
20
|
-
tag: '0.
|
20
|
+
tag: '1.0.1',
|
21
21
|
srcdirs: 'NOSRC'
|
22
22
|
|
23
23
|
use_external_library 'https://github.com/skyrpex/clipper',
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
data/ext/rays/color.cpp
CHANGED
@@ -13,6 +13,79 @@ RUCY_DEFINE_VALUE_OR_ARRAY_FROM_TO(RAYS_EXPORT, Rays::Color)
|
|
13
13
|
#define CHECK RUCY_CHECK_OBJ(Rays::Color, self)
|
14
14
|
|
15
15
|
|
16
|
+
static const char* NIL_COLOR_NO = "no";
|
17
|
+
static const char* NIL_COLOR_NONE = "none";
|
18
|
+
|
19
|
+
typedef std::map<Rays::String, Rays::Color> ColorMap;
|
20
|
+
|
21
|
+
static ColorMap&
|
22
|
+
get_color_map ()
|
23
|
+
{
|
24
|
+
static ColorMap map;
|
25
|
+
if (map.empty())
|
26
|
+
{
|
27
|
+
map[NIL_COLOR_NO] =
|
28
|
+
map[NIL_COLOR_NONE] =
|
29
|
+
map["transp"] =
|
30
|
+
map["transparent"] = Rays::gray(0, 0);
|
31
|
+
|
32
|
+
map["black"] = Rays::rgb8( 0, 0, 0);
|
33
|
+
map["white"] = Rays::rgb8(255, 241, 232);
|
34
|
+
map["gray"] =
|
35
|
+
map["lightgray"] = Rays::rgb8(194, 195, 199);
|
36
|
+
map["darkgray"] = Rays::rgb8( 95, 87, 79);
|
37
|
+
map["brown"] = Rays::rgb8(171, 82, 54);
|
38
|
+
map["red"] = Rays::rgb8(255, 0, 77);
|
39
|
+
map["orange"] = Rays::rgb8(255, 163, 0);
|
40
|
+
map["yellow"] = Rays::rgb8(255, 236, 39);
|
41
|
+
map["green"] = Rays::rgb8( 0, 228, 54);
|
42
|
+
map["darkgreen"] = Rays::rgb8( 0, 135, 81);
|
43
|
+
map["blue"] = Rays::rgb8( 41, 173, 255);
|
44
|
+
map["darkblue"] = Rays::rgb8( 29, 43, 83);
|
45
|
+
map["indigo"] = Rays::rgb8(131, 118, 156);
|
46
|
+
map["pink"] = Rays::rgb8(255, 119, 168);
|
47
|
+
map["peach"] = Rays::rgb8(255, 204, 170);
|
48
|
+
map["darkpurple"] = Rays::rgb8(126, 37, 83);
|
49
|
+
}
|
50
|
+
return map;
|
51
|
+
}
|
52
|
+
|
53
|
+
static const Rays::String
|
54
|
+
to_color_name (const char* name)
|
55
|
+
{
|
56
|
+
return Rays::String(name).downcase();
|
57
|
+
}
|
58
|
+
|
59
|
+
static const Rays::Color&
|
60
|
+
find_color (const char* name)
|
61
|
+
{
|
62
|
+
assert(name);
|
63
|
+
|
64
|
+
const ColorMap& map = get_color_map();
|
65
|
+
ColorMap::const_iterator it = map.find(to_color_name(name));
|
66
|
+
if (it == map.end())
|
67
|
+
argument_error(__FILE__, __LINE__, "color '%s' is not found.", name);
|
68
|
+
|
69
|
+
return it->second;
|
70
|
+
}
|
71
|
+
|
72
|
+
bool
|
73
|
+
is_nil_color (Value value)
|
74
|
+
{
|
75
|
+
if (value.is_nil())
|
76
|
+
return true;
|
77
|
+
|
78
|
+
const char* name = NULL;
|
79
|
+
if (value.is_s()) name = value.as_s();
|
80
|
+
if (value.is_sym()) name = value.as_s(true);
|
81
|
+
if (!name) return false;
|
82
|
+
|
83
|
+
return
|
84
|
+
strcmp(name, NIL_COLOR_NO) == 0 ||
|
85
|
+
strcmp(name, NIL_COLOR_NONE) == 0;
|
86
|
+
}
|
87
|
+
|
88
|
+
|
16
89
|
static
|
17
90
|
RUCY_DEF_ALLOC(alloc, klass)
|
18
91
|
{
|
@@ -125,60 +198,6 @@ RUCY_DEF0(to_hsv)
|
|
125
198
|
}
|
126
199
|
RUCY_END
|
127
200
|
|
128
|
-
|
129
|
-
typedef std::map<Rays::String, Rays::Color> ColorMap;
|
130
|
-
|
131
|
-
static ColorMap&
|
132
|
-
get_color_map ()
|
133
|
-
{
|
134
|
-
static ColorMap map;
|
135
|
-
if (map.empty())
|
136
|
-
{
|
137
|
-
map["no"] =
|
138
|
-
map["none"] =
|
139
|
-
map["transp"] =
|
140
|
-
map["transparent"] = Rays::gray(0, 0);
|
141
|
-
|
142
|
-
map["black"] = Rays::rgb8( 0, 0, 0);
|
143
|
-
map["white"] = Rays::rgb8(255, 241, 232);
|
144
|
-
map["gray"] =
|
145
|
-
map["lightgray"] = Rays::rgb8(194, 195, 199);
|
146
|
-
map["darkgray"] = Rays::rgb8( 95, 87, 79);
|
147
|
-
map["brown"] = Rays::rgb8(171, 82, 54);
|
148
|
-
map["red"] = Rays::rgb8(255, 0, 77);
|
149
|
-
map["orange"] = Rays::rgb8(255, 163, 0);
|
150
|
-
map["yellow"] = Rays::rgb8(255, 236, 39);
|
151
|
-
map["green"] = Rays::rgb8( 0, 228, 54);
|
152
|
-
map["darkgreen"] = Rays::rgb8( 0, 135, 81);
|
153
|
-
map["blue"] = Rays::rgb8( 41, 173, 255);
|
154
|
-
map["darkblue"] = Rays::rgb8( 29, 43, 83);
|
155
|
-
map["indigo"] = Rays::rgb8(131, 118, 156);
|
156
|
-
map["pink"] = Rays::rgb8(255, 119, 168);
|
157
|
-
map["peach"] = Rays::rgb8(255, 204, 170);
|
158
|
-
map["darkpurple"] = Rays::rgb8(126, 37, 83);
|
159
|
-
}
|
160
|
-
return map;
|
161
|
-
}
|
162
|
-
|
163
|
-
static const Rays::String
|
164
|
-
to_color_name (const char* name)
|
165
|
-
{
|
166
|
-
return Rays::String(name).downcase();
|
167
|
-
}
|
168
|
-
|
169
|
-
static const Rays::Color&
|
170
|
-
find_color (const char* name)
|
171
|
-
{
|
172
|
-
assert(name);
|
173
|
-
|
174
|
-
const ColorMap& map = get_color_map();
|
175
|
-
ColorMap::const_iterator it = map.find(to_color_name(name));
|
176
|
-
if (it == map.end())
|
177
|
-
argument_error(__FILE__, __LINE__, "color '%s' is not found.", name);
|
178
|
-
|
179
|
-
return it->second;
|
180
|
-
}
|
181
|
-
|
182
201
|
static
|
183
202
|
RUCY_DEFN(hsv)
|
184
203
|
{
|
data/ext/rays/defs.h
CHANGED
@@ -19,6 +19,9 @@ using namespace Rucy;
|
|
19
19
|
using Rays::coord;
|
20
20
|
|
21
21
|
|
22
|
+
bool is_nil_color (Value value);
|
23
|
+
|
24
|
+
|
22
25
|
void get_points (std::vector<Rays::Point>* points, int argc, const Value* argv);
|
23
26
|
|
24
27
|
void get_colors (std::vector<Rays::Color>* colors, int argc, const Value* argv);
|
data/ext/rays/painter.cpp
CHANGED
@@ -359,7 +359,10 @@ static
|
|
359
359
|
RUCY_DEFN(set_fill)
|
360
360
|
{
|
361
361
|
CHECK;
|
362
|
-
|
362
|
+
if (argc >= 1 && is_nil_color(argv[0]))
|
363
|
+
THIS->no_fill();
|
364
|
+
else
|
365
|
+
THIS->set_fill(to<Rays::Color>(argc, argv));
|
363
366
|
return self;
|
364
367
|
}
|
365
368
|
RUCY_END
|
@@ -385,7 +388,10 @@ static
|
|
385
388
|
RUCY_DEFN(set_stroke)
|
386
389
|
{
|
387
390
|
CHECK;
|
388
|
-
|
391
|
+
if (argc >= 1 && is_nil_color(argv[0]))
|
392
|
+
THIS->no_stroke();
|
393
|
+
else
|
394
|
+
THIS->set_stroke(to<Rays::Color>(argc, argv));
|
389
395
|
return self;
|
390
396
|
}
|
391
397
|
RUCY_END
|
data/ext/rays/rays.cpp
CHANGED
@@ -138,7 +138,7 @@ namespace Rucy
|
|
138
138
|
int type = value_to<int>(*argv, convert);
|
139
139
|
if (type < 0)
|
140
140
|
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
|
141
|
-
if (type >= Rays::
|
141
|
+
if (type >= Rays::CAP_TYPE_MAX)
|
142
142
|
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
|
143
143
|
|
144
144
|
return (Rays::CapType) type;
|
@@ -171,7 +171,7 @@ namespace Rucy
|
|
171
171
|
int type = value_to<int>(*argv, convert);
|
172
172
|
if (type < 0)
|
173
173
|
argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
|
174
|
-
if (type >= Rays::
|
174
|
+
if (type >= Rays::JOIN_TYPE_MAX)
|
175
175
|
argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
|
176
176
|
|
177
177
|
return (Rays::JoinType) type;
|
@@ -204,7 +204,7 @@ namespace Rucy
|
|
204
204
|
int mode = value_to<int>(*argv, convert);
|
205
205
|
if (mode < 0)
|
206
206
|
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
207
|
-
if (mode >= Rays::
|
207
|
+
if (mode >= Rays::BLEND_MODE_MAX)
|
208
208
|
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
209
209
|
|
210
210
|
return (Rays::BlendMode) mode;
|
data/include/rays/defs.h
CHANGED
@@ -39,7 +39,7 @@ namespace Rays
|
|
39
39
|
|
40
40
|
CAP_SQUARE,
|
41
41
|
|
42
|
-
|
42
|
+
CAP_TYPE_MAX,
|
43
43
|
|
44
44
|
CAP_DEFAULT = CAP_BUTT
|
45
45
|
|
@@ -55,7 +55,7 @@ namespace Rays
|
|
55
55
|
|
56
56
|
JOIN_SQUARE,
|
57
57
|
|
58
|
-
|
58
|
+
JOIN_TYPE_MAX,
|
59
59
|
|
60
60
|
JOIN_DEFAULT = JOIN_MITER,
|
61
61
|
JOIN_DEFAULT_MITER_LIMIT = 2
|
@@ -84,7 +84,7 @@ namespace Rays
|
|
84
84
|
|
85
85
|
BLEND_REPLACE,
|
86
86
|
|
87
|
-
|
87
|
+
BLEND_MODE_MAX
|
88
88
|
|
89
89
|
};// BlendMode
|
90
90
|
|
data/rays.gemspec
CHANGED
@@ -25,8 +25,8 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.platform = Gem::Platform::RUBY
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
27
27
|
|
28
|
-
s.add_dependency 'xot', '~> 0.3.
|
29
|
-
s.add_dependency 'rucy', '~> 0.3.
|
28
|
+
s.add_dependency 'xot', '~> 0.3.5', '>= 0.3.5'
|
29
|
+
s.add_dependency 'rucy', '~> 0.3.5', '>= 0.3.5'
|
30
30
|
|
31
31
|
s.files = `git ls-files`.split $/
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
@@ -34,5 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.extra_rdoc_files = rdocs.to_a
|
35
35
|
s.has_rdoc = true
|
36
36
|
|
37
|
+
s.metadata['msys2_mingw_dependencies'] = 'glew'
|
38
|
+
|
37
39
|
s.extensions << 'Rakefile'
|
38
40
|
end
|
data/src/color.cpp
CHANGED
data/src/coord.h
CHANGED
data/src/glm.h
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
// -*- c++ -*-
|
2
|
+
#pragma once
|
3
|
+
#ifndef __RAYS_SRC_GLM_H__
|
4
|
+
#define __RAYS_SRC_GLM_H__
|
5
|
+
|
6
|
+
|
7
|
+
#define GLM_ENABLE_EXPERIMENTAL
|
8
|
+
#include <glm/vec2.hpp>
|
9
|
+
#include <glm/vec3.hpp>
|
10
|
+
#include <glm/mat4x4.hpp>
|
11
|
+
#include <glm/geometric.hpp>
|
12
|
+
#include <glm/gtc/matrix_transform.hpp>
|
13
|
+
#include <glm/gtc/noise.hpp>
|
14
|
+
#include <glm/gtx/color_space.hpp>
|
15
|
+
#include <glm/gtx/rotate_vector.hpp>
|
16
|
+
|
17
|
+
|
18
|
+
#endif//EOH
|
data/src/matrix.cpp
CHANGED
data/src/matrix.h
CHANGED
data/src/painter.cpp
CHANGED
@@ -8,13 +8,13 @@
|
|
8
8
|
#include <vector>
|
9
9
|
#include <algorithm>
|
10
10
|
#include <functional>
|
11
|
-
#include <glm/gtc/matrix_transform.hpp>
|
12
11
|
#include "rays/exception.h"
|
13
12
|
#include "rays/point.h"
|
14
13
|
#include "rays/bounds.h"
|
15
14
|
#include "rays/color.h"
|
16
15
|
#include "rays/debug.h"
|
17
16
|
#include "opengl.h"
|
17
|
+
#include "glm.h"
|
18
18
|
#include "matrix.h"
|
19
19
|
#include "polygon.h"
|
20
20
|
#include "bitmap.h"
|
@@ -37,8 +37,7 @@ namespace Rays
|
|
37
37
|
FILL = 0,
|
38
38
|
STROKE,
|
39
39
|
|
40
|
-
|
41
|
-
COLOR_TYPE_BEGIN = 0
|
40
|
+
COLOR_TYPE_MAX
|
42
41
|
|
43
42
|
};// ColorType
|
44
43
|
|
@@ -46,7 +45,9 @@ namespace Rays
|
|
46
45
|
struct State
|
47
46
|
{
|
48
47
|
|
49
|
-
Color background, colors[
|
48
|
+
Color background, colors[COLOR_TYPE_MAX];
|
49
|
+
|
50
|
+
bool nocolors[COLOR_TYPE_MAX];
|
50
51
|
|
51
52
|
coord stroke_width;
|
52
53
|
|
@@ -78,28 +79,43 @@ namespace Rays
|
|
78
79
|
|
79
80
|
void init ()
|
80
81
|
{
|
81
|
-
background
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
82
|
+
background .reset(0, 0);
|
83
|
+
colors[FILL] .reset(1, 1);
|
84
|
+
colors[STROKE] .reset(1, 0);
|
85
|
+
nocolors[FILL] = false;
|
86
|
+
nocolors[STROKE] = true;
|
87
|
+
stroke_width = 0;
|
88
|
+
stroke_outset = 0;
|
89
|
+
stroke_cap = CAP_DEFAULT;
|
90
|
+
stroke_join = JOIN_DEFAULT;
|
91
|
+
miter_limit = JOIN_DEFAULT_MITER_LIMIT;
|
92
|
+
nsegment = 0;
|
93
|
+
line_height = -1;
|
94
|
+
blend_mode = BLEND_NORMAL;
|
95
|
+
clip .reset(-1);
|
96
|
+
font = get_default_font();
|
97
|
+
texture = Image();
|
98
|
+
texcoord_mode = TEXCOORD_IMAGE;
|
99
|
+
texcoord_wrap = TEXCOORD_CLAMP;
|
100
|
+
shader = Shader();
|
101
|
+
}
|
102
|
+
|
103
|
+
bool get_color (Color* color, ColorType type) const
|
104
|
+
{
|
105
|
+
const Color& c = colors[type];
|
106
|
+
if (blend_mode == BLEND_REPLACE ? nocolors[type] : !c)
|
107
|
+
return false;
|
108
|
+
|
109
|
+
*color = c;
|
110
|
+
return true;
|
98
111
|
}
|
99
112
|
|
100
|
-
bool has_color ()
|
113
|
+
bool has_color () const
|
101
114
|
{
|
102
|
-
|
115
|
+
if (blend_mode == BLEND_REPLACE)
|
116
|
+
return !nocolors[FILL] || !nocolors[STROKE];
|
117
|
+
else
|
118
|
+
return colors[FILL] || colors[STROKE];
|
103
119
|
}
|
104
120
|
|
105
121
|
};// State
|
@@ -314,15 +330,6 @@ namespace Rays
|
|
314
330
|
OpenGL_check_error(__FILE__, __LINE__);
|
315
331
|
}
|
316
332
|
|
317
|
-
bool get_color (Color* color, ColorType type)
|
318
|
-
{
|
319
|
-
const Color& c = state.colors[type];
|
320
|
-
if (!c) return false;
|
321
|
-
|
322
|
-
*color = c;
|
323
|
-
return true;
|
324
|
-
}
|
325
|
-
|
326
333
|
void draw (
|
327
334
|
GLenum mode, const Color* color,
|
328
335
|
const Coord3* points, size_t npoints,
|
@@ -861,13 +868,13 @@ namespace Rays
|
|
861
868
|
|
862
869
|
Color color;
|
863
870
|
|
864
|
-
if (self->get_color(&color, FILL))
|
871
|
+
if (self->state.get_color(&color, FILL))
|
865
872
|
{
|
866
873
|
Polygon_fill(polygon, painter, color);
|
867
874
|
debug_draw_triangulation(painter, polygon, color);
|
868
875
|
}
|
869
876
|
|
870
|
-
if (self->get_color(&color, STROKE))
|
877
|
+
if (self->state.get_color(&color, STROKE))
|
871
878
|
Polygon_stroke(polygon, painter, color);
|
872
879
|
|
873
880
|
if (backup)
|
@@ -1098,12 +1105,12 @@ namespace Rays
|
|
1098
1105
|
TextureInfo texinfo(texture, src_x, src_y, src_x + src_w, src_y + src_h);
|
1099
1106
|
|
1100
1107
|
Color color;
|
1101
|
-
for (int type =
|
1108
|
+
for (int type = 0; type < COLOR_TYPE_MAX; ++type)
|
1102
1109
|
{
|
1103
1110
|
if ((nofill && type == FILL) || (nostroke && type == STROKE))
|
1104
1111
|
continue;
|
1105
1112
|
|
1106
|
-
if (!painter->self->get_color(&color, (ColorType) type))
|
1113
|
+
if (!painter->self->state.get_color(&color, (ColorType) type))
|
1107
1114
|
continue;
|
1108
1115
|
|
1109
1116
|
painter->self->draw(
|
@@ -1392,13 +1399,15 @@ namespace Rays
|
|
1392
1399
|
void
|
1393
1400
|
Painter::set_fill (const Color& color)
|
1394
1401
|
{
|
1395
|
-
self->state.colors[FILL] = color;
|
1402
|
+
self->state. colors[FILL] = color;
|
1403
|
+
self->state.nocolors[FILL] = false;
|
1396
1404
|
}
|
1397
1405
|
|
1398
1406
|
void
|
1399
1407
|
Painter::no_fill ()
|
1400
1408
|
{
|
1401
|
-
self->state.colors[FILL].alpha = 0;
|
1409
|
+
self->state. colors[FILL].alpha = 0;
|
1410
|
+
self->state.nocolors[FILL] = true;
|
1402
1411
|
}
|
1403
1412
|
|
1404
1413
|
const Color&
|
@@ -1416,13 +1425,15 @@ namespace Rays
|
|
1416
1425
|
void
|
1417
1426
|
Painter::set_stroke (const Color& color)
|
1418
1427
|
{
|
1419
|
-
self->state.colors[STROKE] = color;
|
1428
|
+
self->state. colors[STROKE] = color;
|
1429
|
+
self->state.nocolors[STROKE] = false;
|
1420
1430
|
}
|
1421
1431
|
|
1422
1432
|
void
|
1423
1433
|
Painter::no_stroke ()
|
1424
1434
|
{
|
1425
|
-
self->state.colors[STROKE].alpha = 0;
|
1435
|
+
self->state. colors[STROKE].alpha = 0;
|
1436
|
+
self->state.nocolors[STROKE] = true;
|
1426
1437
|
}
|
1427
1438
|
|
1428
1439
|
const Color&
|
data/src/point.cpp
CHANGED
data/src/polygon.cpp
CHANGED
@@ -1454,7 +1454,7 @@ namespace Rays
|
|
1454
1454
|
if (!painter)
|
1455
1455
|
argument_error(__FILE__, __LINE__);
|
1456
1456
|
|
1457
|
-
if (!
|
1457
|
+
if (!polygon || polygon.empty())
|
1458
1458
|
return;
|
1459
1459
|
|
1460
1460
|
polygon.self->fill(painter, color);
|
@@ -1466,7 +1466,7 @@ namespace Rays
|
|
1466
1466
|
if (!painter)
|
1467
1467
|
argument_error(__FILE__, __LINE__);
|
1468
1468
|
|
1469
|
-
if (!
|
1469
|
+
if (!polygon || polygon.empty())
|
1470
1470
|
return;
|
1471
1471
|
|
1472
1472
|
polygon.self->stroke(polygon, painter, color);
|
data/src/shader_source.cpp
CHANGED
@@ -71,6 +71,7 @@ namespace Rays
|
|
71
71
|
}
|
72
72
|
#endif
|
73
73
|
|
74
|
+
#ifndef IOS
|
74
75
|
static const std::regex VERSION(R"(^\s*#\s*version\s+\d+)");
|
75
76
|
if (!std::regex_search(source, VERSION))
|
76
77
|
{
|
@@ -78,6 +79,7 @@ namespace Rays
|
|
78
79
|
*buffer = VERSION_HEADER + source;
|
79
80
|
source = buffer->c_str();
|
80
81
|
}
|
82
|
+
#endif
|
81
83
|
|
82
84
|
return source;
|
83
85
|
}
|
data/src/util.cpp
CHANGED
data/test/test_painter.rb
CHANGED
@@ -21,19 +21,19 @@ class TestPainter < Test::Unit::TestCase
|
|
21
21
|
.tap {|img| img.paint(&block) if block}
|
22
22
|
end
|
23
23
|
|
24
|
-
def assert_gray(expected, actual)
|
25
|
-
assert_in_epsilon expected, actual, 0.02
|
24
|
+
def assert_gray(expected, actual, message = nil)
|
25
|
+
assert_in_epsilon expected, actual, 0.02, message
|
26
26
|
end
|
27
27
|
|
28
28
|
def assert_rgb(expected, actual)
|
29
29
|
(0..2).each do |i|
|
30
|
-
assert_gray expected[i], actual[i]
|
30
|
+
assert_gray expected[i], actual[i], "Expected: #{expected}, Actual: #{actual}"
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
def assert_rgba(expected, actual)
|
35
35
|
(0..3).each do |i|
|
36
|
-
assert_gray expected[i], actual[i]
|
36
|
+
assert_gray expected[i], actual[i], "Expected: #{expected}, Actual: #{actual}"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -347,14 +347,16 @@ class TestPainter < Test::Unit::TestCase
|
|
347
347
|
|
348
348
|
def test_blend_mode_replace()
|
349
349
|
i = image bg: 1 do
|
350
|
-
fill 0.1, 0.2, 0.3
|
350
|
+
fill 0.1, 0.2, 0.3
|
351
351
|
rect 0, 0, 2
|
352
352
|
blend_mode :replace
|
353
|
-
|
353
|
+
no_stroke
|
354
|
+
fill 0.4, 0.5, 0.6, 0.7
|
354
355
|
rect 1, 0, 2
|
355
356
|
end
|
356
|
-
assert_rgba [0.
|
357
|
-
assert_rgba [0.
|
357
|
+
assert_rgba [0.1, 0.2, 0.3, 1.0], i[0, 0]
|
358
|
+
assert_rgba [0.4, 0.5, 0.6, 0.7], i[1, 0]
|
359
|
+
assert_rgba [0.4, 0.5, 0.6, 0.7], i[2, 0]
|
358
360
|
end
|
359
361
|
|
360
362
|
def test_blend_mode_invalid()
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -16,40 +16,40 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.3.
|
19
|
+
version: 0.3.5
|
20
20
|
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.3.
|
22
|
+
version: 0.3.5
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.3.
|
29
|
+
version: 0.3.5
|
30
30
|
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.3.
|
32
|
+
version: 0.3.5
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: rucy
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.3.
|
39
|
+
version: 0.3.5
|
40
40
|
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.3.
|
42
|
+
version: 0.3.5
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.3.
|
49
|
+
version: 0.3.5
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.3.
|
52
|
+
version: 0.3.5
|
53
53
|
description: This library helps you to develop graphics application with OpenGL.
|
54
54
|
email: xordog@gmail.com
|
55
55
|
executables: []
|
@@ -93,10 +93,12 @@ files:
|
|
93
93
|
- ".doc/ext/rays/rays.cpp"
|
94
94
|
- ".doc/ext/rays/shader.cpp"
|
95
95
|
- ".doc/ext/rays/util.cpp"
|
96
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
96
97
|
- ".github/workflows/release-gem.yml"
|
97
98
|
- ".github/workflows/tag.yml"
|
98
99
|
- ".github/workflows/test.yml"
|
99
100
|
- ".github/workflows/utils.rb"
|
101
|
+
- CONTRIBUTING.md
|
100
102
|
- ChangeLog.md
|
101
103
|
- Gemfile
|
102
104
|
- Gemfile.lock
|
@@ -191,6 +193,7 @@ files:
|
|
191
193
|
- src/font.h
|
192
194
|
- src/frame_buffer.cpp
|
193
195
|
- src/frame_buffer.h
|
196
|
+
- src/glm.h
|
194
197
|
- src/image.cpp
|
195
198
|
- src/image.h
|
196
199
|
- src/ios/bitmap.h
|
@@ -256,7 +259,8 @@ files:
|
|
256
259
|
homepage: https://github.com/xord/rays
|
257
260
|
licenses:
|
258
261
|
- MIT
|
259
|
-
metadata:
|
262
|
+
metadata:
|
263
|
+
msys2_mingw_dependencies: glew
|
260
264
|
post_install_message:
|
261
265
|
rdoc_options: []
|
262
266
|
require_paths:
|