rays 0.1.12 → 0.1.17
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 +171 -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 +23 -81
- data/ext/rays/bounds.cpp +100 -128
- data/ext/rays/camera.cpp +186 -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 +74 -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 +24 -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 +23 -0
- data/src/ios/bitmap.mm +133 -110
- data/src/ios/camera.mm +510 -0
- data/src/ios/font.mm +50 -62
- data/src/ios/helper.h +4 -4
- 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 +23 -0
- data/src/osx/bitmap.mm +133 -110
- data/src/osx/camera.mm +451 -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/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
|
}
|
data/ext/rays/noise.cpp
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#include "rays/noise.h"
|
2
|
+
#include "rays/ruby/point.h"
|
3
|
+
#include "defs.h"
|
4
|
+
|
5
|
+
|
6
|
+
static
|
7
|
+
RUCY_DEFN(perlin)
|
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
|
+
RUCY_END
|
26
|
+
|
27
|
+
static
|
28
|
+
RUCY_DEFN(simplex)
|
29
|
+
{
|
30
|
+
check_arg_count(__FILE__, __LINE__, "Rays.simplex", argc, 1, 2, 3, 4);
|
31
|
+
|
32
|
+
coord noise = 0;
|
33
|
+
if (argc == 4)
|
34
|
+
{
|
35
|
+
noise = Rays::simplex(
|
36
|
+
to<coord>(argv[0]),
|
37
|
+
to<coord>(argv[1]),
|
38
|
+
to<coord>(argv[2]),
|
39
|
+
to<coord>(argv[3]));
|
40
|
+
}
|
41
|
+
else
|
42
|
+
noise = Rays::simplex(to<Rays::Point>(argc, argv));
|
43
|
+
|
44
|
+
return value(noise);
|
45
|
+
}
|
46
|
+
RUCY_END
|
47
|
+
|
48
|
+
|
49
|
+
void
|
50
|
+
Init_noise ()
|
51
|
+
{
|
52
|
+
Module mRays = define_module("Rays");
|
53
|
+
mRays.define_singleton_method("perlin", perlin);
|
54
|
+
mRays.define_singleton_method("simplex", simplex);
|
55
|
+
}
|
data/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)
|
@@ -55,6 +49,14 @@ RUCY_DEF0(bounds)
|
|
55
49
|
}
|
56
50
|
RUCY_END
|
57
51
|
|
52
|
+
static
|
53
|
+
RUCY_DEF0(pixel_density)
|
54
|
+
{
|
55
|
+
CHECK;
|
56
|
+
return value(THIS->pixel_density());
|
57
|
+
}
|
58
|
+
RUCY_END
|
59
|
+
|
58
60
|
|
59
61
|
static
|
60
62
|
RUCY_DEF0(begin_paint)
|
@@ -83,144 +85,102 @@ RUCY_DEF0(clear)
|
|
83
85
|
RUCY_END
|
84
86
|
|
85
87
|
static
|
86
|
-
|
88
|
+
RUCY_DEF1(polygon, poly)
|
87
89
|
{
|
88
90
|
CHECK;
|
89
|
-
check_arg_count(__FILE__, __LINE__, "Painter#line", argc, 2, 4);
|
90
|
-
|
91
|
-
if (argc == 2)
|
92
|
-
THIS->line(to<Rays::Point&>(argv[0]), to<Rays::Point&>(argv[1]));
|
93
|
-
else
|
94
|
-
{
|
95
|
-
coord x1 = to<coord>(argv[0]);
|
96
|
-
coord y1 = to<coord>(argv[1]);
|
97
|
-
coord x2 = to<coord>(argv[2]);
|
98
|
-
coord y2 = to<coord>(argv[3]);
|
99
|
-
THIS->line(x1, y1, x2, y2);
|
100
|
-
}
|
101
91
|
|
92
|
+
THIS->polygon(to<Rays::Polygon&>(poly));
|
102
93
|
return self;
|
103
94
|
}
|
104
95
|
RUCY_END
|
105
96
|
|
106
97
|
static
|
107
|
-
|
98
|
+
RUCY_DEF2(line, args, loop)
|
108
99
|
{
|
109
100
|
CHECK;
|
110
|
-
if (argc <= 0)
|
111
|
-
argument_error(__FILE__, __LINE__, "Painter#lines");
|
112
101
|
|
113
|
-
std::vector<Rays::
|
114
|
-
points.
|
115
|
-
|
116
|
-
|
102
|
+
std::vector<Rays::Point> points;
|
103
|
+
get_line_args(&points, args.size(), args.as_array());
|
104
|
+
|
105
|
+
THIS->line(&points[0], points.size(), loop);
|
106
|
+
return self;
|
107
|
+
}
|
108
|
+
RUCY_END
|
109
|
+
|
110
|
+
static
|
111
|
+
RUCY_DEF1(polyline, poly)
|
112
|
+
{
|
113
|
+
CHECK;
|
117
114
|
|
118
|
-
THIS->
|
115
|
+
THIS->line(to<Rays::Polyline&>(poly));
|
119
116
|
return self;
|
120
117
|
}
|
121
118
|
RUCY_END
|
122
119
|
|
123
120
|
static
|
124
|
-
|
121
|
+
RUCY_DEF6(rect, args, round, lefttop, righttop, leftbottom, rightbottom)
|
125
122
|
{
|
126
123
|
CHECK;
|
127
|
-
if (argc <= 0)
|
128
|
-
argument_error(__FILE__, __LINE__, "Painter#polygon");
|
129
124
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
125
|
+
coord x, y, w, h, lt, rt, lb, rb;
|
126
|
+
uint _;
|
127
|
+
get_rect_args(
|
128
|
+
&x, &y, &w, &h, <, &rt, &lb, &rb, &_,
|
129
|
+
args.size(), args.as_array(),
|
130
|
+
round, lefttop, righttop, leftbottom, rightbottom, nil());
|
134
131
|
|
135
|
-
THIS->
|
132
|
+
THIS->rect(x, y, w, h, lt, rt, lb, rb);
|
136
133
|
return self;
|
137
134
|
}
|
138
135
|
RUCY_END
|
139
136
|
|
140
137
|
static
|
141
|
-
|
138
|
+
RUCY_DEF6(ellipse, args, center, radius, hole, angle_from, angle_to)
|
142
139
|
{
|
143
140
|
CHECK;
|
144
|
-
check_arg_count(__FILE__, __LINE__, "Painter#rect", argc, 1, 2, 3, 4, 5, 6);
|
145
141
|
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
{
|
155
|
-
coord x = to<coord>(argv[0]);
|
156
|
-
coord y = to<coord>(argv[1]);
|
157
|
-
coord w = to<coord>(argv[2]);
|
158
|
-
coord h = to<coord>(argv[3]);
|
159
|
-
coord rw = argc >= 5 ? to<coord>(argv[4]) : 0;
|
160
|
-
coord rh = argc >= 6 ? to<coord>(argv[5]) : rw;
|
161
|
-
THIS->rect(x, y, w, h, rw, rh);
|
162
|
-
}
|
142
|
+
coord x, y, w, h;
|
143
|
+
Rays::Point hole_size;
|
144
|
+
float from, to_;
|
145
|
+
uint _;
|
146
|
+
get_ellipse_args(
|
147
|
+
&x, &y, &w, &h, &hole_size, &from, &to_, &_,
|
148
|
+
args.size(), args.as_array(),
|
149
|
+
center, radius, hole, angle_from, angle_to, nil());
|
163
150
|
|
151
|
+
THIS->ellipse(x, y, w, h, hole_size, from, to_);
|
164
152
|
return self;
|
165
153
|
}
|
166
154
|
RUCY_END
|
167
155
|
|
168
156
|
static
|
169
|
-
|
157
|
+
RUCY_DEF2(curve, args, loop)
|
170
158
|
{
|
171
159
|
CHECK;
|
172
|
-
check_arg_count(__FILE__, __LINE__, "Painter#ellipse", argc, 1, 2, 3, 4, 5, 6);
|
173
160
|
|
174
|
-
if (
|
175
|
-
|
176
|
-
const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
177
|
-
coord min_ = (argc >= 2) ? to<coord>(argv[1]) : 0;
|
178
|
-
uint nseg = (argc >= 3) ? to<uint> (argv[2]) : 0;
|
179
|
-
THIS->ellipse(b, min_, nseg);
|
180
|
-
}
|
181
|
-
else
|
182
|
-
{
|
183
|
-
coord x = to<coord>(argv[0]);
|
184
|
-
coord y = to<coord>(argv[1]);
|
185
|
-
coord w = to<coord>(argv[2]);
|
186
|
-
coord h = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
187
|
-
coord min_ = (argc >= 5) ? to<coord>(argv[4]) : 0;
|
188
|
-
uint nseg = (argc >= 6) ? to<uint> (argv[5]) : 0;
|
189
|
-
THIS->ellipse(x, y, w, h, min_, nseg);
|
190
|
-
}
|
161
|
+
if (args.empty())
|
162
|
+
argument_error(__FILE__, __LINE__);
|
191
163
|
|
164
|
+
std::vector<Rays::Point> points;
|
165
|
+
get_line_args(&points, args.size(), args.as_array());
|
166
|
+
|
167
|
+
THIS->curve(&points[0], points.size(), loop);
|
192
168
|
return self;
|
193
169
|
}
|
194
170
|
RUCY_END
|
195
171
|
|
196
172
|
static
|
197
|
-
|
173
|
+
RUCY_DEF2(bezier, args, loop)
|
198
174
|
{
|
199
175
|
CHECK;
|
200
|
-
check_arg_count(__FILE__, __LINE__, "Painter#ellipse", argc, 1, 2, 3, 4, 5, 6, 7, 8);
|
201
176
|
|
202
|
-
if (
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
coord min_ = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
208
|
-
uint nseg = (argc >= 5) ? to<uint> (argv[4]) : 0;
|
209
|
-
THIS->arc(b, begin, end, min_, nseg);
|
210
|
-
}
|
211
|
-
else
|
212
|
-
{
|
213
|
-
coord x = to<coord>(argv[0]);
|
214
|
-
coord y = to<coord>(argv[1]);
|
215
|
-
coord w = to<coord>(argv[2]);
|
216
|
-
coord h = (argc >= 4) ? to<coord>(argv[3]) : 0;
|
217
|
-
float begin = (argc >= 5) ? to<float>(argv[4]) : 0;
|
218
|
-
float end = (argc >= 6) ? to<float>(argv[5]) : 360;
|
219
|
-
coord min_ = (argc >= 7) ? to<coord>(argv[6]) : 0;
|
220
|
-
uint nseg = (argc >= 8) ? to<uint> (argv[7]) : 0;
|
221
|
-
THIS->arc(x, y, w, h, begin, end, min_, nseg);
|
222
|
-
}
|
177
|
+
if (args.empty())
|
178
|
+
argument_error(__FILE__, __LINE__);
|
179
|
+
|
180
|
+
std::vector<Rays::Point> points;
|
181
|
+
get_line_args(&points, args.size(), args.as_array());
|
223
182
|
|
183
|
+
THIS->bezier(&points[0], points.size(), loop);
|
224
184
|
return self;
|
225
185
|
}
|
226
186
|
RUCY_END
|
@@ -273,7 +233,7 @@ static
|
|
273
233
|
RUCY_DEFN(text)
|
274
234
|
{
|
275
235
|
CHECK;
|
276
|
-
check_arg_count(__FILE__, __LINE__, "Painter#text", argc, 1, 3,
|
236
|
+
check_arg_count(__FILE__, __LINE__, "Painter#text", argc, 1, 3, 5);
|
277
237
|
|
278
238
|
if (argc == 1)
|
279
239
|
THIS->text(argv[0].c_str());
|
@@ -282,63 +242,35 @@ RUCY_DEFN(text)
|
|
282
242
|
coord x = to<coord>(argv[1]), y = to<coord>(argv[2]);
|
283
243
|
THIS->text(argv[0].c_str(), x, y);
|
284
244
|
}
|
285
|
-
else if (argc == 4)
|
286
|
-
{
|
287
|
-
const Rays::Font* font = to<Rays::Font*>(argv[3]);
|
288
|
-
if (!font || !*font)
|
289
|
-
rays_error(__FILE__, __LINE__, "Painter#text: invalid font.");
|
290
|
-
|
291
|
-
coord x = to<coord>(argv[1]), y = to<coord>(argv[2]);
|
292
|
-
THIS->text(argv[0].c_str(), x, y, font);
|
293
|
-
}
|
294
245
|
else if (argc == 5)
|
295
246
|
{
|
296
247
|
coord x = to<coord>(argv[1]), w = to<coord>(argv[3]);
|
297
248
|
coord y = to<coord>(argv[2]), h = to<coord>(argv[4]);
|
298
249
|
THIS->text(argv[0].c_str(), x, y, w, h);
|
299
250
|
}
|
300
|
-
else if (argc == 7)
|
301
|
-
{
|
302
|
-
const Rays::Font* font = to<Rays::Font*>(argv[3]);
|
303
|
-
if (!font || !*font)
|
304
|
-
rays_error(__FILE__, __LINE__, "Painter#text: invalid font.");
|
305
|
-
|
306
|
-
coord x = to<coord>(argv[1]), w = to<coord>(argv[3]);
|
307
|
-
coord y = to<coord>(argv[2]), h = to<coord>(argv[4]);
|
308
|
-
THIS->text(argv[0].c_str(), x, y, w, h, font);
|
309
|
-
}
|
310
251
|
|
311
252
|
return self;
|
312
253
|
}
|
313
254
|
RUCY_END
|
314
255
|
|
256
|
+
|
315
257
|
static
|
316
258
|
RUCY_DEFN(set_background)
|
317
259
|
{
|
318
260
|
CHECK;
|
319
|
-
|
320
|
-
|
321
|
-
if (argc == 1 && argv[0].is_kind_of(Rays::color_class()))
|
322
|
-
THIS->set_background(to<Rays::Color&>(argv[0]));
|
323
|
-
else if (argc == 1 || argc == 2)
|
324
|
-
{
|
325
|
-
float v = to<float>(argv[0]);
|
326
|
-
float a = (argc >= 2) ? to<float>(argv[1]) : 1;
|
327
|
-
THIS->set_background(v, v, v, a);
|
328
|
-
}
|
329
|
-
else
|
330
|
-
{
|
331
|
-
float r = to<float>(argv[0]);
|
332
|
-
float g = to<float>(argv[1]);
|
333
|
-
float b = to<float>(argv[2]);
|
334
|
-
float a = (argc == 4) ? to<float>(argv[3]) : 1;
|
335
|
-
THIS->set_background(r, g, b, a);
|
336
|
-
}
|
337
|
-
|
261
|
+
THIS->set_background(to<Rays::Color>(argc, argv));
|
338
262
|
return self;
|
339
263
|
}
|
340
264
|
RUCY_END
|
341
265
|
|
266
|
+
static
|
267
|
+
RUCY_DEF0(get_background)
|
268
|
+
{
|
269
|
+
CHECK;
|
270
|
+
return value(THIS->background());
|
271
|
+
}
|
272
|
+
RUCY_END
|
273
|
+
|
342
274
|
static
|
343
275
|
RUCY_DEF0(no_background)
|
344
276
|
{
|
@@ -349,37 +281,19 @@ RUCY_DEF0(no_background)
|
|
349
281
|
RUCY_END
|
350
282
|
|
351
283
|
static
|
352
|
-
|
284
|
+
RUCY_DEFN(set_fill)
|
353
285
|
{
|
354
286
|
CHECK;
|
355
|
-
|
287
|
+
THIS->set_fill(to<Rays::Color>(argc, argv));
|
288
|
+
return self;
|
356
289
|
}
|
357
290
|
RUCY_END
|
358
291
|
|
359
292
|
static
|
360
|
-
|
293
|
+
RUCY_DEF0(get_fill)
|
361
294
|
{
|
362
295
|
CHECK;
|
363
|
-
|
364
|
-
|
365
|
-
if (argc == 1 && argv[0].is_kind_of(Rays::color_class()))
|
366
|
-
THIS->set_fill(to<Rays::Color&>(argv[0]));
|
367
|
-
else if (argc == 1 || argc == 2)
|
368
|
-
{
|
369
|
-
float v = to<float>(argv[0]);
|
370
|
-
float a = (argc >= 2) ? to<float>(argv[1]) : 1;
|
371
|
-
THIS->set_fill(v, v, v, a);
|
372
|
-
}
|
373
|
-
else
|
374
|
-
{
|
375
|
-
float r = to<float>(argv[0]);
|
376
|
-
float g = to<float>(argv[1]);
|
377
|
-
float b = to<float>(argv[2]);
|
378
|
-
float a = (argc == 4) ? to<float>(argv[3]) : 1;
|
379
|
-
THIS->set_fill(r, g, b, a);
|
380
|
-
}
|
381
|
-
|
382
|
-
return self;
|
296
|
+
return value(THIS->fill());
|
383
297
|
}
|
384
298
|
RUCY_END
|
385
299
|
|
@@ -393,37 +307,19 @@ RUCY_DEF0(no_fill)
|
|
393
307
|
RUCY_END
|
394
308
|
|
395
309
|
static
|
396
|
-
|
310
|
+
RUCY_DEFN(set_stroke)
|
397
311
|
{
|
398
312
|
CHECK;
|
399
|
-
|
313
|
+
THIS->set_stroke(to<Rays::Color>(argc, argv));
|
314
|
+
return self;
|
400
315
|
}
|
401
316
|
RUCY_END
|
402
317
|
|
403
318
|
static
|
404
|
-
|
319
|
+
RUCY_DEF0(get_stroke)
|
405
320
|
{
|
406
321
|
CHECK;
|
407
|
-
|
408
|
-
|
409
|
-
if (argc == 1 && argv[0].is_kind_of(Rays::color_class()))
|
410
|
-
THIS->set_stroke(to<Rays::Color&>(argv[0]));
|
411
|
-
else if (argc == 1 || argc == 2)
|
412
|
-
{
|
413
|
-
float v = to<float>(argv[0]);
|
414
|
-
float a = (argc >= 2) ? to<float>(argv[1]) : 1;
|
415
|
-
THIS->set_stroke(v, v, v, a);
|
416
|
-
}
|
417
|
-
else
|
418
|
-
{
|
419
|
-
float r = to<float>(argv[0]);
|
420
|
-
float g = to<float>(argv[1]);
|
421
|
-
float b = to<float>(argv[2]);
|
422
|
-
float a = (argc == 4) ? to<float>(argv[3]) : 1;
|
423
|
-
THIS->set_stroke(r, g, b, a);
|
424
|
-
}
|
425
|
-
|
426
|
-
return self;
|
322
|
+
return value(THIS->stroke());
|
427
323
|
}
|
428
324
|
RUCY_END
|
429
325
|
|
@@ -437,177 +333,177 @@ RUCY_DEF0(no_stroke)
|
|
437
333
|
RUCY_END
|
438
334
|
|
439
335
|
static
|
440
|
-
|
336
|
+
RUCY_DEF1(set_stroke_width, width)
|
441
337
|
{
|
442
338
|
CHECK;
|
443
|
-
|
339
|
+
THIS->set_stroke_width(to<coord>(width));
|
340
|
+
return self;
|
444
341
|
}
|
445
342
|
RUCY_END
|
446
343
|
|
447
344
|
static
|
448
|
-
|
345
|
+
RUCY_DEF0(get_stroke_width)
|
449
346
|
{
|
450
347
|
CHECK;
|
451
|
-
|
452
|
-
|
453
|
-
if (argc == 1)
|
454
|
-
THIS->set_clip(to<Rays::Bounds&>(argv[0]));
|
455
|
-
else
|
456
|
-
{
|
457
|
-
coord x = to<coord>(argv[0]);
|
458
|
-
coord y = to<coord>(argv[1]);
|
459
|
-
coord w = to<coord>(argv[2]);
|
460
|
-
coord h = to<coord>(argv[3]);
|
461
|
-
THIS->set_clip(x, y, w, h);
|
462
|
-
}
|
463
|
-
|
464
|
-
return self;
|
348
|
+
return value(THIS->stroke_width());
|
465
349
|
}
|
466
350
|
RUCY_END
|
467
351
|
|
468
352
|
static
|
469
|
-
|
353
|
+
RUCY_DEF1(set_stroke_cap, cap)
|
470
354
|
{
|
471
355
|
CHECK;
|
472
|
-
THIS->
|
356
|
+
THIS->set_stroke_cap(to<Rays::CapType>(cap));
|
473
357
|
return self;
|
474
358
|
}
|
475
359
|
RUCY_END
|
476
360
|
|
477
361
|
static
|
478
|
-
RUCY_DEF0(
|
362
|
+
RUCY_DEF0(get_stroke_cap)
|
479
363
|
{
|
480
364
|
CHECK;
|
481
|
-
return value(THIS->
|
365
|
+
return value(THIS->stroke_cap());
|
482
366
|
}
|
483
367
|
RUCY_END
|
484
368
|
|
485
369
|
static
|
486
|
-
|
370
|
+
RUCY_DEF1(set_stroke_join, join)
|
487
371
|
{
|
488
372
|
CHECK;
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
const Rays::Font* f = argc == 0
|
494
|
-
? &Rays::default_font()
|
495
|
-
: to<Rays::Font*>(argv[0]);
|
496
|
-
if (!f || !*f)
|
497
|
-
argument_error(__FILE__, __LINE__);
|
373
|
+
THIS->set_stroke_join(to<Rays::JoinType>(join));
|
374
|
+
return self;
|
375
|
+
}
|
376
|
+
RUCY_END
|
498
377
|
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
}
|
378
|
+
static
|
379
|
+
RUCY_DEF0(get_stroke_join)
|
380
|
+
{
|
381
|
+
CHECK;
|
382
|
+
return value(THIS->stroke_join());
|
383
|
+
}
|
384
|
+
RUCY_END
|
507
385
|
|
386
|
+
static
|
387
|
+
RUCY_DEF1(set_miter_limit, limit)
|
388
|
+
{
|
389
|
+
CHECK;
|
390
|
+
THIS->set_miter_limit(to<coord>(limit));
|
508
391
|
return self;
|
509
392
|
}
|
510
393
|
RUCY_END
|
511
394
|
|
512
395
|
static
|
513
|
-
RUCY_DEF0(
|
396
|
+
RUCY_DEF0(get_miter_limit)
|
514
397
|
{
|
515
398
|
CHECK;
|
516
|
-
return value(THIS->
|
399
|
+
return value(THIS->miter_limit());
|
517
400
|
}
|
518
401
|
RUCY_END
|
519
402
|
|
520
403
|
static
|
521
|
-
|
404
|
+
RUCY_DEF1(set_nsegment, nsegment)
|
522
405
|
{
|
523
406
|
CHECK;
|
524
|
-
THIS->
|
407
|
+
THIS->set_nsegment(nsegment ? to<int>(nsegment) : 0);
|
525
408
|
return self;
|
526
409
|
}
|
527
410
|
RUCY_END
|
528
411
|
|
529
412
|
static
|
530
|
-
RUCY_DEF0(
|
413
|
+
RUCY_DEF0(get_nsegment)
|
414
|
+
{
|
415
|
+
CHECK;
|
416
|
+
return value(THIS->nsegment());
|
417
|
+
}
|
418
|
+
RUCY_END
|
419
|
+
|
420
|
+
static
|
421
|
+
RUCY_DEFN(set_clip)
|
531
422
|
{
|
532
423
|
CHECK;
|
533
|
-
THIS->
|
424
|
+
THIS->set_clip(to<Rays::Bounds>(argc, argv));
|
534
425
|
return self;
|
535
426
|
}
|
536
427
|
RUCY_END
|
537
428
|
|
429
|
+
static
|
430
|
+
RUCY_DEF0(get_clip)
|
431
|
+
{
|
432
|
+
CHECK;
|
433
|
+
return value(THIS->clip());
|
434
|
+
}
|
435
|
+
RUCY_END
|
538
436
|
|
539
437
|
static
|
540
|
-
|
438
|
+
RUCY_DEF0(no_clip)
|
541
439
|
{
|
542
440
|
CHECK;
|
543
|
-
THIS->
|
441
|
+
THIS->no_clip();
|
544
442
|
return self;
|
545
443
|
}
|
546
444
|
RUCY_END
|
547
445
|
|
548
446
|
static
|
549
|
-
|
447
|
+
RUCY_DEFN(set_font)
|
550
448
|
{
|
551
449
|
CHECK;
|
552
|
-
|
450
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_font", argc, 0, 1, 2);
|
451
|
+
|
452
|
+
THIS->set_font(to<Rays::Font>(argc, argv));
|
553
453
|
return self;
|
554
454
|
}
|
555
455
|
RUCY_END
|
556
456
|
|
557
457
|
static
|
558
|
-
|
458
|
+
RUCY_DEF0(get_font)
|
559
459
|
{
|
560
460
|
CHECK;
|
561
|
-
|
461
|
+
return value(THIS->font());
|
462
|
+
}
|
463
|
+
RUCY_END
|
562
464
|
|
563
|
-
|
564
|
-
|
465
|
+
static
|
466
|
+
RUCY_DEFN(set_shader)
|
467
|
+
{
|
468
|
+
CHECK;
|
469
|
+
check_arg_count(__FILE__, __LINE__, "Painter#set_shader", argc, 1);
|
565
470
|
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
{
|
571
|
-
case 2: THIS->set_uniform(name, Ai(1)); break;
|
572
|
-
case 3: THIS->set_uniform(name, Ai(1), Ai(2)); break;
|
573
|
-
case 4: THIS->set_uniform(name, Ai(1), Ai(2), Ai(3)); break;
|
574
|
-
case 5: THIS->set_uniform(name, Ai(1), Ai(2), Ai(3), Ai(4)); break;
|
575
|
-
}
|
576
|
-
}
|
577
|
-
else if (argv[1].is_f())
|
578
|
-
{
|
579
|
-
switch (argc)
|
580
|
-
{
|
581
|
-
case 2: THIS->set_uniform(name, Af(1)); break;
|
582
|
-
case 3: THIS->set_uniform(name, Af(1), Af(2)); break;
|
583
|
-
case 4: THIS->set_uniform(name, Af(1), Af(2), Af(3)); break;
|
584
|
-
case 5: THIS->set_uniform(name, Af(1), Af(2), Af(3), Af(4)); break;
|
585
|
-
}
|
586
|
-
}
|
587
|
-
else
|
588
|
-
argument_error(__FILE__, __LINE__);
|
471
|
+
THIS->set_shader(to<Rays::Shader>(argc, argv));
|
472
|
+
return self;
|
473
|
+
}
|
474
|
+
RUCY_END
|
589
475
|
|
590
|
-
|
591
|
-
|
476
|
+
static
|
477
|
+
RUCY_DEF0(get_shader)
|
478
|
+
{
|
479
|
+
CHECK;
|
480
|
+
return value(THIS->shader());
|
481
|
+
}
|
482
|
+
RUCY_END
|
592
483
|
|
484
|
+
static
|
485
|
+
RUCY_DEF0(no_shader)
|
486
|
+
{
|
487
|
+
CHECK;
|
488
|
+
THIS->no_shader();
|
593
489
|
return self;
|
594
490
|
}
|
595
491
|
RUCY_END
|
596
492
|
|
597
493
|
static
|
598
|
-
RUCY_DEF0(
|
494
|
+
RUCY_DEF0(push_state)
|
599
495
|
{
|
600
496
|
CHECK;
|
601
|
-
THIS->
|
497
|
+
THIS->push_state();
|
602
498
|
return self;
|
603
499
|
}
|
604
500
|
RUCY_END
|
605
501
|
|
606
502
|
static
|
607
|
-
RUCY_DEF0(
|
503
|
+
RUCY_DEF0(pop_state)
|
608
504
|
{
|
609
505
|
CHECK;
|
610
|
-
THIS->
|
506
|
+
THIS->pop_state();
|
611
507
|
return self;
|
612
508
|
}
|
613
509
|
RUCY_END
|
@@ -667,8 +563,8 @@ static
|
|
667
563
|
RUCY_DEFN(set_matrix)
|
668
564
|
{
|
669
565
|
CHECK;
|
670
|
-
THIS->set_matrix();
|
671
|
-
return
|
566
|
+
THIS->set_matrix(to<Rays::Matrix>(argc, argv));
|
567
|
+
return value(THIS->matrix());
|
672
568
|
}
|
673
569
|
RUCY_END
|
674
570
|
|
@@ -711,47 +607,56 @@ Init_painter ()
|
|
711
607
|
|
712
608
|
cPainter.define_method("canvas", canvas);
|
713
609
|
cPainter.define_method("bounds", bounds);
|
610
|
+
cPainter.define_method("pixel_density", pixel_density);
|
714
611
|
|
715
612
|
cPainter.define_private_method("begin_paint", begin_paint);
|
716
613
|
cPainter.define_private_method( "end_paint", end_paint);
|
717
614
|
cPainter.define_method("clear", clear);
|
718
|
-
cPainter.define_method("line", line);
|
719
|
-
cPainter.define_method("lines", lines);
|
720
615
|
cPainter.define_method("polygon", polygon);
|
721
|
-
cPainter.
|
722
|
-
cPainter.
|
723
|
-
cPainter.
|
724
|
-
cPainter.
|
725
|
-
cPainter.
|
726
|
-
|
727
|
-
cPainter.
|
728
|
-
cPainter.
|
729
|
-
|
730
|
-
cPainter.
|
731
|
-
cPainter.
|
732
|
-
cPainter.define_method(
|
733
|
-
cPainter.
|
734
|
-
cPainter.
|
735
|
-
cPainter.define_method(
|
736
|
-
cPainter.
|
737
|
-
cPainter.
|
738
|
-
cPainter.define_method(
|
739
|
-
cPainter.
|
740
|
-
cPainter.
|
741
|
-
cPainter.define_method("
|
742
|
-
cPainter.define_method(
|
743
|
-
|
744
|
-
cPainter.
|
745
|
-
cPainter.
|
746
|
-
cPainter.
|
747
|
-
cPainter.define_method("
|
748
|
-
cPainter.define_method(
|
616
|
+
cPainter.define_private_method("draw_line", line);
|
617
|
+
cPainter.define_private_method("draw_polyline", polyline);
|
618
|
+
cPainter.define_private_method("draw_rect", rect);
|
619
|
+
cPainter.define_private_method("draw_ellipse", ellipse);
|
620
|
+
cPainter.define_private_method("draw_curve", curve);
|
621
|
+
cPainter.define_private_method("draw_bezier", bezier);
|
622
|
+
cPainter.define_method("image", image);
|
623
|
+
cPainter.define_method("text", text);
|
624
|
+
|
625
|
+
cPainter.define_method( "background=", set_background);
|
626
|
+
cPainter.define_method( "background", get_background);
|
627
|
+
cPainter.define_method("no_background", no_background);
|
628
|
+
cPainter.define_method( "fill=", set_fill);
|
629
|
+
cPainter.define_method( "fill", get_fill);
|
630
|
+
cPainter.define_method("no_fill", no_fill);
|
631
|
+
cPainter.define_method( "stroke=", set_stroke);
|
632
|
+
cPainter.define_method( "stroke", get_stroke);
|
633
|
+
cPainter.define_method("no_stroke", no_stroke);
|
634
|
+
cPainter.define_method( "stroke_width=", set_stroke_width);
|
635
|
+
cPainter.define_method( "stroke_width", get_stroke_width);
|
636
|
+
cPainter.define_method( "stroke_cap=", set_stroke_cap);
|
637
|
+
cPainter.define_method( "stroke_cap", get_stroke_cap);
|
638
|
+
cPainter.define_method( "stroke_join=", set_stroke_join);
|
639
|
+
cPainter.define_method( "stroke_join", get_stroke_join);
|
640
|
+
cPainter.define_method("miter_limit=", set_miter_limit);
|
641
|
+
cPainter.define_method("miter_limit", get_miter_limit);
|
642
|
+
cPainter.define_method("nsegment=", set_nsegment);
|
643
|
+
cPainter.define_method("nsegment", get_nsegment);
|
644
|
+
cPainter.define_method( "clip=", set_clip);
|
645
|
+
cPainter.define_method( "clip", get_clip);
|
646
|
+
cPainter.define_method("no_clip", no_clip);
|
647
|
+
cPainter.define_method("font=", set_font);
|
648
|
+
cPainter.define_method("font", get_font);
|
649
|
+
cPainter.define_private_method("set_shader", set_shader);
|
650
|
+
cPainter.define_method( "shader", get_shader);
|
651
|
+
cPainter.define_method( "no_shader", no_shader);
|
652
|
+
cPainter.define_method("push_state", push_state);
|
653
|
+
cPainter.define_method( "pop_state", pop_state);
|
749
654
|
|
750
655
|
cPainter.define_method("translate", translate);
|
751
656
|
cPainter.define_method("scale", scale);
|
752
657
|
cPainter.define_method("rotate", rotate);
|
753
|
-
cPainter.
|
754
|
-
cPainter.
|
658
|
+
cPainter.define_method("matrix=", set_matrix);
|
659
|
+
cPainter.define_method("matrix", get_matrix);
|
755
660
|
cPainter.define_method("push_matrix", push_matrix);
|
756
661
|
cPainter.define_method( "pop_matrix", pop_matrix);
|
757
662
|
}
|