rays 0.1.47 → 0.1.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.doc/ext/rays/bitmap.cpp +287 -46
- data/.doc/ext/rays/camera.cpp +2 -2
- data/.doc/ext/rays/defs.cpp +32 -8
- data/.doc/ext/rays/font.cpp +50 -2
- data/.doc/ext/rays/native.cpp +2 -4
- data/.doc/ext/rays/painter.cpp +73 -3
- data/.doc/ext/rays/polygon.cpp +131 -97
- data/.doc/ext/rays/polyline.cpp +89 -10
- data/.doc/ext/rays/rays.cpp +80 -0
- data/.doc/ext/rays/{noise.cpp → util.cpp} +2 -2
- data/ChangeLog.md +23 -0
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +288 -46
- data/ext/rays/camera.cpp +2 -2
- data/ext/rays/defs.cpp +32 -8
- data/ext/rays/defs.h +56 -3
- data/ext/rays/font.cpp +56 -4
- data/ext/rays/native.cpp +2 -4
- data/ext/rays/painter.cpp +80 -3
- data/ext/rays/polygon.cpp +134 -99
- data/ext/rays/polyline.cpp +95 -9
- data/ext/rays/rays.cpp +80 -0
- data/ext/rays/{noise.cpp → util.cpp} +2 -2
- data/include/rays/defs.h +24 -26
- data/include/rays/font.h +17 -3
- data/include/rays/painter.h +14 -0
- data/include/rays/polygon.h +56 -37
- data/include/rays/polyline.h +17 -2
- data/include/rays/ruby/polygon.h +0 -11
- data/include/rays/ruby/rays.h +4 -0
- data/include/rays/{noise.h → util.h} +2 -2
- data/lib/rays/color.rb +1 -1
- data/lib/rays/font.rb +1 -1
- data/lib/rays/image.rb +1 -1
- data/lib/rays/painter.rb +12 -1
- data/lib/rays/point.rb +1 -1
- data/lib/rays/polygon.rb +44 -35
- data/lib/rays/polyline.rb +54 -8
- data/lib/rays.rb +0 -1
- data/rays.gemspec +1 -1
- data/src/font.cpp +24 -2
- data/src/font.h +8 -1
- data/src/ios/font.mm +88 -27
- data/src/osx/font.mm +90 -28
- data/src/osx/helper.h +2 -2
- data/src/osx/helper.mm +2 -2
- data/src/painter.cpp +155 -85
- data/src/painter.h +11 -3
- data/src/polygon.cpp +404 -315
- data/src/polyline.cpp +138 -27
- data/src/polyline.h +3 -5
- data/src/shader.cpp +36 -4
- data/src/shader.h +1 -1
- data/src/texture.cpp +2 -2
- data/src/{noise.cpp → util.cpp} +1 -1
- data/src/win32/font.cpp +1 -1
- data/test/test_bitmap.rb +12 -5
- data/test/test_color.rb +4 -0
- data/test/test_font.rb +20 -2
- data/test/test_image.rb +18 -18
- data/test/test_point.rb +1 -1
- data/test/test_polygon.rb +52 -45
- data/test/test_polyline.rb +191 -72
- metadata +9 -15
- data/.doc/ext/rays/polygon_line.cpp +0 -97
- data/ext/rays/polygon_line.cpp +0 -100
- data/lib/rays/polygon_line.rb +0 -33
- data/test/test_polygon_line.rb +0 -164
data/include/rays/defs.h
CHANGED
@@ -23,32 +23,6 @@ namespace Rays
|
|
23
23
|
typedef float coord;
|
24
24
|
|
25
25
|
|
26
|
-
enum DrawMode
|
27
|
-
{
|
28
|
-
|
29
|
-
DRAW_POINTS = 0,
|
30
|
-
|
31
|
-
DRAW_LINES,
|
32
|
-
|
33
|
-
DRAW_LINE_STRIP,
|
34
|
-
|
35
|
-
DRAW_TRIANGLES,
|
36
|
-
|
37
|
-
DRAW_TRIANGLE_STRIP,
|
38
|
-
|
39
|
-
DRAW_TRIANGLE_FAN,
|
40
|
-
|
41
|
-
DRAW_QUADS,
|
42
|
-
|
43
|
-
DRAW_QUAD_STRIP,
|
44
|
-
|
45
|
-
DRAW_POLYGON,
|
46
|
-
|
47
|
-
DRAW_MAX,
|
48
|
-
|
49
|
-
};// DrawMode
|
50
|
-
|
51
|
-
|
52
26
|
enum CapType
|
53
27
|
{
|
54
28
|
|
@@ -108,6 +82,30 @@ namespace Rays
|
|
108
82
|
};// BlendMode
|
109
83
|
|
110
84
|
|
85
|
+
enum TexCoordMode
|
86
|
+
{
|
87
|
+
|
88
|
+
TEXCOORD_IMAGE = 0,
|
89
|
+
|
90
|
+
TEXCOORD_NORMAL,
|
91
|
+
|
92
|
+
TEXCOORD_MODE_MAX
|
93
|
+
|
94
|
+
};// TexCoordMode
|
95
|
+
|
96
|
+
|
97
|
+
enum TexCoordWrap
|
98
|
+
{
|
99
|
+
|
100
|
+
TEXCOORD_CLAMP = 0,
|
101
|
+
|
102
|
+
TEXCOORD_REPEAT,
|
103
|
+
|
104
|
+
TEXCOORD_WRAP_MAX
|
105
|
+
|
106
|
+
};// TexCoordWrap
|
107
|
+
|
108
|
+
|
111
109
|
}// Rays
|
112
110
|
|
113
111
|
|
data/include/rays/font.h
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
#define __RAYS_FONT_H__
|
5
5
|
|
6
6
|
|
7
|
+
#include <vector>
|
8
|
+
#include <map>
|
7
9
|
#include <xot/pimpl.h>
|
8
10
|
#include <rays/defs.h>
|
9
11
|
|
@@ -17,15 +19,21 @@ namespace Rays
|
|
17
19
|
|
18
20
|
public:
|
19
21
|
|
22
|
+
enum {DEFAULT_SIZE = 12};
|
23
|
+
|
20
24
|
Font ();
|
21
25
|
|
22
|
-
Font (const char* name, coord size =
|
26
|
+
Font (const char* name, coord size = DEFAULT_SIZE);
|
23
27
|
|
24
28
|
~Font ();
|
25
29
|
|
30
|
+
Font dup () const;
|
31
|
+
|
26
32
|
String name () const;
|
27
33
|
|
28
|
-
coord size
|
34
|
+
void set_size (coord size);
|
35
|
+
|
36
|
+
coord size () const;
|
29
37
|
|
30
38
|
coord get_width (const char* str) const;
|
31
39
|
|
@@ -45,7 +53,13 @@ namespace Rays
|
|
45
53
|
};// Font
|
46
54
|
|
47
55
|
|
48
|
-
|
56
|
+
typedef std::map<String, std::vector<String>> FontFamilyMap;
|
57
|
+
|
58
|
+
const FontFamilyMap& get_font_families ();
|
59
|
+
|
60
|
+
Font load_font (const char* path, coord size = Font::DEFAULT_SIZE);
|
61
|
+
|
62
|
+
const Font& get_default_font ();
|
49
63
|
|
50
64
|
|
51
65
|
}// Rays
|
data/include/rays/painter.h
CHANGED
@@ -253,6 +253,20 @@ namespace Rays
|
|
253
253
|
|
254
254
|
const Font& font () const;
|
255
255
|
|
256
|
+
void set_texture (const Image& image);
|
257
|
+
|
258
|
+
void no_texture ();
|
259
|
+
|
260
|
+
const Image& texture () const;
|
261
|
+
|
262
|
+
void set_texcoord_mode (TexCoordMode mode);
|
263
|
+
|
264
|
+
TexCoordMode texcoord_mode () const;
|
265
|
+
|
266
|
+
void set_texcoord_wrap (TexCoordWrap wrap);
|
267
|
+
|
268
|
+
TexCoordWrap texcoord_wrap () const;
|
269
|
+
|
256
270
|
void set_shader (const Shader& shader);
|
257
271
|
|
258
272
|
void no_shader ();
|
data/include/rays/polygon.h
CHANGED
@@ -20,50 +20,19 @@ namespace Rays
|
|
20
20
|
|
21
21
|
public:
|
22
22
|
|
23
|
-
|
24
|
-
{
|
23
|
+
typedef std::vector<Polyline> PolylineList;
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
public:
|
29
|
-
|
30
|
-
Line ();
|
31
|
-
|
32
|
-
Line (
|
33
|
-
const Point* points, size_t size,
|
34
|
-
bool loop = true,
|
35
|
-
bool hole = false);
|
36
|
-
|
37
|
-
Line (const Polyline& polyline, bool hole = false);
|
38
|
-
|
39
|
-
bool hole () const;
|
40
|
-
|
41
|
-
operator bool () const;
|
42
|
-
|
43
|
-
bool operator ! () const;
|
44
|
-
|
45
|
-
private:
|
46
|
-
|
47
|
-
bool hole_;
|
48
|
-
|
49
|
-
};// Line
|
50
|
-
|
51
|
-
typedef std::vector<Line> LineList;
|
52
|
-
|
53
|
-
typedef LineList::const_iterator const_iterator;
|
25
|
+
typedef PolylineList::const_iterator const_iterator;
|
54
26
|
|
55
27
|
Polygon ();
|
56
28
|
|
57
29
|
Polygon (
|
58
|
-
const Point* points, size_t size, bool loop = true
|
59
|
-
|
60
|
-
Polygon (
|
61
|
-
DrawMode mode,
|
62
|
-
const Point* points, size_t size, bool loop = true);
|
30
|
+
const Point* points, size_t size, bool loop = true,
|
31
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
63
32
|
|
64
33
|
Polygon (const Polyline& polyline);
|
65
34
|
|
66
|
-
Polygon (const
|
35
|
+
Polygon (const Polyline* polylines, size_t size);
|
67
36
|
|
68
37
|
~Polygon ();
|
69
38
|
|
@@ -84,12 +53,14 @@ namespace Rays
|
|
84
53
|
|
85
54
|
const_iterator end () const;
|
86
55
|
|
87
|
-
const
|
56
|
+
const Polyline& operator [] (size_t index) const;
|
88
57
|
|
89
58
|
operator bool () const;
|
90
59
|
|
91
60
|
bool operator ! () const;
|
92
61
|
|
62
|
+
friend Polygon operator + (const Polygon& lhs, const Polyline& rhs);
|
63
|
+
|
93
64
|
friend Polygon operator + (const Polygon& lhs, const Polygon& rhs);
|
94
65
|
|
95
66
|
friend Polygon operator - (const Polygon& lhs, const Polygon& rhs);
|
@@ -115,6 +86,13 @@ namespace Rays
|
|
115
86
|
};// Polygon
|
116
87
|
|
117
88
|
|
89
|
+
Polygon create_point (coord x, coord y);
|
90
|
+
|
91
|
+
Polygon create_point (const Point& point);
|
92
|
+
|
93
|
+
Polygon create_points (const Point* points, size_t size);
|
94
|
+
|
95
|
+
|
118
96
|
Polygon create_line (coord x1, coord y1, coord x2, coord y2);
|
119
97
|
|
120
98
|
Polygon create_line (const Point& p1, const Point& p2);
|
@@ -123,6 +101,29 @@ namespace Rays
|
|
123
101
|
|
124
102
|
Polygon create_line (const Polyline& polyline);
|
125
103
|
|
104
|
+
Polygon create_lines (const Point* points, size_t size);
|
105
|
+
|
106
|
+
|
107
|
+
Polygon create_triangle (
|
108
|
+
coord x1, coord y1, coord x2, coord y2, coord x3, coord y3,
|
109
|
+
bool loop = true);
|
110
|
+
|
111
|
+
Polygon create_triangle (
|
112
|
+
const Point& p1, const Point& p2, const Point& p3,
|
113
|
+
bool loop = true);
|
114
|
+
|
115
|
+
Polygon create_triangles (
|
116
|
+
const Point* points, size_t size, bool loop = true,
|
117
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
118
|
+
|
119
|
+
Polygon create_triangle_strip (
|
120
|
+
const Point* points, size_t size,
|
121
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
122
|
+
|
123
|
+
Polygon create_triangle_fan (
|
124
|
+
const Point* points, size_t size,
|
125
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
126
|
+
|
126
127
|
|
127
128
|
Polygon create_rect (
|
128
129
|
coord x, coord y, coord width, coord height,
|
@@ -147,6 +148,24 @@ namespace Rays
|
|
147
148
|
uint nsegment = 0);
|
148
149
|
|
149
150
|
|
151
|
+
Polygon create_quad (
|
152
|
+
coord x1, coord y1, coord x2, coord y2,
|
153
|
+
coord x3, coord y3, coord x4, coord y4,
|
154
|
+
bool loop = true);
|
155
|
+
|
156
|
+
Polygon create_quad (
|
157
|
+
const Point& p1, const Point& p2, const Point& p3, const Point& p4,
|
158
|
+
bool loop = true);
|
159
|
+
|
160
|
+
Polygon create_quads (
|
161
|
+
const Point* points, size_t size, bool loop = true,
|
162
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
163
|
+
|
164
|
+
Polygon create_quad_strip (
|
165
|
+
const Point* points, size_t size,
|
166
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL);
|
167
|
+
|
168
|
+
|
150
169
|
Polygon create_ellipse (
|
151
170
|
coord x, coord y, coord width, coord height = 0,
|
152
171
|
const Point& hole_size = 0,
|
data/include/rays/polyline.h
CHANGED
@@ -15,6 +15,7 @@ namespace Rays
|
|
15
15
|
{
|
16
16
|
|
17
17
|
|
18
|
+
struct Color;
|
18
19
|
class Polygon;
|
19
20
|
|
20
21
|
|
@@ -29,9 +30,15 @@ namespace Rays
|
|
29
30
|
|
30
31
|
Polyline ();
|
31
32
|
|
32
|
-
Polyline (
|
33
|
+
Polyline (
|
34
|
+
const Point* points, size_t size, bool loop = false,
|
35
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL,
|
36
|
+
bool hole = false);
|
33
37
|
|
34
|
-
Polyline (
|
38
|
+
Polyline (
|
39
|
+
const Point* points, size_t size, bool loop, bool fill,
|
40
|
+
const Color* colors = NULL, const Coord3* texcoords = NULL,
|
41
|
+
bool hole = false);
|
35
42
|
|
36
43
|
~Polyline ();
|
37
44
|
|
@@ -48,6 +55,14 @@ namespace Rays
|
|
48
55
|
|
49
56
|
bool fill () const;
|
50
57
|
|
58
|
+
bool hole () const;
|
59
|
+
|
60
|
+
const Point* points () const;
|
61
|
+
|
62
|
+
const Color* colors () const;
|
63
|
+
|
64
|
+
const Coord3* texcoords () const;
|
65
|
+
|
51
66
|
size_t size () const;
|
52
67
|
|
53
68
|
bool empty () const;
|
data/include/rays/ruby/polygon.h
CHANGED
@@ -11,8 +11,6 @@
|
|
11
11
|
|
12
12
|
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon)
|
13
13
|
|
14
|
-
RUCY_DECLARE_VALUE_OR_ARRAY_FROM_TO(Rays::Polygon::Line)
|
15
|
-
|
16
14
|
|
17
15
|
namespace Rays
|
18
16
|
{
|
@@ -21,9 +19,6 @@ namespace Rays
|
|
21
19
|
Rucy::Class polygon_class ();
|
22
20
|
// class Rays::Polygon
|
23
21
|
|
24
|
-
Rucy::Class polygon_line_class ();
|
25
|
-
// class Rays::Polygon::Line
|
26
|
-
|
27
22
|
|
28
23
|
}// Rays
|
29
24
|
|
@@ -38,12 +33,6 @@ namespace Rucy
|
|
38
33
|
return Rays::polygon_class();
|
39
34
|
}
|
40
35
|
|
41
|
-
template <> inline Class
|
42
|
-
get_ruby_class<Rays::Polygon::Line> ()
|
43
|
-
{
|
44
|
-
return Rays::polygon_line_class();
|
45
|
-
}
|
46
|
-
|
47
36
|
|
48
37
|
}// Rucy
|
49
38
|
|
data/include/rays/ruby/rays.h
CHANGED
data/lib/rays/color.rb
CHANGED
data/lib/rays/font.rb
CHANGED
data/lib/rays/image.rb
CHANGED
data/lib/rays/painter.rb
CHANGED
@@ -118,9 +118,20 @@ module Rays
|
|
118
118
|
replace: BLEND_REPLACE
|
119
119
|
}
|
120
120
|
|
121
|
+
const_symbol_accessor :texcoord_mode, **{
|
122
|
+
image: TEXCOORD_IMAGE,
|
123
|
+
normal: TEXCOORD_NORMAL
|
124
|
+
}
|
125
|
+
|
126
|
+
const_symbol_accessor :texcoord_wrap, **{
|
127
|
+
clamp: TEXCOORD_CLAMP,
|
128
|
+
repeat: TEXCOORD_REPEAT
|
129
|
+
}
|
130
|
+
|
121
131
|
universal_accessor :background, :fill, :stroke, :color,
|
122
132
|
:stroke_width, :stroke_outset, :stroke_cap, :stroke_join, :miter_limit,
|
123
|
-
:nsegment, :blend_mode, :
|
133
|
+
:nsegment, :blend_mode, :texture, :texcoord_mode, :texcoord_wrap,
|
134
|
+
:shader, :clip, :font
|
124
135
|
|
125
136
|
private
|
126
137
|
|
data/lib/rays/point.rb
CHANGED
data/lib/rays/polygon.rb
CHANGED
@@ -8,74 +8,83 @@ module Rays
|
|
8
8
|
class Polygon
|
9
9
|
|
10
10
|
include Enumerable
|
11
|
+
include Comparable
|
11
12
|
|
12
|
-
def initialize(*args, loop: true)
|
13
|
-
setup args, loop
|
13
|
+
def initialize(*args, loop: true, colors: nil, texcoords: nil)
|
14
|
+
setup args, loop, colors, texcoords
|
14
15
|
end
|
15
16
|
|
16
|
-
def transform(
|
17
|
-
|
18
|
-
|
19
|
-
lines = block.call lines if block
|
20
|
-
self.class.new(*lines)
|
17
|
+
def transform(&block)
|
18
|
+
polylines = block.call to_a
|
19
|
+
self.class.new(*polylines)
|
21
20
|
end
|
22
21
|
|
23
22
|
def intersects(obj)
|
24
23
|
!(self & obj).empty?
|
25
24
|
end
|
26
25
|
|
27
|
-
def
|
28
|
-
|
26
|
+
def <=>(o)
|
27
|
+
(size <=> o.size).then {|cmp| return cmp if cmp != 0}
|
28
|
+
to_a.zip(o.to_a).each {|a, b| cmp = a <=> b; return cmp if cmp != 0}
|
29
|
+
0
|
29
30
|
end
|
30
31
|
|
31
|
-
def
|
32
|
-
|
32
|
+
def inspect()
|
33
|
+
"#<Rays::Polygon [#{map {|polyline| polyline.inspect}.join ', '}]>"
|
33
34
|
end
|
34
35
|
|
35
|
-
def self.
|
36
|
-
|
36
|
+
def self.points(*points)
|
37
|
+
points! points
|
37
38
|
end
|
38
39
|
|
39
|
-
def self.
|
40
|
-
|
41
|
-
|
40
|
+
def self.line(*points, loop: false)
|
41
|
+
line! points, loop
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
+
def self.lines(*points)
|
45
|
+
lines! points
|
44
46
|
end
|
45
47
|
|
46
|
-
def self.
|
47
|
-
|
48
|
-
|
48
|
+
def self.triangles(*points, loop: true, colors: nil, texcoords: nil)
|
49
|
+
triangles! points, loop, colors, texcoords
|
50
|
+
end
|
49
51
|
|
50
|
-
|
52
|
+
def self.triangle_strip(*points, colors: nil, texcoords: nil)
|
53
|
+
triangle_strip! points, colors, texcoords
|
51
54
|
end
|
52
55
|
|
53
|
-
def self.
|
54
|
-
|
56
|
+
def self.triangle_fan(*points, colors: nil, texcoords: nil)
|
57
|
+
triangle_fan! points, colors, texcoords
|
55
58
|
end
|
56
59
|
|
57
|
-
def self.
|
58
|
-
|
60
|
+
def self.rect(
|
61
|
+
*args, round: nil, lt: nil, rt: nil, lb: nil, rb: nil,
|
62
|
+
nsegment: nil)
|
63
|
+
|
64
|
+
rect! args, round, lt, rt, lb, rb, nsegment
|
59
65
|
end
|
60
66
|
|
61
|
-
def self.
|
62
|
-
|
67
|
+
def self.quads(*points, loop: true, colors: nil, texcoords: nil)
|
68
|
+
quads! points, loop, colors, texcoords
|
63
69
|
end
|
64
70
|
|
65
|
-
def self.
|
66
|
-
|
71
|
+
def self.quad_strip(*points, colors: nil, texcoords: nil)
|
72
|
+
quad_strip! points, colors, texcoords
|
67
73
|
end
|
68
74
|
|
69
|
-
def self.
|
70
|
-
|
75
|
+
def self.ellipse(
|
76
|
+
*args, center: nil, radius: nil, hole: nil, from: nil, to: nil,
|
77
|
+
nsegment: nil)
|
78
|
+
|
79
|
+
ellipse! args, center, radius, hole, from, to, nsegment
|
71
80
|
end
|
72
81
|
|
73
|
-
def self.curve(*
|
74
|
-
curve!
|
82
|
+
def self.curve(*points, loop: false)
|
83
|
+
curve! points, loop
|
75
84
|
end
|
76
85
|
|
77
|
-
def self.bezier(*
|
78
|
-
bezier!
|
86
|
+
def self.bezier(*points, loop: false)
|
87
|
+
bezier! points, loop
|
79
88
|
end
|
80
89
|
|
81
90
|
end# Polygon
|
data/lib/rays/polyline.rb
CHANGED
@@ -7,20 +7,66 @@ module Rays
|
|
7
7
|
class Polyline
|
8
8
|
|
9
9
|
include Enumerable
|
10
|
+
include Comparable
|
10
11
|
|
11
|
-
def initialize(
|
12
|
-
|
12
|
+
def initialize(
|
13
|
+
*points, loop: false, fill: nil, colors: nil, texcoords: nil, hole: false)
|
14
|
+
|
15
|
+
setup points, loop, (fill != nil ? fill : loop), colors, texcoords, hole
|
16
|
+
end
|
17
|
+
|
18
|
+
def with(**kwargs)
|
19
|
+
points_, loop_, fill_, colors_, texcoords_, hole_ =
|
20
|
+
kwargs.values_at :points, :loop, :fill, :colors, :texcoords, :hole
|
21
|
+
self.class.new(
|
22
|
+
*(points_ || (points? ? points : [])),
|
23
|
+
loop: loop_ != nil ? loop_ : loop?,
|
24
|
+
fill: fill_ != nil ? fill_ : fill?,
|
25
|
+
colors: colors_ || (colors? ? colors : nil),
|
26
|
+
texcoords: texcoords_ || (texcoords? ? texcoords : nil),
|
27
|
+
hole: hole_ != nil ? hole_ : hole?)
|
28
|
+
end
|
29
|
+
|
30
|
+
def points()
|
31
|
+
each_point.to_a
|
32
|
+
end
|
33
|
+
|
34
|
+
def colors()
|
35
|
+
each_color.to_a
|
36
|
+
end
|
37
|
+
|
38
|
+
def texcoords()
|
39
|
+
each_texcoord.to_a
|
40
|
+
end
|
41
|
+
|
42
|
+
def each_point(&block)
|
43
|
+
block ? each_point!(&block) : enum_for(:each_point!)
|
44
|
+
end
|
45
|
+
|
46
|
+
def each_color(&block)
|
47
|
+
block ? each_color!(&block) : enum_for(:each_color!)
|
48
|
+
end
|
49
|
+
|
50
|
+
def each_texcoord(&block)
|
51
|
+
block ? each_texcoord!(&block) : enum_for(:each_texcoord!)
|
13
52
|
end
|
14
53
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
54
|
+
alias each each_point
|
55
|
+
|
56
|
+
def <=>(o)
|
57
|
+
(size <=> o.size) .then {|cmp| return cmp if cmp != 0}
|
58
|
+
(loop? <=> o.loop?).then {|cmp| return cmp if cmp != 0}
|
59
|
+
(fill? <=> o.fill?).then {|cmp| return cmp if cmp != 0}
|
60
|
+
points .zip(o.points) .each {|a, b| cmp = a <=> b; return cmp if cmp != 0}
|
61
|
+
colors .zip(o.colors) .each {|a, b| cmp = a <=> b; return cmp if cmp != 0}
|
62
|
+
texcoords.zip(o.texcoords).each {|a, b| cmp = a <=> b; return cmp if cmp != 0}
|
63
|
+
0
|
20
64
|
end
|
21
65
|
|
22
66
|
def inspect()
|
23
|
-
|
67
|
+
p = points.map {|o| o.to_a.join ','}.join ', '
|
68
|
+
c, t = colors.size, texcoords.size
|
69
|
+
"#<Rays::Polyline [#{p}] loop:#{loop?} fill:#{fill?} hole:#{hole?} colors:#{c} texcoords:#{t}>"
|
24
70
|
end
|
25
71
|
|
26
72
|
end# Polyline
|
data/lib/rays.rb
CHANGED
data/rays.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.required_ruby_version = '>= 3.0.0'
|
27
27
|
|
28
28
|
s.add_runtime_dependency 'xot', '~> 0.1.41'
|
29
|
-
s.add_runtime_dependency 'rucy', '~> 0.1.
|
29
|
+
s.add_runtime_dependency 'rucy', '~> 0.1.43'
|
30
30
|
|
31
31
|
s.files = `git ls-files`.split $/
|
32
32
|
s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}
|
data/src/font.cpp
CHANGED
@@ -27,7 +27,7 @@ namespace Rays
|
|
27
27
|
if (pixel_density != for_pixel_density)
|
28
28
|
{
|
29
29
|
rawfont_for_pixel_density =
|
30
|
-
RawFont(rawfont
|
30
|
+
RawFont(rawfont, rawfont.size() * pixel_density);
|
31
31
|
for_pixel_density = pixel_density;
|
32
32
|
}
|
33
33
|
|
@@ -37,8 +37,16 @@ namespace Rays
|
|
37
37
|
};// Font::Data
|
38
38
|
|
39
39
|
|
40
|
+
Font
|
41
|
+
load_font (const char* path, coord size)
|
42
|
+
{
|
43
|
+
Font font;
|
44
|
+
font.self->rawfont = RawFont_load(path, size);
|
45
|
+
return font;
|
46
|
+
}
|
47
|
+
|
40
48
|
const Font&
|
41
|
-
|
49
|
+
get_default_font ()
|
42
50
|
{
|
43
51
|
static const Font FONT(NULL);
|
44
52
|
return FONT;
|
@@ -79,12 +87,26 @@ namespace Rays
|
|
79
87
|
{
|
80
88
|
}
|
81
89
|
|
90
|
+
Font
|
91
|
+
Font::dup () const
|
92
|
+
{
|
93
|
+
Font f;
|
94
|
+
f.self->rawfont = RawFont(self->rawfont, self->rawfont.size());
|
95
|
+
return f;
|
96
|
+
}
|
97
|
+
|
82
98
|
String
|
83
99
|
Font::name () const
|
84
100
|
{
|
85
101
|
return self->rawfont.name();
|
86
102
|
}
|
87
103
|
|
104
|
+
void
|
105
|
+
Font::set_size (coord size)
|
106
|
+
{
|
107
|
+
self->rawfont = RawFont(self->rawfont, size);
|
108
|
+
}
|
109
|
+
|
88
110
|
coord
|
89
111
|
Font::size () const
|
90
112
|
{
|