rays 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.doc/ext/rays/bitmap.cpp +70 -233
- data/.doc/ext/rays/bounds.cpp +339 -57
- data/.doc/ext/rays/color.cpp +58 -48
- data/.doc/ext/rays/color_space.cpp +174 -0
- data/.doc/ext/rays/font.cpp +31 -53
- data/.doc/ext/rays/image.cpp +64 -67
- data/.doc/ext/rays/matrix.cpp +22 -50
- data/.doc/ext/rays/native.cpp +9 -2
- data/.doc/ext/rays/painter.cpp +276 -259
- data/.doc/ext/rays/point.cpp +186 -52
- data/.doc/ext/rays/rays.cpp +25 -20
- data/.doc/ext/rays/shader.cpp +61 -0
- data/.doc/ext/rays/texture.cpp +47 -59
- data/{README → README.md} +0 -0
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/ext/rays/bitmap.cpp +88 -248
- data/ext/rays/bounds.cpp +437 -141
- data/ext/rays/color.cpp +79 -69
- data/ext/rays/color_space.cpp +185 -0
- data/ext/rays/extconf.rb +14 -63
- data/ext/rays/font.cpp +44 -65
- data/ext/rays/image.cpp +82 -81
- data/ext/rays/matrix.cpp +32 -60
- data/ext/rays/native.cpp +9 -2
- data/ext/rays/painter.cpp +345 -321
- data/ext/rays/point.cpp +212 -69
- data/ext/rays/rays.cpp +29 -23
- data/ext/rays/shader.cpp +63 -0
- data/ext/rays/texture.cpp +64 -74
- data/include/rays/bitmap.h +21 -12
- data/include/rays/bounds.h +67 -9
- data/include/rays/color.h +23 -7
- data/include/rays/{colorspace.h → color_space.h} +6 -3
- data/include/rays/exception.h +17 -11
- data/include/rays/font.h +4 -3
- data/include/rays/image.h +11 -6
- data/include/rays/matrix.h +15 -12
- data/include/rays/opengl.h +54 -1
- data/include/rays/painter.h +98 -108
- data/include/rays/point.h +45 -5
- data/include/rays/rays.h +2 -2
- data/include/rays/ruby/bitmap.h +2 -16
- data/include/rays/ruby/bounds.h +4 -16
- data/include/rays/ruby/color.h +3 -16
- data/include/rays/ruby/color_space.h +27 -0
- data/include/rays/ruby/font.h +2 -16
- data/include/rays/ruby/image.h +2 -16
- data/include/rays/ruby/matrix.h +2 -16
- data/include/rays/ruby/painter.h +2 -16
- data/include/rays/ruby/point.h +3 -16
- data/include/rays/ruby/shader.h +27 -0
- data/include/rays/ruby/texture.h +2 -16
- data/include/rays/ruby.h +1 -0
- data/include/rays/shader.h +48 -0
- data/include/rays/texture.h +13 -2
- data/include/rays.h +2 -1
- data/lib/rays/bitmap.rb +20 -11
- data/lib/rays/bounds.rb +29 -68
- data/lib/rays/color.rb +39 -0
- data/lib/rays/color_space.rb +33 -0
- data/lib/rays/font.rb +29 -0
- data/lib/rays/image.rb +22 -0
- data/lib/rays/module.rb +11 -7
- data/lib/rays/painter.rb +103 -40
- data/lib/rays/point.rb +19 -36
- data/lib/rays/shader.rb +13 -0
- data/lib/rays/texture.rb +9 -0
- data/lib/rays.rb +4 -0
- data/rays.gemspec +3 -4
- data/src/bounds.cpp +272 -63
- data/src/color.cpp +168 -21
- data/src/{colorspace.cpp → color_space.cpp} +38 -1
- data/src/exception.cpp +24 -15
- data/src/frame_buffer.cpp +275 -0
- data/src/frame_buffer.h +79 -0
- data/src/image.cpp +80 -36
- data/src/ios/bitmap.mm +340 -0
- data/src/ios/font.mm +206 -0
- data/src/{cocoa → ios}/helper.h +2 -2
- data/src/{cocoa → ios}/helper.mm +0 -0
- data/src/ios/opengl.mm +21 -0
- data/src/ios/program.cpp +122 -0
- data/src/{cocoa → ios}/rays.mm +8 -7
- data/src/matrix.cpp +10 -22
- data/src/opengl.cpp +64 -0
- data/src/{cocoa → osx}/bitmap.mm +121 -70
- data/src/{cocoa → osx}/font.mm +32 -24
- data/src/osx/helper.h +26 -0
- data/src/osx/helper.mm +25 -0
- data/src/osx/opengl.mm +103 -0
- data/src/osx/rays.mm +43 -0
- data/src/painter.cpp +596 -422
- data/src/point.cpp +154 -11
- data/src/program.cpp +513 -0
- data/src/program.h +73 -0
- data/src/render_buffer.cpp +120 -0
- data/src/render_buffer.h +47 -0
- data/src/shader.cpp +117 -0
- data/src/texture.cpp +104 -134
- data/test/helper.rb +10 -3
- data/test/test_bitmap.rb +18 -0
- data/test/test_bounds.rb +81 -35
- data/test/test_color.rb +29 -2
- data/test/test_image.rb +63 -0
- data/test/test_painter.rb +120 -0
- data/test/test_point.rb +30 -9
- data/test/test_shader.rb +37 -0
- data/test/test_texture.rb +18 -0
- metadata +75 -58
- data/.gitignore +0 -14
- data/ChangeLog +0 -8
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4a408fdf8bf60cb32907e9be2fe9048f0c5de133
|
4
|
+
data.tar.gz: 8e0ab09661a2083e27f9770d7ad8d23c2482fe0f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d9d66ab38417be7291948a5003b71836f74cc6d19e9c1163b0156032784d4677bc666afde3551644992180523af55bf501e0bba2435c2080ba90891d3cc7badd
|
7
|
+
data.tar.gz: 3f52a64943eb855b4cfbb5cd0ebeb7a337fde08d771eca0f42e3272ea6668af9cd16d5a675df426381b70da25493c79c049cc0fde56a3723c96a3e6aa8febae5
|
data/.doc/ext/rays/bitmap.cpp
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
+
#include "rays/exception.h"
|
6
|
+
#include "rays/ruby/color_space.h"
|
7
|
+
#include "rays/ruby/color.h"
|
5
8
|
#include "rays/ruby/font.h"
|
9
|
+
#include "rays/ruby/texture.h"
|
6
10
|
#include "defs.h"
|
7
11
|
|
8
12
|
|
@@ -10,50 +14,17 @@ using namespace Rucy;
|
|
10
14
|
|
11
15
|
using Rays::uchar;
|
12
16
|
using Rays::ushort;
|
13
|
-
using Rays::
|
17
|
+
using Rays::uint;
|
14
18
|
using Rays::coord;
|
15
19
|
|
16
20
|
|
17
21
|
static Class cBitmap;
|
18
22
|
|
23
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::Bitmap, cBitmap)
|
19
24
|
|
20
|
-
|
21
|
-
{
|
22
|
-
|
23
|
-
|
24
|
-
Class
|
25
|
-
bitmap_class ()
|
26
|
-
{
|
27
|
-
return cBitmap;
|
28
|
-
}
|
25
|
+
#define THIS to<Rays::Bitmap*>(self)
|
29
26
|
|
30
|
-
|
31
|
-
}// Rays
|
32
|
-
|
33
|
-
|
34
|
-
namespace Rucy
|
35
|
-
{
|
36
|
-
|
37
|
-
|
38
|
-
Value
|
39
|
-
value (const Rays::Bitmap& obj)
|
40
|
-
{
|
41
|
-
return new_type(cBitmap, new Rays::Bitmap(obj));
|
42
|
-
}
|
43
|
-
|
44
|
-
Value
|
45
|
-
value (const Rays::Bitmap* obj)
|
46
|
-
{
|
47
|
-
return obj ? value(*obj) : nil();
|
48
|
-
}
|
49
|
-
|
50
|
-
|
51
|
-
}// Rucy
|
52
|
-
|
53
|
-
|
54
|
-
#define THIS to<Rays::Bitmap*>(self)
|
55
|
-
|
56
|
-
#define CHECK RUCY_CHECK_OBJECT(self, Rays::Bitmap, cBitmap)
|
27
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::Bitmap, cBitmap, self)
|
57
28
|
|
58
29
|
|
59
30
|
static
|
@@ -63,12 +34,24 @@ VALUE alloc(VALUE klass)
|
|
63
34
|
}
|
64
35
|
|
65
36
|
static
|
66
|
-
VALUE
|
37
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
38
|
+
{
|
39
|
+
RUCY_CHECK_OBJ(Rays::Bitmap, cBitmap, self);
|
40
|
+
|
41
|
+
*THIS = to<Rays::Bitmap&>(obj).copy();
|
42
|
+
return self;
|
43
|
+
}
|
44
|
+
|
45
|
+
static
|
46
|
+
VALUE setup(VALUE self, VALUE width, VALUE height, VALUE color_space)
|
67
47
|
{
|
68
|
-
RUCY_CHECK_OBJ(
|
69
|
-
|
70
|
-
|
71
|
-
|
48
|
+
RUCY_CHECK_OBJ(Rays::Bitmap, cBitmap, self);
|
49
|
+
|
50
|
+
Rays::ColorSpace* cs = to<Rays::ColorSpace*>(color_space);
|
51
|
+
if (!cs)
|
52
|
+
argument_error(__FILE__, __LINE__);
|
53
|
+
|
54
|
+
*THIS = Rays::Bitmap(to<int>(width), to<int>(height), *cs);
|
72
55
|
return self;
|
73
56
|
}
|
74
57
|
|
@@ -76,8 +59,7 @@ static
|
|
76
59
|
VALUE draw_string(VALUE self)
|
77
60
|
{
|
78
61
|
CHECK;
|
79
|
-
|
80
|
-
arg_count_error("Bitmap#draw_string", argc, 1, 2, 3, 4);
|
62
|
+
check_arg_count(__FILE__, __LINE__, "Bitmap#draw_string", argc, 1, 2, 3, 4);
|
81
63
|
|
82
64
|
const char* str = to<const char*>(argv[0]);
|
83
65
|
coord x = argc >= 2 ? to<coord>(argv[1]) : 0;
|
@@ -85,13 +67,7 @@ VALUE draw_string(VALUE self)
|
|
85
67
|
const Rays::Font* font = argc >= 4
|
86
68
|
? to<Rays::Font*>(argv[3]) : &Rays::default_font();
|
87
69
|
|
88
|
-
|
89
|
-
{
|
90
|
-
rays_error(
|
91
|
-
"Bitmap#draw_string('%s', %f, %f, %s) failed.",
|
92
|
-
str, x, y, font->name().c_str());
|
93
|
-
}
|
94
|
-
|
70
|
+
Rays::draw_string(THIS, str, x, y, *font);
|
95
71
|
return self;
|
96
72
|
}
|
97
73
|
|
@@ -116,7 +92,7 @@ VALUE color_space(VALUE self)
|
|
116
92
|
{
|
117
93
|
CHECK;
|
118
94
|
|
119
|
-
return value(THIS->color_space()
|
95
|
+
return value(THIS->color_space());
|
120
96
|
}
|
121
97
|
|
122
98
|
static
|
@@ -124,198 +100,46 @@ VALUE at(VALUE self, VALUE x, VALUE y)
|
|
124
100
|
{
|
125
101
|
CHECK;
|
126
102
|
|
127
|
-
|
128
|
-
|
129
|
-
if (!pixel) rays_error("Bitmap#at(%d, %d) failed.", xx, yy);
|
103
|
+
return value(Rays::Color(THIS->at<void>(x.as_i(), y.as_i()), THIS->color_space()));
|
104
|
+
}
|
130
105
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
array.push(p[0]).push(p[1]).push(p[2]);
|
142
|
-
break;
|
143
|
-
case Rays::RGBA_float:
|
144
|
-
array.push(p[0]).push(p[1]).push(p[2]).push(p[3]);
|
145
|
-
break;
|
146
|
-
case Rays::ARGB_float:
|
147
|
-
array.push(p[1]).push(p[2]).push(p[3]).push(p[0]);
|
148
|
-
break;
|
149
|
-
case Rays::BGR_float:
|
150
|
-
array.push(p[2]).push(p[1]).push(p[0]);
|
151
|
-
break;
|
152
|
-
case Rays::BGRA_float:
|
153
|
-
array.push(p[2]).push(p[1]).push(p[0]).push(p[3]);
|
154
|
-
break;
|
155
|
-
case Rays::ABGR_float:
|
156
|
-
array.push(p[3]).push(p[2]).push(p[1]).push(p[0]);
|
157
|
-
break;
|
158
|
-
default:
|
159
|
-
rays_error("Bitmap#at: unknown color space");
|
160
|
-
}
|
161
|
-
}
|
162
|
-
else
|
163
|
-
{
|
164
|
-
uchar* p = (uchar*) pixel;
|
165
|
-
switch (THIS->color_space().type())
|
166
|
-
{
|
167
|
-
case Rays::GRAY_8:
|
168
|
-
array.push(*(uchar*) pixel);
|
169
|
-
break;
|
170
|
-
case Rays::GRAY_16:
|
171
|
-
array.push(*(ushort*) pixel);
|
172
|
-
break;
|
173
|
-
case Rays::GRAY_32:
|
174
|
-
array.push(*(ulong*) pixel);
|
175
|
-
break;
|
176
|
-
case Rays::RGB_888:
|
177
|
-
array.push(p[0]).push(p[1]).push(p[2]);
|
178
|
-
break;
|
179
|
-
case Rays::RGBA_8888:
|
180
|
-
array.push(p[0]).push(p[1]).push(p[2]).push(p[3]);
|
181
|
-
break;
|
182
|
-
case Rays::ARGB_8888:
|
183
|
-
array.push(p[1]).push(p[2]).push(p[3]).push(p[0]);
|
184
|
-
break;
|
185
|
-
case Rays::RGBX_8888:
|
186
|
-
array.push(p[0]).push(p[1]).push(p[2]);
|
187
|
-
break;
|
188
|
-
case Rays::XRGB_8888:
|
189
|
-
array.push(p[1]).push(p[2]).push(p[3]);
|
190
|
-
break;
|
191
|
-
case Rays::BGR_888:
|
192
|
-
array.push(p[2]).push(p[1]).push(p[0]);
|
193
|
-
break;
|
194
|
-
case Rays::BGRA_8888:
|
195
|
-
array.push(p[2]).push(p[1]).push(p[0]).push(p[3]);
|
196
|
-
break;
|
197
|
-
case Rays::ABGR_8888:
|
198
|
-
array.push(p[3]).push(p[2]).push(p[1]).push(p[0]);
|
199
|
-
break;
|
200
|
-
case Rays::BGRX_8888:
|
201
|
-
array.push(p[2]).push(p[1]).push(p[0]);
|
202
|
-
break;
|
203
|
-
case Rays::XBGR_8888:
|
204
|
-
array.push(p[3]).push(p[2]).push(p[1]);
|
205
|
-
break;
|
206
|
-
default:
|
207
|
-
rays_error("Bitmap#at: unknown color space");
|
208
|
-
}
|
209
|
-
}
|
106
|
+
static
|
107
|
+
VALUE set_at(VALUE self, VALUE x, VALUE y, VALUE color)
|
108
|
+
{
|
109
|
+
CHECK;
|
110
|
+
|
111
|
+
Rays::Color* col = to<Rays::Color*>(color);
|
112
|
+
if (!col)
|
113
|
+
argument_error(__FILE__, __LINE__);
|
114
|
+
|
115
|
+
col->get(THIS->at<void>(x.as_i(), y.as_i()), THIS->color_space());
|
210
116
|
|
211
|
-
return
|
117
|
+
return color;
|
212
118
|
}
|
213
119
|
|
214
120
|
static
|
215
|
-
VALUE
|
121
|
+
VALUE to_texture(VALUE self)
|
216
122
|
{
|
217
123
|
CHECK;
|
218
124
|
|
219
|
-
|
220
|
-
|
221
|
-
|
125
|
+
bool alpha_only = (argc >= 1) ? to<bool>(argv[0]) : false;
|
126
|
+
return value(Rays::Texture(*THIS, alpha_only));
|
127
|
+
}
|
222
128
|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
switch (THIS->color_space().type())
|
228
|
-
{
|
229
|
-
#define C(n) ((float) color[n].as_f())
|
230
|
-
case Rays::GRAY_float:
|
231
|
-
p[0] = C(0);
|
232
|
-
break;
|
233
|
-
case Rays::RGB_float:
|
234
|
-
p[0] = C(0); p[1] = C(1); p[2] = C(2);
|
235
|
-
break;
|
236
|
-
case Rays::RGBA_float:
|
237
|
-
p[0] = C(0); p[1] = C(1); p[2] = C(2); p[3] = C(3);
|
238
|
-
break;
|
239
|
-
case Rays::ARGB_float:
|
240
|
-
p[0] = C(1); p[1] = C(2); p[2] = C(3); p[3] = C(0);
|
241
|
-
break;
|
242
|
-
case Rays::BGR_float:
|
243
|
-
p[0] = C(2); p[1] = C(1); p[2] = C(0);
|
244
|
-
break;
|
245
|
-
case Rays::BGRA_float:
|
246
|
-
p[0] = C(2); p[1] = C(1); p[2] = C(0); p[3] = C(3);
|
247
|
-
break;
|
248
|
-
case Rays::ABGR_float:
|
249
|
-
p[0] = C(3); p[1] = C(2); p[2] = C(1); p[3] = C(0);
|
250
|
-
break;
|
251
|
-
#undef C
|
252
|
-
default:
|
253
|
-
rays_error("Bitmap#at: unknown color space");
|
254
|
-
}
|
255
|
-
}
|
256
|
-
else
|
257
|
-
{
|
258
|
-
uchar* p = (uchar*) pixel;
|
259
|
-
switch (THIS->color_space().type())
|
260
|
-
{
|
261
|
-
#define C(n) ((uchar) color[n].as_i())
|
262
|
-
case Rays::GRAY_8:
|
263
|
-
*(uchar*) pixel = C(0);
|
264
|
-
break;
|
265
|
-
case Rays::GRAY_16:
|
266
|
-
*(ushort*) pixel = C(0);
|
267
|
-
break;
|
268
|
-
case Rays::GRAY_32:
|
269
|
-
*(ulong*) pixel = C(0);
|
270
|
-
break;
|
271
|
-
case Rays::RGB_888:
|
272
|
-
p[0] = C(0); p[1] = C(1); p[2] = C(2);
|
273
|
-
break;
|
274
|
-
case Rays::RGBA_8888:
|
275
|
-
p[0] = C(0); p[1] = C(1); p[2] = C(2); p[3] = C(3);
|
276
|
-
break;
|
277
|
-
case Rays::ARGB_8888:
|
278
|
-
p[0] = C(1); p[1] = C(2); p[2] = C(3); p[3] = C(0);
|
279
|
-
break;
|
280
|
-
case Rays::RGBX_8888:
|
281
|
-
p[0] = C(0); p[1] = C(1); p[2] = C(2);
|
282
|
-
break;
|
283
|
-
case Rays::XRGB_8888:
|
284
|
-
p[0] = C(1); p[1] = C(2); p[2] = C(3);
|
285
|
-
break;
|
286
|
-
case Rays::BGR_888:
|
287
|
-
p[0] = C(2); p[1] = C(1); p[2] = C(0);
|
288
|
-
break;
|
289
|
-
case Rays::BGRA_8888:
|
290
|
-
p[0] = C(2); p[1] = C(1); p[2] = C(0); p[3] = C(3);
|
291
|
-
break;
|
292
|
-
case Rays::ABGR_8888:
|
293
|
-
p[0] = C(3); p[1] = C(2); p[2] = C(1); p[3] = C(0);
|
294
|
-
break;
|
295
|
-
case Rays::BGRX_8888:
|
296
|
-
p[0] = C(2); p[1] = C(1); p[2] = C(0);
|
297
|
-
break;
|
298
|
-
case Rays::XBGR_8888:
|
299
|
-
p[0] = C(3); p[1] = C(2); p[2] = C(1);
|
300
|
-
break;
|
301
|
-
#undef C
|
302
|
-
default:
|
303
|
-
rays_error("Bitmap#at: unknown color space");
|
304
|
-
}
|
305
|
-
}
|
129
|
+
static
|
130
|
+
VALUE save(VALUE self, VALUE path)
|
131
|
+
{
|
132
|
+
CHECK;
|
306
133
|
|
307
|
-
|
134
|
+
Rays::save_bitmap(*THIS, path.c_str());
|
135
|
+
return self;
|
308
136
|
}
|
309
137
|
|
310
138
|
|
311
139
|
static
|
312
140
|
VALUE load(VALUE self, VALUE path)
|
313
141
|
{
|
314
|
-
Rays::
|
315
|
-
if (!Rays::load_bitmap(&bmp, path.c_str()))
|
316
|
-
rays_error("Bitmap.load('%s') failed.", path.c_str());
|
317
|
-
|
318
|
-
return value(bmp);
|
142
|
+
return value(Rays::load_bitmap(path.c_str()));
|
319
143
|
}
|
320
144
|
|
321
145
|
|
@@ -324,18 +148,31 @@ Init_bitmap ()
|
|
324
148
|
{
|
325
149
|
Module mRays = rb_define_module("Rays");
|
326
150
|
|
327
|
-
mRays.define_const("GRAY", Rays::GRAY);
|
328
|
-
mRays.define_const("RGB", Rays::RGB);
|
329
|
-
mRays.define_const("RGBA", Rays::RGBA);
|
330
|
-
|
331
151
|
cBitmap = rb_define_class_under(mRays, "Bitmap", rb_cObject);
|
332
152
|
rb_define_alloc_func(cBitmap, alloc);
|
153
|
+
rb_define_private_method(cBitmap, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
333
154
|
rb_define_private_method(cBitmap, "setup", RUBY_METHOD_FUNC(setup), 3);
|
334
155
|
rb_define_method(cBitmap, "draw_string", RUBY_METHOD_FUNC(draw_string), -1);
|
335
156
|
rb_define_method(cBitmap, "width", RUBY_METHOD_FUNC(width), 0);
|
336
157
|
rb_define_method(cBitmap, "height", RUBY_METHOD_FUNC(height), 0);
|
337
158
|
rb_define_method(cBitmap, "color_space", RUBY_METHOD_FUNC(color_space), 0);
|
338
159
|
cBitmap.define_method("[]", at);
|
339
|
-
cBitmap
|
160
|
+
rb_define_method(cBitmap, "set_at", RUBY_METHOD_FUNC(set_at), 3);
|
161
|
+
rb_define_method(cBitmap, "to_texture", RUBY_METHOD_FUNC(to_texture), -1);
|
162
|
+
rb_define_method(cBitmap, "save", RUBY_METHOD_FUNC(save), 1);
|
340
163
|
rb_define_function(cBitmap, "load", RUBY_METHOD_FUNC(load), 1);
|
341
164
|
}
|
165
|
+
|
166
|
+
|
167
|
+
namespace Rays
|
168
|
+
{
|
169
|
+
|
170
|
+
|
171
|
+
Class
|
172
|
+
bitmap_class ()
|
173
|
+
{
|
174
|
+
return cBitmap;
|
175
|
+
}
|
176
|
+
|
177
|
+
|
178
|
+
}// Rays
|