rays 0.1.12 → 0.1.13
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 +5 -5
- data/.doc/ext/rays/bitmap.cpp +22 -76
- data/.doc/ext/rays/bounds.cpp +95 -125
- data/.doc/ext/rays/color.cpp +224 -45
- data/.doc/ext/rays/color_space.cpp +137 -45
- data/.doc/ext/rays/defs.cpp +183 -0
- data/.doc/ext/rays/font.cpp +39 -21
- data/.doc/ext/rays/image.cpp +26 -37
- data/.doc/ext/rays/matrix.cpp +186 -29
- data/.doc/ext/rays/native.cpp +12 -6
- data/.doc/ext/rays/noise.cpp +53 -0
- data/.doc/ext/rays/painter.cpp +120 -308
- data/.doc/ext/rays/point.cpp +82 -77
- data/.doc/ext/rays/polygon.cpp +287 -0
- data/.doc/ext/rays/polygon_line.cpp +96 -0
- data/.doc/ext/rays/polyline.cpp +161 -0
- data/.doc/ext/rays/rays.cpp +0 -13
- data/.doc/ext/rays/shader.cpp +83 -9
- data/README.md +1 -1
- data/Rakefile +21 -9
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +22 -80
- data/ext/rays/bounds.cpp +100 -128
- data/ext/rays/color.cpp +232 -51
- data/ext/rays/color_space.cpp +140 -46
- data/ext/rays/defs.cpp +183 -0
- data/ext/rays/defs.h +26 -2
- data/ext/rays/extconf.rb +1 -2
- data/ext/rays/font.cpp +39 -22
- data/ext/rays/image.cpp +27 -39
- data/ext/rays/matrix.cpp +198 -30
- data/ext/rays/native.cpp +12 -6
- data/ext/rays/noise.cpp +55 -0
- data/ext/rays/painter.cpp +129 -315
- data/ext/rays/point.cpp +89 -81
- data/ext/rays/polygon.cpp +301 -0
- data/ext/rays/polygon_line.cpp +99 -0
- data/ext/rays/polyline.cpp +170 -0
- data/ext/rays/rays.cpp +0 -14
- data/ext/rays/shader.cpp +84 -9
- data/include/rays.h +10 -2
- data/include/rays/bitmap.h +14 -26
- data/include/rays/bounds.h +21 -4
- data/include/rays/color.h +25 -14
- data/include/rays/color_space.h +11 -8
- data/include/rays/coord.h +114 -0
- data/include/rays/debug.h +22 -0
- data/include/rays/defs.h +3 -0
- data/include/rays/font.h +4 -4
- data/include/rays/image.h +11 -17
- data/include/rays/matrix.h +50 -24
- data/include/rays/noise.h +42 -0
- data/include/rays/opengl.h +2 -50
- data/include/rays/painter.h +57 -99
- data/include/rays/point.h +44 -51
- data/include/rays/polygon.h +164 -0
- data/include/rays/polyline.h +65 -0
- data/include/rays/rays.h +3 -0
- data/include/rays/ruby.h +7 -1
- data/include/rays/ruby/bounds.h +1 -1
- data/include/rays/ruby/color.h +1 -1
- data/include/rays/ruby/color_space.h +1 -1
- data/include/rays/ruby/font.h +1 -1
- data/include/rays/ruby/matrix.h +1 -1
- data/include/rays/ruby/point.h +1 -1
- data/include/rays/ruby/polygon.h +52 -0
- data/include/rays/ruby/polyline.h +41 -0
- data/include/rays/ruby/shader.h +1 -1
- data/include/rays/shader.h +36 -8
- data/lib/rays.rb +6 -1
- data/lib/rays/bitmap.rb +0 -15
- data/lib/rays/bounds.rb +17 -23
- data/lib/rays/color.rb +20 -47
- data/lib/rays/color_space.rb +13 -13
- data/lib/rays/image.rb +2 -6
- data/lib/rays/matrix.rb +28 -0
- data/lib/rays/module.rb +4 -19
- data/lib/rays/painter.rb +60 -97
- data/lib/rays/point.rb +13 -21
- data/lib/rays/polygon.rb +50 -0
- data/lib/rays/polygon_line.rb +36 -0
- data/lib/rays/polyline.rb +32 -0
- data/lib/rays/shader.rb +20 -1
- data/rays.gemspec +5 -7
- data/src/bitmap.h +36 -0
- data/src/bounds.cpp +74 -11
- data/src/color.cpp +58 -23
- data/src/color_space.cpp +50 -32
- data/src/color_space.h +22 -0
- data/src/coord.cpp +170 -0
- data/src/coord.h +35 -0
- data/src/font.cpp +118 -0
- data/src/font.h +64 -0
- data/src/frame_buffer.cpp +37 -71
- data/src/frame_buffer.h +4 -4
- data/src/image.cpp +171 -97
- data/src/image.h +25 -0
- data/src/ios/bitmap.mm +107 -105
- data/src/ios/font.mm +48 -60
- data/src/ios/helper.h +2 -2
- data/src/ios/opengl.mm +19 -4
- data/src/ios/rays.mm +3 -0
- data/src/matrix.cpp +111 -26
- data/src/matrix.h +30 -0
- data/src/noise.cpp +74 -0
- data/src/opengl.cpp +9 -27
- data/src/opengl.h +37 -0
- data/src/osx/bitmap.mm +111 -106
- data/src/osx/font.mm +48 -61
- data/src/osx/helper.h +2 -2
- data/src/osx/opengl.mm +19 -83
- data/src/osx/rays.mm +3 -0
- data/src/painter.cpp +780 -696
- data/src/painter.h +24 -0
- data/src/point.cpp +140 -119
- data/src/polygon.cpp +1100 -0
- data/src/polygon.h +32 -0
- data/src/polyline.cpp +158 -0
- data/src/polyline.h +67 -0
- data/src/render_buffer.cpp +11 -4
- data/src/render_buffer.h +2 -2
- data/src/shader.cpp +163 -106
- data/src/shader.h +38 -0
- data/src/shader_program.cpp +533 -0
- data/src/{program.h → shader_program.h} +28 -16
- data/src/shader_source.cpp +140 -0
- data/src/shader_source.h +52 -0
- data/src/texture.cpp +136 -160
- data/src/texture.h +65 -0
- data/src/win32/bitmap.cpp +62 -52
- data/src/win32/font.cpp +11 -13
- data/src/win32/font.h +24 -0
- data/src/win32/gdi.h +6 -6
- data/test/helper.rb +0 -3
- data/test/test_bitmap.rb +31 -7
- data/test/test_bounds.rb +36 -0
- data/test/test_color.rb +59 -19
- data/test/test_color_space.rb +95 -0
- data/test/test_image.rb +24 -20
- data/test/test_matrix.rb +106 -0
- data/test/test_painter.rb +92 -46
- data/test/test_painter_shape.rb +57 -0
- data/test/test_point.rb +21 -0
- data/test/test_polygon.rb +234 -0
- data/test/test_polygon_line.rb +167 -0
- data/test/test_polyline.rb +145 -0
- data/test/test_shader.rb +9 -9
- metadata +88 -67
- data/.doc/ext/rays/texture.cpp +0 -138
- data/ext/rays/texture.cpp +0 -149
- data/include/rays/ruby/texture.h +0 -41
- data/include/rays/texture.h +0 -71
- data/lib/rays/texture.rb +0 -24
- data/src/program.cpp +0 -648
- data/test/test_texture.rb +0 -27
data/.doc/ext/rays/native.cpp
CHANGED
@@ -1,25 +1,26 @@
|
|
1
|
-
#include <rucy.h>
|
2
1
|
#include "defs.h"
|
3
2
|
|
4
3
|
|
5
|
-
using namespace Rucy;
|
6
|
-
|
7
|
-
|
8
4
|
void Init_rays ();
|
9
5
|
|
10
6
|
void Init_point ();
|
11
7
|
void Init_bounds ();
|
12
8
|
void Init_color ();
|
13
9
|
void Init_color_space ();
|
10
|
+
void Init_matrix ();
|
14
11
|
|
12
|
+
void Init_polyline ();
|
13
|
+
void Init_polygon_line ();
|
14
|
+
void Init_polygon ();
|
15
15
|
void Init_bitmap ();
|
16
|
-
void Init_texture ();
|
17
16
|
void Init_image ();
|
18
17
|
void Init_font ();
|
19
18
|
void Init_shader ();
|
20
19
|
|
21
20
|
void Init_painter ();
|
22
21
|
|
22
|
+
void Init_noise ();
|
23
|
+
|
23
24
|
|
24
25
|
extern "C" void
|
25
26
|
#ifdef COCOAPODS
|
@@ -38,14 +39,19 @@ extern "C" void
|
|
38
39
|
Init_bounds();
|
39
40
|
Init_color();
|
40
41
|
Init_color_space();
|
42
|
+
Init_matrix();
|
41
43
|
|
44
|
+
Init_polyline();
|
45
|
+
Init_polygon_line();
|
46
|
+
Init_polygon();
|
42
47
|
Init_bitmap();
|
43
|
-
Init_texture();
|
44
48
|
Init_image();
|
45
49
|
Init_font();
|
46
50
|
Init_shader();
|
47
51
|
|
48
52
|
Init_painter();
|
49
53
|
|
54
|
+
Init_noise();
|
55
|
+
|
50
56
|
RUCY_CATCH
|
51
57
|
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#include "rays/noise.h"
|
2
|
+
#include "rays/ruby/point.h"
|
3
|
+
#include "defs.h"
|
4
|
+
|
5
|
+
|
6
|
+
static
|
7
|
+
VALUE perlin(VALUE self)
|
8
|
+
{
|
9
|
+
check_arg_count(__FILE__, __LINE__, "Rays.perlin", argc, 1, 2, 3, 4);
|
10
|
+
|
11
|
+
coord noise = 0;
|
12
|
+
if (argc == 4)
|
13
|
+
{
|
14
|
+
noise = Rays::perlin(
|
15
|
+
to<coord>(argv[0]),
|
16
|
+
to<coord>(argv[1]),
|
17
|
+
to<coord>(argv[2]),
|
18
|
+
to<coord>(argv[3]));
|
19
|
+
}
|
20
|
+
else
|
21
|
+
noise = Rays::perlin(to<Rays::Point>(argc, argv));
|
22
|
+
|
23
|
+
return value(noise);
|
24
|
+
}
|
25
|
+
|
26
|
+
static
|
27
|
+
VALUE simplex(VALUE self)
|
28
|
+
{
|
29
|
+
check_arg_count(__FILE__, __LINE__, "Rays.simplex", argc, 1, 2, 3, 4);
|
30
|
+
|
31
|
+
coord noise = 0;
|
32
|
+
if (argc == 4)
|
33
|
+
{
|
34
|
+
noise = Rays::simplex(
|
35
|
+
to<coord>(argv[0]),
|
36
|
+
to<coord>(argv[1]),
|
37
|
+
to<coord>(argv[2]),
|
38
|
+
to<coord>(argv[3]));
|
39
|
+
}
|
40
|
+
else
|
41
|
+
noise = Rays::simplex(to<Rays::Point>(argc, argv));
|
42
|
+
|
43
|
+
return value(noise);
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
|
+
void
|
48
|
+
Init_noise ()
|
49
|
+
{
|
50
|
+
Module mRays = rb_define_module("Rays");
|
51
|
+
rb_define_singleton_method(mRays, "perlin", RUBY_METHOD_FUNC(perlin), -1);
|
52
|
+
rb_define_singleton_method(mRays, "simplex", RUBY_METHOD_FUNC(simplex), -1);
|
53
|
+
}
|
data/.doc/ext/rays/painter.cpp
CHANGED
@@ -2,22 +2,16 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <vector>
|
5
|
-
#include <rucy.h>
|
6
5
|
#include "rays/ruby/point.h"
|
7
6
|
#include "rays/ruby/bounds.h"
|
8
7
|
#include "rays/ruby/color.h"
|
9
8
|
#include "rays/ruby/matrix.h"
|
10
|
-
#include "rays/ruby/font.h"
|
11
9
|
#include "rays/ruby/image.h"
|
10
|
+
#include "rays/ruby/font.h"
|
12
11
|
#include "rays/ruby/shader.h"
|
13
12
|
#include "defs.h"
|
14
13
|
|
15
14
|
|
16
|
-
using namespace Rucy;
|
17
|
-
|
18
|
-
using Rays::coord;
|
19
|
-
|
20
|
-
|
21
15
|
RUCY_DEFINE_VALUE_FROM_TO(Rays::Painter)
|
22
16
|
|
23
17
|
#define THIS to<Rays::Painter*>(self)
|
@@ -52,6 +46,13 @@ VALUE bounds(VALUE self)
|
|
52
46
|
return value(THIS->bounds());
|
53
47
|
}
|
54
48
|
|
49
|
+
static
|
50
|
+
VALUE pixel_density(VALUE self)
|
51
|
+
{
|
52
|
+
CHECK;
|
53
|
+
return value(THIS->pixel_density());
|
54
|
+
}
|
55
|
+
|
55
56
|
|
56
57
|
static
|
57
58
|
VALUE begin_paint(VALUE self)
|
@@ -77,139 +78,66 @@ VALUE clear(VALUE self)
|
|
77
78
|
}
|
78
79
|
|
79
80
|
static
|
80
|
-
VALUE
|
81
|
+
VALUE polygon(VALUE self, VALUE poly)
|
81
82
|
{
|
82
83
|
CHECK;
|
83
|
-
check_arg_count(__FILE__, __LINE__, "Painter#line", argc, 2, 4);
|
84
|
-
|
85
|
-
if (argc == 2)
|
86
|
-
THIS->line(to<Rays::Point&>(argv[0]), to<Rays::Point&>(argv[1]));
|
87
|
-
else
|
88
|
-
{
|
89
|
-
coord x1 = to<coord>(argv[0]);
|
90
|
-
coord y1 = to<coord>(argv[1]);
|
91
|
-
coord x2 = to<coord>(argv[2]);
|
92
|
-
coord y2 = to<coord>(argv[3]);
|
93
|
-
THIS->line(x1, y1, x2, y2);
|
94
|
-
}
|
95
84
|
|
85
|
+
THIS->polygon(to<Rays::Polygon&>(poly));
|
96
86
|
return self;
|
97
87
|
}
|
98
88
|
|
99
89
|
static
|
100
|
-
VALUE
|
90
|
+
VALUE line(VALUE self, VALUE args, VALUE loop)
|
101
91
|
{
|
102
92
|
CHECK;
|
103
|
-
if (argc <= 0)
|
104
|
-
argument_error(__FILE__, __LINE__, "Painter#lines");
|
105
93
|
|
106
|
-
std::vector<Rays::
|
107
|
-
points.
|
108
|
-
for (int i = 0; i < argc; ++i)
|
109
|
-
points.push_back(to<Rays::Point&>(argv[i]));
|
94
|
+
std::vector<Rays::Point> points;
|
95
|
+
get_line_args(&points, args.size(), args.as_array());
|
110
96
|
|
111
|
-
THIS->
|
97
|
+
THIS->line(&points[0], points.size(), loop);
|
112
98
|
return self;
|
113
99
|
}
|
114
100
|
|
115
101
|
static
|
116
|
-
VALUE
|
102
|
+
VALUE polyline(VALUE self, VALUE poly)
|
117
103
|
{
|
118
104
|
CHECK;
|
119
|
-
if (argc <= 0)
|
120
|
-
argument_error(__FILE__, __LINE__, "Painter#polygon");
|
121
|
-
|
122
|
-
std::vector<Rays::Coord3> points;
|
123
|
-
points.reserve(argc);
|
124
|
-
for (int i = 0; i < argc; ++i)
|
125
|
-
points.push_back(to<Rays::Point&>(argv[i]));
|
126
105
|
|
127
|
-
THIS->
|
106
|
+
THIS->line(to<Rays::Polyline&>(poly));
|
128
107
|
return self;
|
129
108
|
}
|
130
109
|
|
131
110
|
static
|
132
|
-
VALUE rect(VALUE self)
|
111
|
+
VALUE rect(VALUE self, VALUE args, VALUE round, VALUE lefttop, VALUE righttop, VALUE leftbottom, VALUE rightbottom)
|
133
112
|
{
|
134
113
|
CHECK;
|
135
|
-
check_arg_count(__FILE__, __LINE__, "Painter#rect", argc, 1, 2, 3, 4, 5, 6);
|
136
114
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
}
|
144
|
-
else
|
145
|
-
{
|
146
|
-
coord x = to<coord>(argv[0]);
|
147
|
-
coord y = to<coord>(argv[1]);
|
148
|
-
coord w = to<coord>(argv[2]);
|
149
|
-
coord h = to<coord>(argv[3]);
|
150
|
-
coord rw = argc >= 5 ? to<coord>(argv[4]) : 0;
|
151
|
-
coord rh = argc >= 6 ? to<coord>(argv[5]) : rw;
|
152
|
-
THIS->rect(x, y, w, h, rw, rh);
|
153
|
-
}
|
115
|
+
coord x, y, w, h, lt, rt, lb, rb;
|
116
|
+
uint _;
|
117
|
+
get_rect_args(
|
118
|
+
&x, &y, &w, &h, <, &rt, &lb, &rb, &_,
|
119
|
+
args.size(), args.as_array(),
|
120
|
+
round, lefttop, righttop, leftbottom, rightbottom, nil());
|
154
121
|
|
122
|
+
THIS->rect(x, y, w, h, lt, rt, lb, rb);
|
155
123
|
return self;
|
156
124
|
}
|
157
125
|
|
158
126
|
static
|
159
|
-
VALUE ellipse(VALUE self)
|
127
|
+
VALUE ellipse(VALUE self, VALUE args, VALUE center, VALUE radius, VALUE hole, VALUE angle_from, VALUE angle_to)
|
160
128
|
{
|
161
129
|
CHECK;
|
162
|
-
check_arg_count(__FILE__, __LINE__, "Painter#ellipse", argc, 1, 2, 3, 4, 5, 6);
|
163
130
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
{
|
173
|
-
coord x = to<coord>(argv[0]);
|
174
|
-
coord y = to<coord>(argv[1]);
|
175
|
-
coord w = to<coord>(argv[2]);
|
176
|
-
coord h = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
177
|
-
coord min_ = (argc >= 5) ? to<coord>(argv[4]) : 0;
|
178
|
-
uint nseg = (argc >= 6) ? to<uint> (argv[5]) : 0;
|
179
|
-
THIS->ellipse(x, y, w, h, min_, nseg);
|
180
|
-
}
|
181
|
-
|
182
|
-
return self;
|
183
|
-
}
|
184
|
-
|
185
|
-
static
|
186
|
-
VALUE arc(VALUE self)
|
187
|
-
{
|
188
|
-
CHECK;
|
189
|
-
check_arg_count(__FILE__, __LINE__, "Painter#ellipse", argc, 1, 2, 3, 4, 5, 6, 7, 8);
|
190
|
-
|
191
|
-
if (argv[0].is_kind_of(Rays::bounds_class()))
|
192
|
-
{
|
193
|
-
const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
194
|
-
float begin = (argc >= 2) ? to<float>(argv[1]) : 0;
|
195
|
-
float end = (argc >= 3) ? to<float>(argv[2]) : 360;
|
196
|
-
coord min_ = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
197
|
-
uint nseg = (argc >= 5) ? to<uint> (argv[4]) : 0;
|
198
|
-
THIS->arc(b, begin, end, min_, nseg);
|
199
|
-
}
|
200
|
-
else
|
201
|
-
{
|
202
|
-
coord x = to<coord>(argv[0]);
|
203
|
-
coord y = to<coord>(argv[1]);
|
204
|
-
coord w = to<coord>(argv[2]);
|
205
|
-
coord h = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
206
|
-
float begin = (argc >= 5) ? to<float>(argv[4]) : 0;
|
207
|
-
float end = (argc >= 6) ? to<float>(argv[5]) : 360;
|
208
|
-
coord min_ = (argc >= 7) ? to<coord>(argv[6]) : 0;
|
209
|
-
uint nseg = (argc >= 8) ? to<uint> (argv[7]) : 0;
|
210
|
-
THIS->arc(x, y, w, h, begin, end, min_, nseg);
|
211
|
-
}
|
131
|
+
coord x, y, w, h;
|
132
|
+
Rays::Point hole_size;
|
133
|
+
float from, to_;
|
134
|
+
uint _;
|
135
|
+
get_ellipse_args(
|
136
|
+
&x, &y, &w, &h, &hole_size, &from, &to_, &_,
|
137
|
+
args.size(), args.as_array(),
|
138
|
+
center, radius, hole, angle_from, angle_to, nil());
|
212
139
|
|
140
|
+
THIS->ellipse(x, y, w, h, hole_size, from, to_);
|
213
141
|
return self;
|
214
142
|
}
|
215
143
|
|
@@ -260,7 +188,7 @@ static
|
|
260
188
|
VALUE text(VALUE self)
|
261
189
|
{
|
262
190
|
CHECK;
|
263
|
-
check_arg_count(__FILE__, __LINE__, "Painter#text", argc, 1, 3,
|
191
|
+
check_arg_count(__FILE__, __LINE__, "Painter#text", argc, 1, 3, 5);
|
264
192
|
|
265
193
|
if (argc == 1)
|
266
194
|
THIS->text(argv[0].c_str());
|
@@ -269,66 +197,22 @@ VALUE text(VALUE self)
|
|
269
197
|
coord x = to<coord>(argv[1]), y = to<coord>(argv[2]);
|
270
198
|
THIS->text(argv[0].c_str(), x, y);
|
271
199
|
}
|
272
|
-
else if (argc == 4)
|
273
|
-
{
|
274
|
-
const Rays::Font* font = to<Rays::Font*>(argv[3]);
|
275
|
-
if (!font || !*font)
|
276
|
-
rays_error(__FILE__, __LINE__, "Painter#text: invalid font.");
|
277
|
-
|
278
|
-
coord x = to<coord>(argv[1]), y = to<coord>(argv[2]);
|
279
|
-
THIS->text(argv[0].c_str(), x, y, font);
|
280
|
-
}
|
281
200
|
else if (argc == 5)
|
282
201
|
{
|
283
202
|
coord x = to<coord>(argv[1]), w = to<coord>(argv[3]);
|
284
203
|
coord y = to<coord>(argv[2]), h = to<coord>(argv[4]);
|
285
204
|
THIS->text(argv[0].c_str(), x, y, w, h);
|
286
205
|
}
|
287
|
-
else if (argc == 7)
|
288
|
-
{
|
289
|
-
const Rays::Font* font = to<Rays::Font*>(argv[3]);
|
290
|
-
if (!font || !*font)
|
291
|
-
rays_error(__FILE__, __LINE__, "Painter#text: invalid font.");
|
292
|
-
|
293
|
-
coord x = to<coord>(argv[1]), w = to<coord>(argv[3]);
|
294
|
-
coord y = to<coord>(argv[2]), h = to<coord>(argv[4]);
|
295
|
-
THIS->text(argv[0].c_str(), x, y, w, h, font);
|
296
|
-
}
|
297
206
|
|
298
207
|
return self;
|
299
208
|
}
|
300
209
|
|
301
|
-
static
|
302
|
-
VALUE set_background(VALUE self)
|
303
|
-
{
|
304
|
-
CHECK;
|
305
|
-
check_arg_count(__FILE__, __LINE__, "Painter#set_background", argc, 1, 2, 3, 4);
|
306
|
-
|
307
|
-
if (argc == 1 && argv[0].is_kind_of(Rays::color_class()))
|
308
|
-
THIS->set_background(to<Rays::Color&>(argv[0]));
|
309
|
-
else if (argc == 1 || argc == 2)
|
310
|
-
{
|
311
|
-
float v = to<float>(argv[0]);
|
312
|
-
float a = (argc >= 2) ? to<float>(argv[1]) : 1;
|
313
|
-
THIS->set_background(v, v, v, a);
|
314
|
-
}
|
315
|
-
else
|
316
|
-
{
|
317
|
-
float r = to<float>(argv[0]);
|
318
|
-
float g = to<float>(argv[1]);
|
319
|
-
float b = to<float>(argv[2]);
|
320
|
-
float a = (argc == 4) ? to<float>(argv[3]) : 1;
|
321
|
-
THIS->set_background(r, g, b, a);
|
322
|
-
}
|
323
|
-
|
324
|
-
return self;
|
325
|
-
}
|
326
210
|
|
327
211
|
static
|
328
|
-
VALUE
|
212
|
+
VALUE set_background(VALUE self)
|
329
213
|
{
|
330
214
|
CHECK;
|
331
|
-
THIS->
|
215
|
+
THIS->set_background(to<Rays::Color>(argc, argv));
|
332
216
|
return self;
|
333
217
|
}
|
334
218
|
|
@@ -340,36 +224,18 @@ VALUE get_background(VALUE self)
|
|
340
224
|
}
|
341
225
|
|
342
226
|
static
|
343
|
-
VALUE
|
227
|
+
VALUE no_background(VALUE self)
|
344
228
|
{
|
345
229
|
CHECK;
|
346
|
-
|
347
|
-
|
348
|
-
if (argc == 1 && argv[0].is_kind_of(Rays::color_class()))
|
349
|
-
THIS->set_fill(to<Rays::Color&>(argv[0]));
|
350
|
-
else if (argc == 1 || argc == 2)
|
351
|
-
{
|
352
|
-
float v = to<float>(argv[0]);
|
353
|
-
float a = (argc >= 2) ? to<float>(argv[1]) : 1;
|
354
|
-
THIS->set_fill(v, v, v, a);
|
355
|
-
}
|
356
|
-
else
|
357
|
-
{
|
358
|
-
float r = to<float>(argv[0]);
|
359
|
-
float g = to<float>(argv[1]);
|
360
|
-
float b = to<float>(argv[2]);
|
361
|
-
float a = (argc == 4) ? to<float>(argv[3]) : 1;
|
362
|
-
THIS->set_fill(r, g, b, a);
|
363
|
-
}
|
364
|
-
|
230
|
+
THIS->no_background();
|
365
231
|
return self;
|
366
232
|
}
|
367
233
|
|
368
234
|
static
|
369
|
-
VALUE
|
235
|
+
VALUE set_fill(VALUE self)
|
370
236
|
{
|
371
237
|
CHECK;
|
372
|
-
THIS->
|
238
|
+
THIS->set_fill(to<Rays::Color>(argc, argv));
|
373
239
|
return self;
|
374
240
|
}
|
375
241
|
|
@@ -381,36 +247,18 @@ VALUE get_fill(VALUE self)
|
|
381
247
|
}
|
382
248
|
|
383
249
|
static
|
384
|
-
VALUE
|
250
|
+
VALUE no_fill(VALUE self)
|
385
251
|
{
|
386
252
|
CHECK;
|
387
|
-
|
388
|
-
|
389
|
-
if (argc == 1 && argv[0].is_kind_of(Rays::color_class()))
|
390
|
-
THIS->set_stroke(to<Rays::Color&>(argv[0]));
|
391
|
-
else if (argc == 1 || argc == 2)
|
392
|
-
{
|
393
|
-
float v = to<float>(argv[0]);
|
394
|
-
float a = (argc >= 2) ? to<float>(argv[1]) : 1;
|
395
|
-
THIS->set_stroke(v, v, v, a);
|
396
|
-
}
|
397
|
-
else
|
398
|
-
{
|
399
|
-
float r = to<float>(argv[0]);
|
400
|
-
float g = to<float>(argv[1]);
|
401
|
-
float b = to<float>(argv[2]);
|
402
|
-
float a = (argc == 4) ? to<float>(argv[3]) : 1;
|
403
|
-
THIS->set_stroke(r, g, b, a);
|
404
|
-
}
|
405
|
-
|
253
|
+
THIS->no_fill();
|
406
254
|
return self;
|
407
255
|
}
|
408
256
|
|
409
257
|
static
|
410
|
-
VALUE
|
258
|
+
VALUE set_stroke(VALUE self)
|
411
259
|
{
|
412
260
|
CHECK;
|
413
|
-
THIS->
|
261
|
+
THIS->set_stroke(to<Rays::Color>(argc, argv));
|
414
262
|
return self;
|
415
263
|
}
|
416
264
|
|
@@ -422,158 +270,121 @@ VALUE get_stroke(VALUE self)
|
|
422
270
|
}
|
423
271
|
|
424
272
|
static
|
425
|
-
VALUE
|
273
|
+
VALUE no_stroke(VALUE self)
|
426
274
|
{
|
427
275
|
CHECK;
|
428
|
-
|
429
|
-
|
430
|
-
if (argc == 1)
|
431
|
-
THIS->set_clip(to<Rays::Bounds&>(argv[0]));
|
432
|
-
else
|
433
|
-
{
|
434
|
-
coord x = to<coord>(argv[0]);
|
435
|
-
coord y = to<coord>(argv[1]);
|
436
|
-
coord w = to<coord>(argv[2]);
|
437
|
-
coord h = to<coord>(argv[3]);
|
438
|
-
THIS->set_clip(x, y, w, h);
|
439
|
-
}
|
440
|
-
|
276
|
+
THIS->no_stroke();
|
441
277
|
return self;
|
442
278
|
}
|
443
279
|
|
444
280
|
static
|
445
|
-
VALUE
|
281
|
+
VALUE set_stroke_width(VALUE self, VALUE width)
|
446
282
|
{
|
447
283
|
CHECK;
|
448
|
-
THIS->
|
284
|
+
THIS->set_stroke_width(to<coord>(width));
|
449
285
|
return self;
|
450
286
|
}
|
451
287
|
|
452
288
|
static
|
453
|
-
VALUE
|
289
|
+
VALUE get_stroke_width(VALUE self)
|
454
290
|
{
|
455
291
|
CHECK;
|
456
|
-
return value(THIS->
|
292
|
+
return value(THIS->stroke_width());
|
457
293
|
}
|
458
294
|
|
459
295
|
static
|
460
|
-
VALUE
|
296
|
+
VALUE set_nsegment(VALUE self, VALUE nsegment)
|
461
297
|
{
|
462
298
|
CHECK;
|
463
|
-
|
464
|
-
|
465
|
-
if (argc == 0 || argv[0].is_kind_of(Rays::font_class()))
|
466
|
-
{
|
467
|
-
const Rays::Font* f = argc == 0
|
468
|
-
? &Rays::default_font()
|
469
|
-
: to<Rays::Font*>(argv[0]);
|
470
|
-
if (!f || !*f)
|
471
|
-
argument_error(__FILE__, __LINE__);
|
472
|
-
|
473
|
-
THIS->set_font(*f);
|
474
|
-
}
|
475
|
-
else
|
476
|
-
{
|
477
|
-
const char* name = argv[0].c_str();
|
478
|
-
coord size = argc >= 2 ? to<coord>(argv[1]) : 0;
|
479
|
-
THIS->set_font(name, size);
|
480
|
-
}
|
481
|
-
|
299
|
+
THIS->set_nsegment(nsegment ? to<int>(nsegment) : 0);
|
482
300
|
return self;
|
483
301
|
}
|
484
302
|
|
485
303
|
static
|
486
|
-
VALUE
|
304
|
+
VALUE get_nsegment(VALUE self)
|
487
305
|
{
|
488
306
|
CHECK;
|
489
|
-
return value(THIS->
|
307
|
+
return value(THIS->nsegment());
|
490
308
|
}
|
491
309
|
|
492
310
|
static
|
493
|
-
VALUE
|
311
|
+
VALUE set_clip(VALUE self)
|
494
312
|
{
|
495
313
|
CHECK;
|
496
|
-
THIS->
|
314
|
+
THIS->set_clip(to<Rays::Bounds>(argc, argv));
|
497
315
|
return self;
|
498
316
|
}
|
499
317
|
|
500
318
|
static
|
501
|
-
VALUE
|
319
|
+
VALUE get_clip(VALUE self)
|
502
320
|
{
|
503
321
|
CHECK;
|
504
|
-
THIS->
|
505
|
-
return self;
|
322
|
+
return value(THIS->clip());
|
506
323
|
}
|
507
324
|
|
508
|
-
|
509
325
|
static
|
510
|
-
VALUE
|
326
|
+
VALUE no_clip(VALUE self)
|
511
327
|
{
|
512
328
|
CHECK;
|
513
|
-
THIS->
|
329
|
+
THIS->no_clip();
|
514
330
|
return self;
|
515
331
|
}
|
516
332
|
|
517
333
|
static
|
518
|
-
VALUE
|
334
|
+
VALUE set_font(VALUE self)
|
519
335
|
{
|
520
336
|
CHECK;
|
521
|
-
|
337
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2);
|
338
|
+
|
339
|
+
THIS->set_font(to<Rays::Font>(argc, argv));
|
522
340
|
return self;
|
523
341
|
}
|
524
342
|
|
525
343
|
static
|
526
|
-
VALUE
|
344
|
+
VALUE get_font(VALUE self)
|
527
345
|
{
|
528
346
|
CHECK;
|
529
|
-
|
347
|
+
return value(THIS->font());
|
348
|
+
}
|
530
349
|
|
531
|
-
|
532
|
-
|
350
|
+
static
|
351
|
+
VALUE set_shader(VALUE self)
|
352
|
+
{
|
353
|
+
CHECK;
|
354
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_shader", argc, 1);
|
533
355
|
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
switch (argc)
|
538
|
-
{
|
539
|
-
case 2: THIS->set_uniform(name, Ai(1)); break;
|
540
|
-
case 3: THIS->set_uniform(name, Ai(1), Ai(2)); break;
|
541
|
-
case 4: THIS->set_uniform(name, Ai(1), Ai(2), Ai(3)); break;
|
542
|
-
case 5: THIS->set_uniform(name, Ai(1), Ai(2), Ai(3), Ai(4)); break;
|
543
|
-
}
|
544
|
-
}
|
545
|
-
else if (argv[1].is_f())
|
546
|
-
{
|
547
|
-
switch (argc)
|
548
|
-
{
|
549
|
-
case 2: THIS->set_uniform(name, Af(1)); break;
|
550
|
-
case 3: THIS->set_uniform(name, Af(1), Af(2)); break;
|
551
|
-
case 4: THIS->set_uniform(name, Af(1), Af(2), Af(3)); break;
|
552
|
-
case 5: THIS->set_uniform(name, Af(1), Af(2), Af(3), Af(4)); break;
|
553
|
-
}
|
554
|
-
}
|
555
|
-
else
|
556
|
-
argument_error(__FILE__, __LINE__);
|
356
|
+
THIS->set_shader(to<Rays::Shader>(argc, argv));
|
357
|
+
return self;
|
358
|
+
}
|
557
359
|
|
558
|
-
|
559
|
-
|
360
|
+
static
|
361
|
+
VALUE get_shader(VALUE self)
|
362
|
+
{
|
363
|
+
CHECK;
|
364
|
+
return value(THIS->shader());
|
365
|
+
}
|
560
366
|
|
367
|
+
static
|
368
|
+
VALUE no_shader(VALUE self)
|
369
|
+
{
|
370
|
+
CHECK;
|
371
|
+
THIS->no_shader();
|
561
372
|
return self;
|
562
373
|
}
|
563
374
|
|
564
375
|
static
|
565
|
-
VALUE
|
376
|
+
VALUE push_state(VALUE self)
|
566
377
|
{
|
567
378
|
CHECK;
|
568
|
-
THIS->
|
379
|
+
THIS->push_state();
|
569
380
|
return self;
|
570
381
|
}
|
571
382
|
|
572
383
|
static
|
573
|
-
VALUE
|
384
|
+
VALUE pop_state(VALUE self)
|
574
385
|
{
|
575
386
|
CHECK;
|
576
|
-
THIS->
|
387
|
+
THIS->pop_state();
|
577
388
|
return self;
|
578
389
|
}
|
579
390
|
|
@@ -629,8 +440,8 @@ static
|
|
629
440
|
VALUE set_matrix(VALUE self)
|
630
441
|
{
|
631
442
|
CHECK;
|
632
|
-
THIS->set_matrix();
|
633
|
-
return
|
443
|
+
THIS->set_matrix(to<Rays::Matrix>(argc, argv));
|
444
|
+
return value(THIS->matrix());
|
634
445
|
}
|
635
446
|
|
636
447
|
static
|
@@ -669,47 +480,48 @@ Init_painter ()
|
|
669
480
|
|
670
481
|
rb_define_method(cPainter, "canvas", RUBY_METHOD_FUNC(canvas), 4);
|
671
482
|
rb_define_method(cPainter, "bounds", RUBY_METHOD_FUNC(bounds), 0);
|
483
|
+
rb_define_method(cPainter, "pixel_density", RUBY_METHOD_FUNC(pixel_density), 0);
|
672
484
|
|
673
485
|
rb_define_private_method(cPainter, "begin_paint", RUBY_METHOD_FUNC(begin_paint), 0);
|
674
486
|
rb_define_private_method(cPainter, "end_paint", RUBY_METHOD_FUNC(end_paint), 0);
|
675
487
|
rb_define_method(cPainter, "clear", RUBY_METHOD_FUNC(clear), 0);
|
676
|
-
rb_define_method(cPainter, "
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
rb_define_method(cPainter, "arc", RUBY_METHOD_FUNC(arc), -1);
|
488
|
+
rb_define_method(cPainter, "polygon", RUBY_METHOD_FUNC(polygon), 1);
|
489
|
+
rb_define_private_method(cPainter, "draw_line", RUBY_METHOD_FUNC(line), 2);
|
490
|
+
rb_define_private_method(cPainter, "draw_polyline", RUBY_METHOD_FUNC(polyline), 1);
|
491
|
+
rb_define_private_method(cPainter, "draw_rect", RUBY_METHOD_FUNC(rect), 6);
|
492
|
+
rb_define_private_method(cPainter, "draw_ellipse", RUBY_METHOD_FUNC(ellipse), 6);
|
682
493
|
rb_define_method(cPainter, "image", RUBY_METHOD_FUNC(image), -1);
|
683
494
|
rb_define_method(cPainter, "text", RUBY_METHOD_FUNC(text), -1);
|
684
495
|
|
685
|
-
|
686
|
-
|
496
|
+
rb_define_method(cPainter, "background=", RUBY_METHOD_FUNC(set_background), -1);
|
497
|
+
rb_define_method(cPainter, "background", RUBY_METHOD_FUNC(get_background), 0);
|
687
498
|
rb_define_method(cPainter, "no_background", RUBY_METHOD_FUNC(no_background), 0);
|
688
|
-
|
689
|
-
|
499
|
+
rb_define_method(cPainter, "fill=", RUBY_METHOD_FUNC(set_fill), -1);
|
500
|
+
rb_define_method(cPainter, "fill", RUBY_METHOD_FUNC(get_fill), 0);
|
690
501
|
rb_define_method(cPainter, "no_fill", RUBY_METHOD_FUNC(no_fill), 0);
|
691
|
-
|
692
|
-
|
502
|
+
rb_define_method(cPainter, "stroke=", RUBY_METHOD_FUNC(set_stroke), -1);
|
503
|
+
rb_define_method(cPainter, "stroke", RUBY_METHOD_FUNC(get_stroke), 0);
|
693
504
|
rb_define_method(cPainter, "no_stroke", RUBY_METHOD_FUNC(no_stroke), 0);
|
694
|
-
|
695
|
-
|
505
|
+
rb_define_method(cPainter, "stroke_width=", RUBY_METHOD_FUNC(set_stroke_width), 1);
|
506
|
+
rb_define_method(cPainter, "stroke_width", RUBY_METHOD_FUNC(get_stroke_width), 0);
|
507
|
+
rb_define_method(cPainter, "nsegment=", RUBY_METHOD_FUNC(set_nsegment), 1);
|
508
|
+
rb_define_method(cPainter, "nsegment", RUBY_METHOD_FUNC(get_nsegment), 0);
|
509
|
+
rb_define_method(cPainter, "clip=", RUBY_METHOD_FUNC(set_clip), -1);
|
510
|
+
rb_define_method(cPainter, "clip", RUBY_METHOD_FUNC(get_clip), 0);
|
696
511
|
rb_define_method(cPainter, "no_clip", RUBY_METHOD_FUNC(no_clip), 0);
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
rb_define_method(cPainter, "
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
rb_define_private_method(cPainter, "set_uniform", RUBY_METHOD_FUNC(set_uniform), -1);
|
705
|
-
rb_define_method(cPainter, "push_shader", RUBY_METHOD_FUNC(push_shader), 0);
|
706
|
-
rb_define_method(cPainter, "pop_shader", RUBY_METHOD_FUNC(pop_shader), 0);
|
512
|
+
rb_define_method(cPainter, "font=", RUBY_METHOD_FUNC(set_font), -1);
|
513
|
+
rb_define_method(cPainter, "font", RUBY_METHOD_FUNC(get_font), 0);
|
514
|
+
rb_define_private_method(cPainter, "set_shader", RUBY_METHOD_FUNC(set_shader), -1);
|
515
|
+
rb_define_method(cPainter, "shader", RUBY_METHOD_FUNC(get_shader), 0);
|
516
|
+
rb_define_method(cPainter, "no_shader", RUBY_METHOD_FUNC(no_shader), 0);
|
517
|
+
rb_define_method(cPainter, "push_state", RUBY_METHOD_FUNC(push_state), 0);
|
518
|
+
rb_define_method(cPainter, "pop_state", RUBY_METHOD_FUNC(pop_state), 0);
|
707
519
|
|
708
520
|
rb_define_method(cPainter, "translate", RUBY_METHOD_FUNC(translate), -1);
|
709
521
|
rb_define_method(cPainter, "scale", RUBY_METHOD_FUNC(scale), -1);
|
710
522
|
rb_define_method(cPainter, "rotate", RUBY_METHOD_FUNC(rotate), -1);
|
711
|
-
|
712
|
-
|
523
|
+
rb_define_method(cPainter, "matrix=", RUBY_METHOD_FUNC(set_matrix), -1);
|
524
|
+
rb_define_method(cPainter, "matrix", RUBY_METHOD_FUNC(get_matrix), 0);
|
713
525
|
rb_define_method(cPainter, "push_matrix", RUBY_METHOD_FUNC(push_matrix), 0);
|
714
526
|
rb_define_method(cPainter, "pop_matrix", RUBY_METHOD_FUNC(pop_matrix), 0);
|
715
527
|
}
|