rays 0.1.11 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.doc/ext/rays/bitmap.cpp +22 -76
- data/.doc/ext/rays/bounds.cpp +95 -125
- data/.doc/ext/rays/camera.cpp +88 -0
- data/.doc/ext/rays/color.cpp +223 -45
- data/.doc/ext/rays/color_space.cpp +146 -46
- data/.doc/ext/rays/defs.cpp +183 -0
- data/.doc/ext/rays/font.cpp +69 -21
- data/.doc/ext/rays/image.cpp +26 -37
- data/.doc/ext/rays/matrix.cpp +186 -29
- data/.doc/ext/rays/native.cpp +14 -8
- data/.doc/ext/rays/noise.cpp +53 -0
- data/.doc/ext/rays/painter.cpp +187 -292
- data/.doc/ext/rays/point.cpp +96 -77
- data/.doc/ext/rays/polygon.cpp +313 -0
- data/.doc/ext/rays/polygon_line.cpp +96 -0
- data/.doc/ext/rays/polyline.cpp +167 -0
- data/.doc/ext/rays/rays.cpp +103 -12
- data/.doc/ext/rays/shader.cpp +83 -9
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/Rakefile +24 -9
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +22 -80
- data/ext/rays/bounds.cpp +100 -128
- data/ext/rays/camera.cpp +94 -0
- data/ext/rays/color.cpp +231 -51
- data/ext/rays/color_space.cpp +149 -47
- data/ext/rays/defs.cpp +183 -0
- data/ext/rays/defs.h +26 -2
- data/ext/rays/extconf.rb +2 -3
- data/ext/rays/font.cpp +74 -24
- data/ext/rays/image.cpp +28 -40
- data/ext/rays/matrix.cpp +198 -30
- data/ext/rays/native.cpp +14 -8
- data/ext/rays/noise.cpp +55 -0
- data/ext/rays/painter.cpp +203 -298
- data/ext/rays/point.cpp +105 -81
- data/ext/rays/polygon.cpp +329 -0
- data/ext/rays/polygon_line.cpp +99 -0
- data/ext/rays/polyline.cpp +176 -0
- data/ext/rays/rays.cpp +103 -13
- 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/camera.h +49 -0
- data/include/rays/color.h +25 -14
- data/include/rays/color_space.h +15 -10
- data/include/rays/coord.h +114 -0
- data/include/rays/debug.h +22 -0
- data/include/rays/defs.h +36 -0
- data/include/rays/exception.h +6 -2
- data/include/rays/font.h +4 -4
- data/include/rays/image.h +12 -18
- 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 +89 -93
- data/include/rays/point.h +44 -51
- data/include/rays/polygon.h +198 -0
- data/include/rays/polyline.h +71 -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/camera.h +41 -0
- 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/rays.h +8 -0
- data/include/rays/ruby/shader.h +1 -1
- data/include/rays/shader.h +36 -8
- data/lib/rays.rb +7 -2
- data/lib/rays/bitmap.rb +0 -15
- data/lib/rays/bounds.rb +17 -23
- data/lib/rays/camera.rb +21 -0
- data/lib/rays/color.rb +20 -47
- data/lib/rays/color_space.rb +13 -13
- data/lib/rays/image.rb +3 -7
- data/lib/rays/matrix.rb +28 -0
- data/lib/rays/module.rb +4 -19
- data/lib/rays/painter.rb +78 -93
- data/lib/rays/point.rb +13 -21
- data/lib/rays/polygon.rb +58 -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 +52 -34
- 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 +172 -98
- data/src/image.h +25 -0
- data/src/ios/bitmap.h +21 -0
- data/src/ios/bitmap.mm +129 -110
- data/src/ios/camera.mm +236 -0
- data/src/ios/font.mm +50 -62
- 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.h +21 -0
- data/src/osx/bitmap.mm +129 -110
- data/src/osx/camera.mm +236 -0
- data/src/osx/font.mm +49 -62
- 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 +845 -671
- data/src/painter.h +24 -0
- data/src/point.cpp +140 -119
- data/src/polygon.cpp +1266 -0
- data/src/polygon.h +32 -0
- data/src/polyline.cpp +160 -0
- data/src/polyline.h +69 -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_font.rb +5 -0
- data/test/test_image.rb +24 -20
- data/test/test_matrix.rb +106 -0
- data/test/test_painter.rb +157 -51
- data/test/test_painter_shape.rb +102 -0
- data/test/test_point.rb +29 -0
- data/test/test_polygon.rb +234 -0
- data/test/test_polygon_line.rb +167 -0
- data/test/test_polyline.rb +171 -0
- data/test/test_shader.rb +9 -9
- metadata +102 -70
- 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,24 +1,25 @@
|
|
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_painter ();
|
13
|
+
void Init_polyline ();
|
14
|
+
void Init_polygon_line ();
|
15
|
+
void Init_polygon ();
|
15
16
|
void Init_bitmap ();
|
16
|
-
void Init_texture ();
|
17
17
|
void Init_image ();
|
18
18
|
void Init_font ();
|
19
19
|
void Init_shader ();
|
20
|
+
void Init_camera ();
|
20
21
|
|
21
|
-
void
|
22
|
+
void Init_noise ();
|
22
23
|
|
23
24
|
|
24
25
|
extern "C" void
|
@@ -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_painter();
|
45
|
+
Init_polyline();
|
46
|
+
Init_polygon_line();
|
47
|
+
Init_polygon();
|
42
48
|
Init_bitmap();
|
43
|
-
Init_texture();
|
44
49
|
Init_image();
|
45
50
|
Init_font();
|
46
51
|
Init_shader();
|
52
|
+
Init_camera();
|
47
53
|
|
48
|
-
|
54
|
+
Init_noise();
|
49
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,96 @@ 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
|
-
|
109
|
-
|
94
|
+
std::vector<Rays::Point> points;
|
95
|
+
get_line_args(&points, args.size(), args.as_array());
|
96
|
+
|
97
|
+
THIS->line(&points[0], points.size(), loop);
|
98
|
+
return self;
|
99
|
+
}
|
100
|
+
|
101
|
+
static
|
102
|
+
VALUE polyline(VALUE self, VALUE poly)
|
103
|
+
{
|
104
|
+
CHECK;
|
110
105
|
|
111
|
-
THIS->
|
106
|
+
THIS->line(to<Rays::Polyline&>(poly));
|
112
107
|
return self;
|
113
108
|
}
|
114
109
|
|
115
110
|
static
|
116
|
-
VALUE
|
111
|
+
VALUE rect(VALUE self, VALUE args, VALUE round, VALUE lefttop, VALUE righttop, VALUE leftbottom, VALUE rightbottom)
|
117
112
|
{
|
118
113
|
CHECK;
|
119
|
-
if (argc <= 0)
|
120
|
-
argument_error(__FILE__, __LINE__, "Painter#polygon");
|
121
114
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
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());
|
126
121
|
|
127
|
-
THIS->
|
122
|
+
THIS->rect(x, y, w, h, lt, rt, lb, rb);
|
128
123
|
return self;
|
129
124
|
}
|
130
125
|
|
131
126
|
static
|
132
|
-
VALUE
|
127
|
+
VALUE ellipse(VALUE self, VALUE args, VALUE center, VALUE radius, VALUE hole, VALUE angle_from, VALUE angle_to)
|
133
128
|
{
|
134
129
|
CHECK;
|
135
|
-
check_arg_count(__FILE__, __LINE__, "Painter#rect", argc, 1, 2, 3, 4, 5, 6);
|
136
130
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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
|
-
}
|
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());
|
154
139
|
|
140
|
+
THIS->ellipse(x, y, w, h, hole_size, from, to_);
|
155
141
|
return self;
|
156
142
|
}
|
157
143
|
|
158
144
|
static
|
159
|
-
VALUE
|
145
|
+
VALUE curve(VALUE self, VALUE args, VALUE loop)
|
160
146
|
{
|
161
147
|
CHECK;
|
162
|
-
check_arg_count(__FILE__, __LINE__, "Painter#ellipse", argc, 1, 2, 3, 4, 5, 6);
|
163
148
|
|
164
|
-
if (
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
THIS->ellipse(b, min_, nseg);
|
170
|
-
}
|
171
|
-
else
|
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
|
-
}
|
149
|
+
if (args.empty())
|
150
|
+
argument_error(__FILE__, __LINE__);
|
151
|
+
|
152
|
+
std::vector<Rays::Point> points;
|
153
|
+
get_line_args(&points, args.size(), args.as_array());
|
181
154
|
|
155
|
+
THIS->curve(&points[0], points.size(), loop);
|
182
156
|
return self;
|
183
157
|
}
|
184
158
|
|
185
159
|
static
|
186
|
-
VALUE
|
160
|
+
VALUE bezier(VALUE self, VALUE args, VALUE loop)
|
187
161
|
{
|
188
162
|
CHECK;
|
189
|
-
check_arg_count(__FILE__, __LINE__, "Painter#ellipse", argc, 1, 2, 3, 4, 5, 6, 7, 8);
|
190
163
|
|
191
|
-
if (
|
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
|
-
}
|
164
|
+
if (args.empty())
|
165
|
+
argument_error(__FILE__, __LINE__);
|
212
166
|
|
167
|
+
std::vector<Rays::Point> points;
|
168
|
+
get_line_args(&points, args.size(), args.as_array());
|
169
|
+
|
170
|
+
THIS->bezier(&points[0], points.size(), loop);
|
213
171
|
return self;
|
214
172
|
}
|
215
173
|
|
@@ -260,7 +218,7 @@ static
|
|
260
218
|
VALUE text(VALUE self)
|
261
219
|
{
|
262
220
|
CHECK;
|
263
|
-
check_arg_count(__FILE__, __LINE__, "Painter#text", argc, 1, 3,
|
221
|
+
check_arg_count(__FILE__, __LINE__, "Painter#text", argc, 1, 3, 5);
|
264
222
|
|
265
223
|
if (argc == 1)
|
266
224
|
THIS->text(argv[0].c_str());
|
@@ -269,61 +227,32 @@ VALUE text(VALUE self)
|
|
269
227
|
coord x = to<coord>(argv[1]), y = to<coord>(argv[2]);
|
270
228
|
THIS->text(argv[0].c_str(), x, y);
|
271
229
|
}
|
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
230
|
else if (argc == 5)
|
282
231
|
{
|
283
232
|
coord x = to<coord>(argv[1]), w = to<coord>(argv[3]);
|
284
233
|
coord y = to<coord>(argv[2]), h = to<coord>(argv[4]);
|
285
234
|
THIS->text(argv[0].c_str(), x, y, w, h);
|
286
235
|
}
|
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
236
|
|
298
237
|
return self;
|
299
238
|
}
|
300
239
|
|
240
|
+
|
301
241
|
static
|
302
242
|
VALUE set_background(VALUE self)
|
303
243
|
{
|
304
244
|
CHECK;
|
305
|
-
|
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
|
-
|
245
|
+
THIS->set_background(to<Rays::Color>(argc, argv));
|
324
246
|
return self;
|
325
247
|
}
|
326
248
|
|
249
|
+
static
|
250
|
+
VALUE get_background(VALUE self)
|
251
|
+
{
|
252
|
+
CHECK;
|
253
|
+
return value(THIS->background());
|
254
|
+
}
|
255
|
+
|
327
256
|
static
|
328
257
|
VALUE no_background(VALUE self)
|
329
258
|
{
|
@@ -333,36 +262,18 @@ VALUE no_background(VALUE self)
|
|
333
262
|
}
|
334
263
|
|
335
264
|
static
|
336
|
-
VALUE
|
265
|
+
VALUE set_fill(VALUE self)
|
337
266
|
{
|
338
267
|
CHECK;
|
339
|
-
|
268
|
+
THIS->set_fill(to<Rays::Color>(argc, argv));
|
269
|
+
return self;
|
340
270
|
}
|
341
271
|
|
342
272
|
static
|
343
|
-
VALUE
|
273
|
+
VALUE get_fill(VALUE self)
|
344
274
|
{
|
345
275
|
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
|
-
|
365
|
-
return self;
|
276
|
+
return value(THIS->fill());
|
366
277
|
}
|
367
278
|
|
368
279
|
static
|
@@ -374,36 +285,18 @@ VALUE no_fill(VALUE self)
|
|
374
285
|
}
|
375
286
|
|
376
287
|
static
|
377
|
-
VALUE
|
288
|
+
VALUE set_stroke(VALUE self)
|
378
289
|
{
|
379
290
|
CHECK;
|
380
|
-
|
291
|
+
THIS->set_stroke(to<Rays::Color>(argc, argv));
|
292
|
+
return self;
|
381
293
|
}
|
382
294
|
|
383
295
|
static
|
384
|
-
VALUE
|
296
|
+
VALUE get_stroke(VALUE self)
|
385
297
|
{
|
386
298
|
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
|
-
|
406
|
-
return self;
|
299
|
+
return value(THIS->stroke());
|
407
300
|
}
|
408
301
|
|
409
302
|
static
|
@@ -415,165 +308,158 @@ VALUE no_stroke(VALUE self)
|
|
415
308
|
}
|
416
309
|
|
417
310
|
static
|
418
|
-
VALUE
|
311
|
+
VALUE set_stroke_width(VALUE self, VALUE width)
|
419
312
|
{
|
420
313
|
CHECK;
|
421
|
-
|
314
|
+
THIS->set_stroke_width(to<coord>(width));
|
315
|
+
return self;
|
422
316
|
}
|
423
317
|
|
424
318
|
static
|
425
|
-
VALUE
|
319
|
+
VALUE get_stroke_width(VALUE self)
|
426
320
|
{
|
427
321
|
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
|
-
|
441
|
-
return self;
|
322
|
+
return value(THIS->stroke_width());
|
442
323
|
}
|
443
324
|
|
444
325
|
static
|
445
|
-
VALUE
|
326
|
+
VALUE set_stroke_cap(VALUE self, VALUE cap)
|
446
327
|
{
|
447
328
|
CHECK;
|
448
|
-
THIS->
|
329
|
+
THIS->set_stroke_cap(to<Rays::CapType>(cap));
|
449
330
|
return self;
|
450
331
|
}
|
451
332
|
|
452
333
|
static
|
453
|
-
VALUE
|
334
|
+
VALUE get_stroke_cap(VALUE self)
|
454
335
|
{
|
455
336
|
CHECK;
|
456
|
-
return value(THIS->
|
337
|
+
return value(THIS->stroke_cap());
|
457
338
|
}
|
458
339
|
|
459
340
|
static
|
460
|
-
VALUE
|
341
|
+
VALUE set_stroke_join(VALUE self, VALUE join)
|
461
342
|
{
|
462
343
|
CHECK;
|
463
|
-
|
464
|
-
|
465
|
-
|
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__);
|
344
|
+
THIS->set_stroke_join(to<Rays::JoinType>(join));
|
345
|
+
return self;
|
346
|
+
}
|
472
347
|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
THIS->set_font(name, size);
|
480
|
-
}
|
348
|
+
static
|
349
|
+
VALUE get_stroke_join(VALUE self)
|
350
|
+
{
|
351
|
+
CHECK;
|
352
|
+
return value(THIS->stroke_join());
|
353
|
+
}
|
481
354
|
|
355
|
+
static
|
356
|
+
VALUE set_miter_limit(VALUE self, VALUE limit)
|
357
|
+
{
|
358
|
+
CHECK;
|
359
|
+
THIS->set_miter_limit(to<coord>(limit));
|
482
360
|
return self;
|
483
361
|
}
|
484
362
|
|
485
363
|
static
|
486
|
-
VALUE
|
364
|
+
VALUE get_miter_limit(VALUE self)
|
487
365
|
{
|
488
366
|
CHECK;
|
489
|
-
return value(THIS->
|
367
|
+
return value(THIS->miter_limit());
|
490
368
|
}
|
491
369
|
|
492
370
|
static
|
493
|
-
VALUE
|
371
|
+
VALUE set_nsegment(VALUE self, VALUE nsegment)
|
494
372
|
{
|
495
373
|
CHECK;
|
496
|
-
THIS->
|
374
|
+
THIS->set_nsegment(nsegment ? to<int>(nsegment) : 0);
|
497
375
|
return self;
|
498
376
|
}
|
499
377
|
|
500
378
|
static
|
501
|
-
VALUE
|
379
|
+
VALUE get_nsegment(VALUE self)
|
502
380
|
{
|
503
381
|
CHECK;
|
504
|
-
THIS->
|
382
|
+
return value(THIS->nsegment());
|
383
|
+
}
|
384
|
+
|
385
|
+
static
|
386
|
+
VALUE set_clip(VALUE self)
|
387
|
+
{
|
388
|
+
CHECK;
|
389
|
+
THIS->set_clip(to<Rays::Bounds>(argc, argv));
|
505
390
|
return self;
|
506
391
|
}
|
507
392
|
|
393
|
+
static
|
394
|
+
VALUE get_clip(VALUE self)
|
395
|
+
{
|
396
|
+
CHECK;
|
397
|
+
return value(THIS->clip());
|
398
|
+
}
|
508
399
|
|
509
400
|
static
|
510
|
-
VALUE
|
401
|
+
VALUE no_clip(VALUE self)
|
511
402
|
{
|
512
403
|
CHECK;
|
513
|
-
THIS->
|
404
|
+
THIS->no_clip();
|
514
405
|
return self;
|
515
406
|
}
|
516
407
|
|
517
408
|
static
|
518
|
-
VALUE
|
409
|
+
VALUE set_font(VALUE self)
|
519
410
|
{
|
520
411
|
CHECK;
|
521
|
-
|
412
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2);
|
413
|
+
|
414
|
+
THIS->set_font(to<Rays::Font>(argc, argv));
|
522
415
|
return self;
|
523
416
|
}
|
524
417
|
|
525
418
|
static
|
526
|
-
VALUE
|
419
|
+
VALUE get_font(VALUE self)
|
527
420
|
{
|
528
421
|
CHECK;
|
529
|
-
|
422
|
+
return value(THIS->font());
|
423
|
+
}
|
530
424
|
|
531
|
-
|
532
|
-
|
425
|
+
static
|
426
|
+
VALUE set_shader(VALUE self)
|
427
|
+
{
|
428
|
+
CHECK;
|
429
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_shader", argc, 1);
|
533
430
|
|
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__);
|
431
|
+
THIS->set_shader(to<Rays::Shader>(argc, argv));
|
432
|
+
return self;
|
433
|
+
}
|
557
434
|
|
558
|
-
|
559
|
-
|
435
|
+
static
|
436
|
+
VALUE get_shader(VALUE self)
|
437
|
+
{
|
438
|
+
CHECK;
|
439
|
+
return value(THIS->shader());
|
440
|
+
}
|
560
441
|
|
442
|
+
static
|
443
|
+
VALUE no_shader(VALUE self)
|
444
|
+
{
|
445
|
+
CHECK;
|
446
|
+
THIS->no_shader();
|
561
447
|
return self;
|
562
448
|
}
|
563
449
|
|
564
450
|
static
|
565
|
-
VALUE
|
451
|
+
VALUE push_state(VALUE self)
|
566
452
|
{
|
567
453
|
CHECK;
|
568
|
-
THIS->
|
454
|
+
THIS->push_state();
|
569
455
|
return self;
|
570
456
|
}
|
571
457
|
|
572
458
|
static
|
573
|
-
VALUE
|
459
|
+
VALUE pop_state(VALUE self)
|
574
460
|
{
|
575
461
|
CHECK;
|
576
|
-
THIS->
|
462
|
+
THIS->pop_state();
|
577
463
|
return self;
|
578
464
|
}
|
579
465
|
|
@@ -629,8 +515,8 @@ static
|
|
629
515
|
VALUE set_matrix(VALUE self)
|
630
516
|
{
|
631
517
|
CHECK;
|
632
|
-
THIS->set_matrix();
|
633
|
-
return
|
518
|
+
THIS->set_matrix(to<Rays::Matrix>(argc, argv));
|
519
|
+
return value(THIS->matrix());
|
634
520
|
}
|
635
521
|
|
636
522
|
static
|
@@ -669,47 +555,56 @@ Init_painter ()
|
|
669
555
|
|
670
556
|
rb_define_method(cPainter, "canvas", RUBY_METHOD_FUNC(canvas), 4);
|
671
557
|
rb_define_method(cPainter, "bounds", RUBY_METHOD_FUNC(bounds), 0);
|
558
|
+
rb_define_method(cPainter, "pixel_density", RUBY_METHOD_FUNC(pixel_density), 0);
|
672
559
|
|
673
560
|
rb_define_private_method(cPainter, "begin_paint", RUBY_METHOD_FUNC(begin_paint), 0);
|
674
561
|
rb_define_private_method(cPainter, "end_paint", RUBY_METHOD_FUNC(end_paint), 0);
|
675
562
|
rb_define_method(cPainter, "clear", RUBY_METHOD_FUNC(clear), 0);
|
676
|
-
rb_define_method(cPainter, "
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
563
|
+
rb_define_method(cPainter, "polygon", RUBY_METHOD_FUNC(polygon), 1);
|
564
|
+
rb_define_private_method(cPainter, "draw_line", RUBY_METHOD_FUNC(line), 2);
|
565
|
+
rb_define_private_method(cPainter, "draw_polyline", RUBY_METHOD_FUNC(polyline), 1);
|
566
|
+
rb_define_private_method(cPainter, "draw_rect", RUBY_METHOD_FUNC(rect), 6);
|
567
|
+
rb_define_private_method(cPainter, "draw_ellipse", RUBY_METHOD_FUNC(ellipse), 6);
|
568
|
+
rb_define_private_method(cPainter, "draw_curve", RUBY_METHOD_FUNC(curve), 2);
|
569
|
+
rb_define_private_method(cPainter, "draw_bezier", RUBY_METHOD_FUNC(bezier), 2);
|
682
570
|
rb_define_method(cPainter, "image", RUBY_METHOD_FUNC(image), -1);
|
683
571
|
rb_define_method(cPainter, "text", RUBY_METHOD_FUNC(text), -1);
|
684
572
|
|
685
|
-
|
686
|
-
|
573
|
+
rb_define_method(cPainter, "background=", RUBY_METHOD_FUNC(set_background), -1);
|
574
|
+
rb_define_method(cPainter, "background", RUBY_METHOD_FUNC(get_background), 0);
|
687
575
|
rb_define_method(cPainter, "no_background", RUBY_METHOD_FUNC(no_background), 0);
|
688
|
-
|
689
|
-
|
576
|
+
rb_define_method(cPainter, "fill=", RUBY_METHOD_FUNC(set_fill), -1);
|
577
|
+
rb_define_method(cPainter, "fill", RUBY_METHOD_FUNC(get_fill), 0);
|
690
578
|
rb_define_method(cPainter, "no_fill", RUBY_METHOD_FUNC(no_fill), 0);
|
691
|
-
|
692
|
-
|
579
|
+
rb_define_method(cPainter, "stroke=", RUBY_METHOD_FUNC(set_stroke), -1);
|
580
|
+
rb_define_method(cPainter, "stroke", RUBY_METHOD_FUNC(get_stroke), 0);
|
693
581
|
rb_define_method(cPainter, "no_stroke", RUBY_METHOD_FUNC(no_stroke), 0);
|
694
|
-
|
695
|
-
|
582
|
+
rb_define_method(cPainter, "stroke_width=", RUBY_METHOD_FUNC(set_stroke_width), 1);
|
583
|
+
rb_define_method(cPainter, "stroke_width", RUBY_METHOD_FUNC(get_stroke_width), 0);
|
584
|
+
rb_define_method(cPainter, "stroke_cap=", RUBY_METHOD_FUNC(set_stroke_cap), 1);
|
585
|
+
rb_define_method(cPainter, "stroke_cap", RUBY_METHOD_FUNC(get_stroke_cap), 0);
|
586
|
+
rb_define_method(cPainter, "stroke_join=", RUBY_METHOD_FUNC(set_stroke_join), 1);
|
587
|
+
rb_define_method(cPainter, "stroke_join", RUBY_METHOD_FUNC(get_stroke_join), 0);
|
588
|
+
rb_define_method(cPainter, "miter_limit=", RUBY_METHOD_FUNC(set_miter_limit), 1);
|
589
|
+
rb_define_method(cPainter, "miter_limit", RUBY_METHOD_FUNC(get_miter_limit), 0);
|
590
|
+
rb_define_method(cPainter, "nsegment=", RUBY_METHOD_FUNC(set_nsegment), 1);
|
591
|
+
rb_define_method(cPainter, "nsegment", RUBY_METHOD_FUNC(get_nsegment), 0);
|
592
|
+
rb_define_method(cPainter, "clip=", RUBY_METHOD_FUNC(set_clip), -1);
|
593
|
+
rb_define_method(cPainter, "clip", RUBY_METHOD_FUNC(get_clip), 0);
|
696
594
|
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);
|
595
|
+
rb_define_method(cPainter, "font=", RUBY_METHOD_FUNC(set_font), -1);
|
596
|
+
rb_define_method(cPainter, "font", RUBY_METHOD_FUNC(get_font), 0);
|
597
|
+
rb_define_private_method(cPainter, "set_shader", RUBY_METHOD_FUNC(set_shader), -1);
|
598
|
+
rb_define_method(cPainter, "shader", RUBY_METHOD_FUNC(get_shader), 0);
|
599
|
+
rb_define_method(cPainter, "no_shader", RUBY_METHOD_FUNC(no_shader), 0);
|
600
|
+
rb_define_method(cPainter, "push_state", RUBY_METHOD_FUNC(push_state), 0);
|
601
|
+
rb_define_method(cPainter, "pop_state", RUBY_METHOD_FUNC(pop_state), 0);
|
707
602
|
|
708
603
|
rb_define_method(cPainter, "translate", RUBY_METHOD_FUNC(translate), -1);
|
709
604
|
rb_define_method(cPainter, "scale", RUBY_METHOD_FUNC(scale), -1);
|
710
605
|
rb_define_method(cPainter, "rotate", RUBY_METHOD_FUNC(rotate), -1);
|
711
|
-
|
712
|
-
|
606
|
+
rb_define_method(cPainter, "matrix=", RUBY_METHOD_FUNC(set_matrix), -1);
|
607
|
+
rb_define_method(cPainter, "matrix", RUBY_METHOD_FUNC(get_matrix), 0);
|
713
608
|
rb_define_method(cPainter, "push_matrix", RUBY_METHOD_FUNC(push_matrix), 0);
|
714
609
|
rb_define_method(cPainter, "pop_matrix", RUBY_METHOD_FUNC(pop_matrix), 0);
|
715
610
|
}
|