rays 0.1.47 → 0.1.48
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 +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/ext/rays/defs.h
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
#include <vector>
|
8
8
|
#include <rucy.h>
|
9
9
|
#include "rays/defs.h"
|
10
|
+
#include "rays/color.h"
|
10
11
|
#include "rays/point.h"
|
11
12
|
#include "rays/ruby/defs.h"
|
12
13
|
|
@@ -16,9 +17,9 @@ using namespace Rucy;
|
|
16
17
|
using Rays::coord;
|
17
18
|
|
18
19
|
|
19
|
-
void
|
20
|
-
|
21
|
-
|
20
|
+
void get_points (std::vector<Rays::Point>* points, int argc, const Value* argv);
|
21
|
+
|
22
|
+
void get_colors (std::vector<Rays::Color>* colors, int argc, const Value* argv);
|
22
23
|
|
23
24
|
void get_rect_args (
|
24
25
|
coord* x, coord* y, coord* w, coord* h,
|
@@ -35,4 +36,56 @@ void get_ellipse_args (
|
|
35
36
|
Value nsegment);
|
36
37
|
|
37
38
|
|
39
|
+
struct CreateParams
|
40
|
+
{
|
41
|
+
|
42
|
+
std::vector<Rays::Point> points;
|
43
|
+
|
44
|
+
std::vector<Rays::Color> colors;
|
45
|
+
|
46
|
+
std::vector<Rays::Point> texcoords;
|
47
|
+
|
48
|
+
CreateParams (
|
49
|
+
const Value& points_, const Value& colors_, const Value& texcoords_)
|
50
|
+
{
|
51
|
+
get_points(&points, points_.size(), points_.as_array());
|
52
|
+
|
53
|
+
if (colors_)
|
54
|
+
{
|
55
|
+
get_colors(&colors, colors_.size(), colors_.as_array());
|
56
|
+
if (colors.size() != points.size())
|
57
|
+
argument_error(__FILE__, __LINE__, "colors.size() != points.size()");
|
58
|
+
}
|
59
|
+
|
60
|
+
if (texcoords_)
|
61
|
+
{
|
62
|
+
get_points(&texcoords, texcoords_.size(), texcoords_.as_array());
|
63
|
+
if (texcoords.size() != points.size())
|
64
|
+
argument_error(__FILE__, __LINE__, "texcoords.size() != points.size()");
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
const Rays::Point* ppoints () const
|
69
|
+
{
|
70
|
+
return points.empty() ? NULL : &points[0];
|
71
|
+
}
|
72
|
+
|
73
|
+
const Rays::Color* pcolors () const
|
74
|
+
{
|
75
|
+
return colors.empty() ? NULL : &colors[0];
|
76
|
+
}
|
77
|
+
|
78
|
+
const Rays::Point* ptexcoords () const
|
79
|
+
{
|
80
|
+
return texcoords.empty() ? NULL : &texcoords[0];
|
81
|
+
}
|
82
|
+
|
83
|
+
size_t size () const
|
84
|
+
{
|
85
|
+
return points.size();
|
86
|
+
}
|
87
|
+
|
88
|
+
};// CreateParams
|
89
|
+
|
90
|
+
|
38
91
|
#endif//EOH
|
data/ext/rays/font.cpp
CHANGED
@@ -30,6 +30,16 @@ RUCY_DEFN(initialize)
|
|
30
30
|
}
|
31
31
|
RUCY_END
|
32
32
|
|
33
|
+
static
|
34
|
+
RUCY_DEF1(initialize_copy, obj)
|
35
|
+
{
|
36
|
+
RUCY_CHECK_OBJ(Rays::Font, self);
|
37
|
+
|
38
|
+
*THIS = to<Rays::Font&>(obj).dup();
|
39
|
+
return self;
|
40
|
+
}
|
41
|
+
RUCY_END
|
42
|
+
|
33
43
|
static
|
34
44
|
RUCY_DEF0(name)
|
35
45
|
{
|
@@ -38,6 +48,15 @@ RUCY_DEF0(name)
|
|
38
48
|
}
|
39
49
|
RUCY_END
|
40
50
|
|
51
|
+
static
|
52
|
+
RUCY_DEF1(set_size, size)
|
53
|
+
{
|
54
|
+
CHECK;
|
55
|
+
THIS->set_size(to<coord>(size));
|
56
|
+
return size;
|
57
|
+
}
|
58
|
+
RUCY_END
|
59
|
+
|
41
60
|
static
|
42
61
|
RUCY_DEF0(size)
|
43
62
|
{
|
@@ -92,6 +111,35 @@ RUCY_DEF0(leading)
|
|
92
111
|
}
|
93
112
|
RUCY_END
|
94
113
|
|
114
|
+
static
|
115
|
+
RUCY_DEF0(families)
|
116
|
+
{
|
117
|
+
Hash hash;
|
118
|
+
for (const auto& family : Rays::get_font_families())
|
119
|
+
{
|
120
|
+
std::vector<Value> members;
|
121
|
+
for (const auto& member : family.second)
|
122
|
+
members.emplace_back(member.c_str());
|
123
|
+
hash.set(family.first.c_str(), value(members.size(), &members[0]));
|
124
|
+
}
|
125
|
+
return hash;
|
126
|
+
}
|
127
|
+
RUCY_END
|
128
|
+
|
129
|
+
static
|
130
|
+
RUCY_DEFN(load)
|
131
|
+
{
|
132
|
+
check_arg_count(__FILE__, __LINE__, "Font.load", argc, 1, 2);
|
133
|
+
|
134
|
+
const char* path = argv[0].c_str();
|
135
|
+
|
136
|
+
if (argc >= 2)
|
137
|
+
return value(Rays::load_font(path, to<Rays::coord>(argv[1])));
|
138
|
+
else
|
139
|
+
return value(Rays::load_font(path));
|
140
|
+
}
|
141
|
+
RUCY_END
|
142
|
+
|
95
143
|
|
96
144
|
static Class cFont;
|
97
145
|
|
@@ -102,14 +150,18 @@ Init_rays_font ()
|
|
102
150
|
|
103
151
|
cFont = mRays.define_class("Font");
|
104
152
|
cFont.define_alloc_func(alloc);
|
105
|
-
cFont.define_private_method("initialize",
|
153
|
+
cFont.define_private_method("initialize", initialize);
|
154
|
+
cFont.define_private_method("initialize_copy", initialize_copy);
|
106
155
|
cFont.define_method("name", name);
|
107
|
-
cFont.define_method("size",
|
156
|
+
cFont.define_method("size=", set_size);
|
157
|
+
cFont.define_method("size", size);
|
108
158
|
cFont.define_method("width", width);
|
109
159
|
cFont.define_method("height", height);
|
110
160
|
cFont.define_method("ascent", ascent);
|
111
161
|
cFont.define_method("descent", descent);
|
112
162
|
cFont.define_method("leading", leading);
|
163
|
+
cFont.define_module_function("families", families);
|
164
|
+
cFont.define_module_function("load", load);
|
113
165
|
}
|
114
166
|
|
115
167
|
|
@@ -131,9 +183,9 @@ namespace Rucy
|
|
131
183
|
if (convert)
|
132
184
|
{
|
133
185
|
if (argc == 0)
|
134
|
-
return Rays::
|
186
|
+
return Rays::get_default_font();
|
135
187
|
|
136
|
-
coord size = argc >= 2 ? to<coord>(argv[1]) :
|
188
|
+
coord size = argc >= 2 ? to<coord>(argv[1]) : Rays::Font::DEFAULT_SIZE;
|
137
189
|
if (argv->is_nil())
|
138
190
|
return Rays::Font(NULL, size);
|
139
191
|
else if (argv->is_s() || argv->is_sym())
|
data/ext/rays/native.cpp
CHANGED
@@ -12,7 +12,6 @@ void Init_rays_matrix ();
|
|
12
12
|
|
13
13
|
void Init_rays_painter ();
|
14
14
|
void Init_rays_polyline ();
|
15
|
-
void Init_rays_polygon_line ();
|
16
15
|
void Init_rays_polygon ();
|
17
16
|
void Init_rays_bitmap ();
|
18
17
|
void Init_rays_image ();
|
@@ -20,7 +19,7 @@ void Init_rays_font ();
|
|
20
19
|
void Init_rays_shader ();
|
21
20
|
void Init_rays_camera ();
|
22
21
|
|
23
|
-
void
|
22
|
+
void Init_rays_util ();
|
24
23
|
|
25
24
|
|
26
25
|
extern "C" void
|
@@ -45,7 +44,6 @@ extern "C" void
|
|
45
44
|
|
46
45
|
Init_rays_painter();
|
47
46
|
Init_rays_polyline();
|
48
|
-
Init_rays_polygon_line();
|
49
47
|
Init_rays_polygon();
|
50
48
|
Init_rays_bitmap();
|
51
49
|
Init_rays_image();
|
@@ -53,7 +51,7 @@ extern "C" void
|
|
53
51
|
Init_rays_shader();
|
54
52
|
Init_rays_camera();
|
55
53
|
|
56
|
-
|
54
|
+
Init_rays_util();
|
57
55
|
|
58
56
|
RUCY_CATCH
|
59
57
|
}
|
data/ext/rays/painter.cpp
CHANGED
@@ -162,7 +162,7 @@ RUCY_DEF2(line, args, loop)
|
|
162
162
|
CHECK;
|
163
163
|
|
164
164
|
std::vector<Rays::Point> points;
|
165
|
-
|
165
|
+
get_points(&points, args.size(), args.as_array());
|
166
166
|
|
167
167
|
THIS->line(&points[0], points.size(), loop);
|
168
168
|
return self;
|
@@ -224,7 +224,7 @@ RUCY_DEF2(curve, args, loop)
|
|
224
224
|
argument_error(__FILE__, __LINE__);
|
225
225
|
|
226
226
|
std::vector<Rays::Point> points;
|
227
|
-
|
227
|
+
get_points(&points, args.size(), args.as_array());
|
228
228
|
|
229
229
|
THIS->curve(&points[0], points.size(), loop);
|
230
230
|
return self;
|
@@ -240,7 +240,7 @@ RUCY_DEF2(bezier, args, loop)
|
|
240
240
|
argument_error(__FILE__, __LINE__);
|
241
241
|
|
242
242
|
std::vector<Rays::Point> points;
|
243
|
-
|
243
|
+
get_points(&points, args.size(), args.as_array());
|
244
244
|
|
245
245
|
THIS->bezier(&points[0], points.size(), loop);
|
246
246
|
return self;
|
@@ -558,6 +558,76 @@ RUCY_DEF0(get_font)
|
|
558
558
|
}
|
559
559
|
RUCY_END
|
560
560
|
|
561
|
+
static
|
562
|
+
RUCY_DEF1(set_texture, image)
|
563
|
+
{
|
564
|
+
CHECK;
|
565
|
+
|
566
|
+
if (!image)
|
567
|
+
THIS->no_texture();
|
568
|
+
else
|
569
|
+
THIS->set_texture(to<Rays::Image&>(image));
|
570
|
+
return self;
|
571
|
+
}
|
572
|
+
RUCY_END
|
573
|
+
|
574
|
+
static
|
575
|
+
RUCY_DEF0(get_texture)
|
576
|
+
{
|
577
|
+
CHECK;
|
578
|
+
|
579
|
+
const Rays::Image& image = THIS->texture();
|
580
|
+
return image ? value(image) : nil();
|
581
|
+
}
|
582
|
+
RUCY_END
|
583
|
+
|
584
|
+
static
|
585
|
+
RUCY_DEF0(no_texture)
|
586
|
+
{
|
587
|
+
CHECK;
|
588
|
+
THIS->no_texture();
|
589
|
+
return self;
|
590
|
+
}
|
591
|
+
RUCY_END
|
592
|
+
|
593
|
+
static
|
594
|
+
RUCY_DEF1(set_texcoord_mode, mode)
|
595
|
+
{
|
596
|
+
CHECK;
|
597
|
+
|
598
|
+
THIS->set_texcoord_mode(to<Rays::TexCoordMode>(mode));
|
599
|
+
return self;
|
600
|
+
}
|
601
|
+
RUCY_END
|
602
|
+
|
603
|
+
static
|
604
|
+
RUCY_DEF0(get_texcoord_mode)
|
605
|
+
{
|
606
|
+
CHECK;
|
607
|
+
|
608
|
+
return value(THIS->texcoord_mode());
|
609
|
+
}
|
610
|
+
RUCY_END
|
611
|
+
|
612
|
+
static
|
613
|
+
RUCY_DEF1(set_texcoord_wrap, wrap)
|
614
|
+
{
|
615
|
+
CHECK;
|
616
|
+
|
617
|
+
THIS->set_texcoord_wrap(to<Rays::TexCoordWrap>(wrap));
|
618
|
+
return self;
|
619
|
+
}
|
620
|
+
RUCY_END
|
621
|
+
|
622
|
+
static
|
623
|
+
RUCY_DEF0(get_texcoord_wrap)
|
624
|
+
{
|
625
|
+
CHECK;
|
626
|
+
|
627
|
+
return value(THIS->texcoord_wrap());
|
628
|
+
}
|
629
|
+
RUCY_END
|
630
|
+
|
561
631
|
static
|
562
632
|
RUCY_DEFN(set_shader)
|
563
633
|
{
|
@@ -752,6 +822,13 @@ Init_rays_painter ()
|
|
752
822
|
cPainter.define_method("no_clip", no_clip);
|
753
823
|
cPainter.define_method("font=", set_font);
|
754
824
|
cPainter.define_method("font", get_font);
|
825
|
+
cPainter.define_method( "texture=", set_texture);
|
826
|
+
cPainter.define_method( "texture", get_texture);
|
827
|
+
cPainter.define_method("no_texture", no_texture);
|
828
|
+
cPainter.define_method("texcoord_mode=", set_texcoord_mode);
|
829
|
+
cPainter.define_method("texcoord_mode", get_texcoord_mode);
|
830
|
+
cPainter.define_method("texcoord_wrap=", set_texcoord_wrap);
|
831
|
+
cPainter.define_method("texcoord_wrap", get_texcoord_wrap);
|
755
832
|
cPainter.define_private_method("set_shader", set_shader);
|
756
833
|
cPainter.define_method( "shader", get_shader);
|
757
834
|
cPainter.define_method( "no_shader", no_shader);
|