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
@@ -0,0 +1,174 @@
|
|
1
|
+
#include "rays/ruby/color_space.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <rucy.h>
|
5
|
+
#include "defs.h"
|
6
|
+
|
7
|
+
|
8
|
+
using namespace Rucy;
|
9
|
+
|
10
|
+
|
11
|
+
static Class cColorSpace;
|
12
|
+
|
13
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::ColorSpace, cColorSpace)
|
14
|
+
|
15
|
+
#define THIS to<Rays::ColorSpace*>(self)
|
16
|
+
|
17
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::ColorSpace, cColorSpace, self)
|
18
|
+
|
19
|
+
|
20
|
+
static
|
21
|
+
VALUE alloc(VALUE klass)
|
22
|
+
{
|
23
|
+
return new_type<Rays::ColorSpace>(klass);
|
24
|
+
}
|
25
|
+
|
26
|
+
static
|
27
|
+
VALUE setup(VALUE self, VALUE type, VALUE premultiplied)
|
28
|
+
{
|
29
|
+
CHECK;
|
30
|
+
|
31
|
+
*THIS = Rays::ColorSpace(
|
32
|
+
(Rays::ColorSpaceType) to<uint>(type),
|
33
|
+
to<bool>(premultiplied));
|
34
|
+
return self;
|
35
|
+
}
|
36
|
+
|
37
|
+
static
|
38
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
39
|
+
{
|
40
|
+
CHECK;
|
41
|
+
*THIS = to<Rays::ColorSpace&>(obj);
|
42
|
+
return self;
|
43
|
+
}
|
44
|
+
|
45
|
+
static
|
46
|
+
VALUE type(VALUE self)
|
47
|
+
{
|
48
|
+
CHECK;
|
49
|
+
|
50
|
+
return value(THIS->type());
|
51
|
+
}
|
52
|
+
|
53
|
+
static
|
54
|
+
VALUE is_gray(VALUE self)
|
55
|
+
{
|
56
|
+
CHECK;
|
57
|
+
|
58
|
+
return value(THIS->is_gray());
|
59
|
+
}
|
60
|
+
|
61
|
+
static
|
62
|
+
VALUE is_rgb(VALUE self)
|
63
|
+
{
|
64
|
+
CHECK;
|
65
|
+
|
66
|
+
return value(THIS->is_rgb());
|
67
|
+
}
|
68
|
+
|
69
|
+
static
|
70
|
+
VALUE is_bgr(VALUE self)
|
71
|
+
{
|
72
|
+
CHECK;
|
73
|
+
|
74
|
+
return value(THIS->is_bgr());
|
75
|
+
}
|
76
|
+
|
77
|
+
static
|
78
|
+
VALUE is_float(VALUE self)
|
79
|
+
{
|
80
|
+
CHECK;
|
81
|
+
|
82
|
+
return value(THIS->is_float());
|
83
|
+
}
|
84
|
+
|
85
|
+
static
|
86
|
+
VALUE has_alpha(VALUE self)
|
87
|
+
{
|
88
|
+
CHECK;
|
89
|
+
|
90
|
+
return value(THIS->has_alpha());
|
91
|
+
}
|
92
|
+
|
93
|
+
static
|
94
|
+
VALUE has_skip(VALUE self)
|
95
|
+
{
|
96
|
+
CHECK;
|
97
|
+
|
98
|
+
return value(THIS->has_skip());
|
99
|
+
}
|
100
|
+
|
101
|
+
static
|
102
|
+
VALUE is_premult(VALUE self)
|
103
|
+
{
|
104
|
+
CHECK;
|
105
|
+
|
106
|
+
return value(THIS->is_premult());
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
void
|
111
|
+
Init_color_space ()
|
112
|
+
{
|
113
|
+
Module mRays = rb_define_module("Rays");
|
114
|
+
|
115
|
+
cColorSpace = rb_define_class_under(mRays, "ColorSpace", rb_cObject);
|
116
|
+
rb_define_alloc_func(cColorSpace, alloc);
|
117
|
+
rb_define_private_method(cColorSpace, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
118
|
+
rb_define_private_method(cColorSpace, "setup", RUBY_METHOD_FUNC(setup), 2);
|
119
|
+
rb_define_method(cColorSpace, "type", RUBY_METHOD_FUNC(type), 0);
|
120
|
+
cColorSpace.define_method("gray?", is_gray);
|
121
|
+
cColorSpace.define_method("rgb?", is_rgb);
|
122
|
+
cColorSpace.define_method("bgr?", is_bgr);
|
123
|
+
cColorSpace.define_method("float?", is_float);
|
124
|
+
cColorSpace.define_method("alpha?", has_alpha);
|
125
|
+
cColorSpace.define_method("skip?", has_skip);
|
126
|
+
cColorSpace.define_method("premult?", is_premult);
|
127
|
+
|
128
|
+
cColorSpace.define_const("GRAY_8", Rays::GRAY_8);
|
129
|
+
cColorSpace.define_const("GRAY_16", Rays::GRAY_16);
|
130
|
+
cColorSpace.define_const("GRAY_24", Rays::GRAY_24);
|
131
|
+
cColorSpace.define_const("GRAY_32", Rays::GRAY_32);
|
132
|
+
cColorSpace.define_const("GRAY_float", Rays::GRAY_float);
|
133
|
+
cColorSpace.define_const("RGB_888", Rays:: RGB_888);
|
134
|
+
cColorSpace.define_const("RGBA_8888", Rays:: RGBA_8888);
|
135
|
+
cColorSpace.define_const("RGBX_8888", Rays:: RGBX_8888);
|
136
|
+
cColorSpace.define_const("ARGB_8888", Rays::ARGB_8888);
|
137
|
+
cColorSpace.define_const("XRGB_8888", Rays::XRGB_8888);
|
138
|
+
cColorSpace.define_const("BGR_888", Rays:: BGR_888);
|
139
|
+
cColorSpace.define_const("BGRA_8888", Rays:: BGRA_8888);
|
140
|
+
cColorSpace.define_const("BGRX_8888", Rays:: BGRX_8888);
|
141
|
+
cColorSpace.define_const("ABGR_8888", Rays::ABGR_8888);
|
142
|
+
cColorSpace.define_const("XBGR_8888", Rays::XBGR_8888);
|
143
|
+
cColorSpace.define_const("RGB_float", Rays:: RGB_float);
|
144
|
+
cColorSpace.define_const("RGBA_float", Rays:: RGBA_float);
|
145
|
+
cColorSpace.define_const("ARGB_float", Rays::ARGB_float);
|
146
|
+
cColorSpace.define_const("BGR_float", Rays:: BGR_float);
|
147
|
+
cColorSpace.define_const("BGRA_float", Rays:: BGRA_float);
|
148
|
+
cColorSpace.define_const("ABGR_float", Rays::ABGR_float);
|
149
|
+
cColorSpace.define_const("GRAY", Rays::GRAY);
|
150
|
+
cColorSpace.define_const("RGB", Rays:: RGB);
|
151
|
+
cColorSpace.define_const("BGR", Rays:: BGR);
|
152
|
+
cColorSpace.define_const("RGBA", Rays:: RGBA);
|
153
|
+
cColorSpace.define_const("RGBX", Rays:: RGBX);
|
154
|
+
cColorSpace.define_const("ARGB", Rays::ARGB);
|
155
|
+
cColorSpace.define_const("XRGB", Rays::XRGB);
|
156
|
+
cColorSpace.define_const("BGRA", Rays:: BGRA);
|
157
|
+
cColorSpace.define_const("BGRX", Rays:: BGRX);
|
158
|
+
cColorSpace.define_const("ABGR", Rays::ABGR);
|
159
|
+
cColorSpace.define_const("XBGR", Rays::XBGR);
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
namespace Rays
|
164
|
+
{
|
165
|
+
|
166
|
+
|
167
|
+
Class
|
168
|
+
color_space_class ()
|
169
|
+
{
|
170
|
+
return cColorSpace;
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
}// Rays
|
data/.doc/ext/rays/font.cpp
CHANGED
@@ -12,44 +12,11 @@ using Rays::coord;
|
|
12
12
|
|
13
13
|
static Class cFont;
|
14
14
|
|
15
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::Font, cFont)
|
15
16
|
|
16
|
-
|
17
|
-
{
|
18
|
-
|
19
|
-
|
20
|
-
Class
|
21
|
-
font_class ()
|
22
|
-
{
|
23
|
-
return cFont;
|
24
|
-
}
|
25
|
-
|
26
|
-
|
27
|
-
}// Rays
|
28
|
-
|
29
|
-
|
30
|
-
namespace Rucy
|
31
|
-
{
|
32
|
-
|
33
|
-
|
34
|
-
Value
|
35
|
-
value (const Rays::Font& obj)
|
36
|
-
{
|
37
|
-
return new_type(cFont, new Rays::Font(obj));
|
38
|
-
}
|
39
|
-
|
40
|
-
Value
|
41
|
-
value (const Rays::Font* obj)
|
42
|
-
{
|
43
|
-
return obj ? value(*obj) : nil();
|
44
|
-
}
|
45
|
-
|
46
|
-
|
47
|
-
}// Rucy
|
48
|
-
|
49
|
-
|
50
|
-
#define THIS to<Rays::Font*>(self)
|
17
|
+
#define THIS to<Rays::Font*>(self)
|
51
18
|
|
52
|
-
#define CHECK RUCY_CHECK_OBJECT(
|
19
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::Font, cFont, self)
|
53
20
|
|
54
21
|
|
55
22
|
static
|
@@ -61,9 +28,8 @@ VALUE alloc(VALUE klass)
|
|
61
28
|
static
|
62
29
|
VALUE initialize(VALUE self)
|
63
30
|
{
|
64
|
-
RUCY_CHECK_OBJ(
|
65
|
-
|
66
|
-
arg_count_error("Font#initialize", argc, 0, 1, 2);
|
31
|
+
RUCY_CHECK_OBJ(Rays::Font, cFont, self);
|
32
|
+
check_arg_count(__FILE__, __LINE__, "Font#initialize", argc, 0, 1, 2);
|
67
33
|
|
68
34
|
const char* name = (argc >= 1) ? argv[0].c_str() : NULL;
|
69
35
|
float size = (argc >= 2) ? to<float>(argv[1]) : 0;
|
@@ -72,11 +38,19 @@ VALUE initialize(VALUE self)
|
|
72
38
|
return self;
|
73
39
|
}
|
74
40
|
|
41
|
+
static
|
42
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
43
|
+
{
|
44
|
+
RUCY_CHECK_OBJ(Rays::Font, cFont, self);
|
45
|
+
|
46
|
+
*THIS = to<Rays::Font&>(obj).copy();
|
47
|
+
return self;
|
48
|
+
}
|
49
|
+
|
75
50
|
static
|
76
51
|
VALUE name(VALUE self)
|
77
52
|
{
|
78
53
|
CHECK;
|
79
|
-
|
80
54
|
return value(THIS->name().c_str());
|
81
55
|
}
|
82
56
|
|
@@ -84,7 +58,6 @@ static
|
|
84
58
|
VALUE size(VALUE self)
|
85
59
|
{
|
86
60
|
CHECK;
|
87
|
-
|
88
61
|
return value(THIS->size());
|
89
62
|
}
|
90
63
|
|
@@ -92,24 +65,14 @@ static
|
|
92
65
|
VALUE width(VALUE self, VALUE str)
|
93
66
|
{
|
94
67
|
CHECK;
|
95
|
-
|
96
|
-
coord width = 0;
|
97
|
-
if (!THIS->get_width(&width, str.c_str()))
|
98
|
-
rays_error("Font#width(%s) failed.", str.inspect().c_str());
|
99
|
-
|
100
|
-
return value(width);
|
68
|
+
return value(THIS->get_width(str.c_str()));
|
101
69
|
}
|
102
70
|
|
103
71
|
static
|
104
72
|
VALUE height(VALUE self)
|
105
73
|
{
|
106
74
|
CHECK;
|
107
|
-
|
108
|
-
coord height = 0;
|
109
|
-
if (!THIS->get_height(&height))
|
110
|
-
rays_error("Font#height() failed.");
|
111
|
-
|
112
|
-
return value(height);
|
75
|
+
return value(THIS->get_height());
|
113
76
|
}
|
114
77
|
|
115
78
|
|
@@ -121,8 +84,23 @@ Init_font ()
|
|
121
84
|
cFont = rb_define_class_under(mRays, "Font", rb_cObject);
|
122
85
|
rb_define_alloc_func(cFont, alloc);
|
123
86
|
rb_define_private_method(cFont, "initialize", RUBY_METHOD_FUNC(initialize), -1);
|
87
|
+
rb_define_private_method(cFont, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
124
88
|
rb_define_method(cFont, "name", RUBY_METHOD_FUNC(name), 0);
|
125
89
|
rb_define_method(cFont, "size", RUBY_METHOD_FUNC(size), 0);
|
126
90
|
rb_define_method(cFont, "width", RUBY_METHOD_FUNC(width), 1);
|
127
91
|
rb_define_method(cFont, "height", RUBY_METHOD_FUNC(height), 0);
|
128
92
|
}
|
93
|
+
|
94
|
+
|
95
|
+
namespace Rays
|
96
|
+
{
|
97
|
+
|
98
|
+
|
99
|
+
Class
|
100
|
+
font_class ()
|
101
|
+
{
|
102
|
+
return cFont;
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
}// Rays
|
data/.doc/ext/rays/image.cpp
CHANGED
@@ -2,8 +2,10 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
#include <rucy.h>
|
5
|
-
#include
|
6
|
-
#include
|
5
|
+
#include "rays/ruby/color_space.h"
|
6
|
+
#include "rays/ruby/bitmap.h"
|
7
|
+
#include "rays/ruby/texture.h"
|
8
|
+
#include "rays/ruby/painter.h"
|
7
9
|
#include "defs.h"
|
8
10
|
|
9
11
|
|
@@ -14,44 +16,11 @@ using Rays::coord;
|
|
14
16
|
|
15
17
|
static Class cImage;
|
16
18
|
|
19
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::Image, cImage)
|
17
20
|
|
18
|
-
|
19
|
-
{
|
20
|
-
|
21
|
-
|
22
|
-
Class
|
23
|
-
image_class ()
|
24
|
-
{
|
25
|
-
return cImage;
|
26
|
-
}
|
21
|
+
#define THIS to<Rays::Image*>(self)
|
27
22
|
|
28
|
-
|
29
|
-
}// Rays
|
30
|
-
|
31
|
-
|
32
|
-
namespace Rucy
|
33
|
-
{
|
34
|
-
|
35
|
-
|
36
|
-
Value
|
37
|
-
value (const Rays::Image& obj)
|
38
|
-
{
|
39
|
-
return new_type(cImage, new Rays::Image(obj));
|
40
|
-
}
|
41
|
-
|
42
|
-
Value
|
43
|
-
value (const Rays::Image* obj)
|
44
|
-
{
|
45
|
-
return obj ? value(*obj) : nil();
|
46
|
-
}
|
47
|
-
|
48
|
-
|
49
|
-
}// Rucy
|
50
|
-
|
51
|
-
|
52
|
-
#define THIS to<Rays::Image*>(self)
|
53
|
-
|
54
|
-
#define CHECK RUCY_CHECK_OBJECT(self, Rays::Image, cImage)
|
23
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::Image, cImage, self)
|
55
24
|
|
56
25
|
|
57
26
|
static
|
@@ -63,23 +32,20 @@ VALUE alloc(VALUE klass)
|
|
63
32
|
static
|
64
33
|
VALUE initialize(VALUE self)
|
65
34
|
{
|
66
|
-
RUCY_CHECK_OBJ(
|
67
|
-
|
68
|
-
if (argc < 1 || 3 < argc)
|
69
|
-
arg_count_error("Image#initialize", argc, 1, 2, 3);
|
35
|
+
RUCY_CHECK_OBJ(Rays::Image, cImage, self);
|
36
|
+
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3);
|
70
37
|
|
71
38
|
if (argc == 0) return self;
|
72
39
|
|
73
40
|
if (argv[0].is_kind_of(Rays::bitmap_class()))
|
74
41
|
{
|
75
|
-
|
76
|
-
arg_count_error("Image#initialize", argc, 1, 2);
|
42
|
+
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2);
|
77
43
|
|
78
44
|
const Rays::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
|
79
|
-
if (!bitmap) argument_error();
|
45
|
+
if (!bitmap) argument_error(__FILE__, __LINE__);
|
80
46
|
|
81
|
-
bool
|
82
|
-
*THIS = Rays::Image(*bitmap,
|
47
|
+
bool alpha_only = (argc == 2) ? to<bool>(argv[1]) : false;
|
48
|
+
*THIS = Rays::Image(*bitmap, alpha_only);
|
83
49
|
}
|
84
50
|
else
|
85
51
|
{
|
@@ -93,10 +59,25 @@ VALUE initialize(VALUE self)
|
|
93
59
|
}
|
94
60
|
|
95
61
|
static
|
96
|
-
VALUE
|
62
|
+
VALUE initialize_copy(VALUE self, VALUE obj)
|
63
|
+
{
|
64
|
+
RUCY_CHECK_OBJ(Rays::Image, cImage, self);
|
65
|
+
|
66
|
+
*THIS = to<Rays::Image&>(obj).copy();
|
67
|
+
return self;
|
68
|
+
}
|
69
|
+
|
70
|
+
static
|
71
|
+
VALUE painter(VALUE self)
|
97
72
|
{
|
98
73
|
CHECK;
|
74
|
+
return value(THIS->painter());
|
75
|
+
}
|
99
76
|
|
77
|
+
static
|
78
|
+
VALUE width(VALUE self)
|
79
|
+
{
|
80
|
+
CHECK;
|
100
81
|
return value(THIS->width());
|
101
82
|
}
|
102
83
|
|
@@ -104,7 +85,6 @@ static
|
|
104
85
|
VALUE height(VALUE self)
|
105
86
|
{
|
106
87
|
CHECK;
|
107
|
-
|
108
88
|
return value(THIS->height());
|
109
89
|
}
|
110
90
|
|
@@ -112,15 +92,20 @@ static
|
|
112
92
|
VALUE color_space(VALUE self)
|
113
93
|
{
|
114
94
|
CHECK;
|
95
|
+
return value(THIS->color_space());
|
96
|
+
}
|
115
97
|
|
116
|
-
|
98
|
+
static
|
99
|
+
VALUE alpha_only(VALUE self)
|
100
|
+
{
|
101
|
+
CHECK;
|
102
|
+
return value(THIS->alpha_only());
|
117
103
|
}
|
118
104
|
|
119
105
|
static
|
120
106
|
VALUE bitmap(VALUE self)
|
121
107
|
{
|
122
108
|
CHECK;
|
123
|
-
|
124
109
|
return value(THIS->bitmap());
|
125
110
|
}
|
126
111
|
|
@@ -128,28 +113,22 @@ static
|
|
128
113
|
VALUE texture(VALUE self)
|
129
114
|
{
|
130
115
|
CHECK;
|
131
|
-
|
132
116
|
return value(THIS->texture());
|
133
117
|
}
|
134
118
|
|
135
|
-
|
136
119
|
static
|
137
|
-
VALUE
|
120
|
+
VALUE save(VALUE self, VALUE path)
|
138
121
|
{
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
122
|
+
CHECK;
|
123
|
+
Rays::save_image(*THIS, path.c_str());
|
124
|
+
return self;
|
125
|
+
}
|
143
126
|
|
144
|
-
Rays::Image img;
|
145
|
-
if (!Rays::load_image(&img, path.c_str(), alphaonly))
|
146
|
-
{
|
147
|
-
rays_error(
|
148
|
-
"Image.load('%s', %s) failed.",
|
149
|
-
path.c_str(), alphaonly ? "true" : "false");
|
150
|
-
}
|
151
127
|
|
152
|
-
|
128
|
+
static
|
129
|
+
VALUE load(VALUE self, VALUE path, VALUE alpha_only)
|
130
|
+
{
|
131
|
+
return value(Rays::load_image(path.c_str(), to<bool>(alpha_only)));
|
153
132
|
}
|
154
133
|
|
155
134
|
|
@@ -161,10 +140,28 @@ Init_image ()
|
|
161
140
|
cImage = rb_define_class_under(mRays, "Image", rb_cObject);
|
162
141
|
rb_define_alloc_func(cImage, alloc);
|
163
142
|
rb_define_private_method(cImage, "initialize", RUBY_METHOD_FUNC(initialize), -1);
|
143
|
+
rb_define_private_method(cImage, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
144
|
+
rb_define_method(cImage, "painter", RUBY_METHOD_FUNC(painter), 0);
|
164
145
|
rb_define_method(cImage, "width", RUBY_METHOD_FUNC(width), 0);
|
165
146
|
rb_define_method(cImage, "height", RUBY_METHOD_FUNC(height), 0);
|
166
147
|
rb_define_method(cImage, "color_space", RUBY_METHOD_FUNC(color_space), 0);
|
148
|
+
rb_define_method(cImage, "alpha_only", RUBY_METHOD_FUNC(alpha_only), 0);
|
167
149
|
rb_define_method(cImage, "bitmap", RUBY_METHOD_FUNC(bitmap), 0);
|
168
150
|
rb_define_method(cImage, "texture", RUBY_METHOD_FUNC(texture), 0);
|
169
|
-
|
151
|
+
rb_define_method(cImage, "save", RUBY_METHOD_FUNC(save), 1);
|
152
|
+
rb_define_function(cImage, "load_image", RUBY_METHOD_FUNC(load), 2);
|
170
153
|
}
|
154
|
+
|
155
|
+
|
156
|
+
namespace Rays
|
157
|
+
{
|
158
|
+
|
159
|
+
|
160
|
+
Class
|
161
|
+
image_class ()
|
162
|
+
{
|
163
|
+
return cImage;
|
164
|
+
}
|
165
|
+
|
166
|
+
|
167
|
+
}// Rays
|
data/.doc/ext/rays/matrix.cpp
CHANGED
@@ -10,44 +10,11 @@ using namespace Rucy;
|
|
10
10
|
|
11
11
|
static Class cMatrix;
|
12
12
|
|
13
|
+
RUCY_DEFINE_VALUE_FROM_TO(Rays::Matrix, cMatrix)
|
13
14
|
|
14
|
-
|
15
|
-
{
|
16
|
-
|
17
|
-
|
18
|
-
Class
|
19
|
-
matrix_class ()
|
20
|
-
{
|
21
|
-
return cMatrix;
|
22
|
-
}
|
23
|
-
|
24
|
-
|
25
|
-
}// Rays
|
26
|
-
|
27
|
-
|
28
|
-
namespace Rucy
|
29
|
-
{
|
30
|
-
|
31
|
-
|
32
|
-
Value
|
33
|
-
value (const Rays::Matrix& obj)
|
34
|
-
{
|
35
|
-
return new_type(cMatrix, new Rays::Matrix(obj));
|
36
|
-
}
|
37
|
-
|
38
|
-
Value
|
39
|
-
value (const Rays::Matrix* obj)
|
40
|
-
{
|
41
|
-
return obj ? value(*obj) : nil();
|
42
|
-
}
|
43
|
-
|
44
|
-
|
45
|
-
}// Rucy
|
15
|
+
#define THIS to<Rays::Matrix*>(self)
|
46
16
|
|
47
|
-
|
48
|
-
#define THIS to<Rays::Matrix*>(self)
|
49
|
-
|
50
|
-
#define CHECK RUCY_CHECK_OBJ(self, Rays::Matrix, cMatrix)
|
17
|
+
#define CHECK RUCY_CHECK_OBJ(Rays::Matrix, cMatrix, self)
|
51
18
|
|
52
19
|
|
53
20
|
static
|
@@ -59,10 +26,8 @@ VALUE alloc(VALUE klass)
|
|
59
26
|
static
|
60
27
|
VALUE initialize(VALUE self)
|
61
28
|
{
|
62
|
-
|
63
|
-
|
64
|
-
if (argc != 0 && argc != 1 && argc != 16)
|
65
|
-
arg_count_error("Matrix#initialize", argc, 0, 1, 16);
|
29
|
+
CHECK;
|
30
|
+
check_arg_count(__FILE__, __LINE__, "Matrix#initialize", argc, 0, 1, 16);
|
66
31
|
|
67
32
|
if (argc == 0) return self;
|
68
33
|
|
@@ -87,12 +52,8 @@ VALUE initialize(VALUE self)
|
|
87
52
|
static
|
88
53
|
VALUE initialize_copy(VALUE self, VALUE obj)
|
89
54
|
{
|
90
|
-
|
91
|
-
|
92
|
-
Rays::Matrix* matrix = to<Rays::Matrix*>(obj);
|
93
|
-
if (!matrix) argument_error();
|
94
|
-
|
95
|
-
*THIS = *matrix;
|
55
|
+
CHECK;
|
56
|
+
*THIS = to<Rays::Matrix&>(obj);
|
96
57
|
return self;
|
97
58
|
}
|
98
59
|
|
@@ -100,9 +61,7 @@ static
|
|
100
61
|
VALUE set(VALUE self)
|
101
62
|
{
|
102
63
|
CHECK;
|
103
|
-
|
104
|
-
if (argc != 0 && argc != 1 && argc != 16)
|
105
|
-
arg_count_error("Matrix#initialize", argc, 0, 1, 16);
|
64
|
+
check_arg_count(__FILE__, __LINE__, "Matrix#initialize", argc, 0, 1, 16);
|
106
65
|
|
107
66
|
switch (argc)
|
108
67
|
{
|
@@ -130,7 +89,6 @@ static
|
|
130
89
|
VALUE at(VALUE self, VALUE row, VALUE column)
|
131
90
|
{
|
132
91
|
CHECK;
|
133
|
-
|
134
92
|
return value(THIS->at(row.as_i(), column.as_i()));
|
135
93
|
}
|
136
94
|
|
@@ -147,3 +105,17 @@ Init_matrix ()
|
|
147
105
|
rb_define_method(cMatrix, "set", RUBY_METHOD_FUNC(set), -1);
|
148
106
|
rb_define_method(cMatrix, "at", RUBY_METHOD_FUNC(at), 2);
|
149
107
|
}
|
108
|
+
|
109
|
+
|
110
|
+
namespace Rays
|
111
|
+
{
|
112
|
+
|
113
|
+
|
114
|
+
Class
|
115
|
+
matrix_class ()
|
116
|
+
{
|
117
|
+
return cMatrix;
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
}// Rays
|
data/.doc/ext/rays/native.cpp
CHANGED
@@ -9,26 +9,33 @@ void Init_rays ();
|
|
9
9
|
void Init_point ();
|
10
10
|
void Init_bounds ();
|
11
11
|
void Init_color ();
|
12
|
+
void Init_color_space ();
|
12
13
|
void Init_bitmap ();
|
13
14
|
void Init_texture ();
|
14
15
|
void Init_image ();
|
15
16
|
void Init_font ();
|
17
|
+
void Init_shader ();
|
16
18
|
void Init_painter ();
|
17
19
|
|
18
20
|
|
19
21
|
extern "C" void
|
20
22
|
Init_native ()
|
21
23
|
{
|
22
|
-
|
23
|
-
|
24
|
+
RUCY_TRY
|
25
|
+
|
26
|
+
Rucy::init();
|
24
27
|
|
25
28
|
Init_rays();
|
26
29
|
Init_point();
|
27
30
|
Init_bounds();
|
28
31
|
Init_color();
|
32
|
+
Init_color_space();
|
29
33
|
Init_bitmap();
|
30
34
|
Init_texture();
|
31
35
|
Init_image();
|
32
36
|
Init_font();
|
37
|
+
Init_shader();
|
33
38
|
Init_painter();
|
39
|
+
|
40
|
+
RUCY_CATCH
|
34
41
|
}
|