rays 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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
data/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,73 +16,37 @@ 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
|
-
}
|
27
|
-
|
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)
|
21
|
+
#define THIS to<Rays::Image*>(self)
|
53
22
|
|
54
|
-
#define CHECK RUCY_CHECK_OBJECT(
|
23
|
+
#define CHECK RUCY_CHECK_OBJECT(Rays::Image, cImage, self)
|
55
24
|
|
56
25
|
|
57
26
|
static
|
58
|
-
|
27
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
59
28
|
{
|
60
29
|
return new_type<Rays::Image>(klass);
|
61
30
|
}
|
62
|
-
|
31
|
+
RUCY_END
|
63
32
|
|
64
33
|
static
|
65
|
-
|
34
|
+
RUCY_DEFN(initialize)
|
66
35
|
{
|
67
|
-
RUCY_CHECK_OBJ(
|
68
|
-
|
69
|
-
if (argc < 1 || 3 < argc)
|
70
|
-
arg_count_error("Image#initialize", argc, 1, 2, 3);
|
36
|
+
RUCY_CHECK_OBJ(Rays::Image, cImage, self);
|
37
|
+
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3);
|
71
38
|
|
72
39
|
if (argc == 0) return self;
|
73
40
|
|
74
41
|
if (argv[0].is_kind_of(Rays::bitmap_class()))
|
75
42
|
{
|
76
|
-
|
77
|
-
arg_count_error("Image#initialize", argc, 1, 2);
|
43
|
+
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2);
|
78
44
|
|
79
45
|
const Rays::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
|
80
|
-
if (!bitmap) argument_error();
|
46
|
+
if (!bitmap) argument_error(__FILE__, __LINE__);
|
81
47
|
|
82
|
-
bool
|
83
|
-
*THIS = Rays::Image(*bitmap,
|
48
|
+
bool alpha_only = (argc == 2) ? to<bool>(argv[1]) : false;
|
49
|
+
*THIS = Rays::Image(*bitmap, alpha_only);
|
84
50
|
}
|
85
51
|
else
|
86
52
|
{
|
@@ -92,73 +58,90 @@ RUBY_DEFN(initialize)
|
|
92
58
|
|
93
59
|
return self;
|
94
60
|
}
|
95
|
-
|
61
|
+
RUCY_END
|
62
|
+
|
63
|
+
static
|
64
|
+
RUCY_DEF1(initialize_copy, obj)
|
65
|
+
{
|
66
|
+
RUCY_CHECK_OBJ(Rays::Image, cImage, self);
|
67
|
+
|
68
|
+
*THIS = to<Rays::Image&>(obj).copy();
|
69
|
+
return self;
|
70
|
+
}
|
71
|
+
RUCY_END
|
96
72
|
|
97
73
|
static
|
98
|
-
|
74
|
+
RUCY_DEF0(painter)
|
99
75
|
{
|
100
76
|
CHECK;
|
77
|
+
return value(THIS->painter());
|
78
|
+
}
|
79
|
+
RUCY_END
|
101
80
|
|
81
|
+
static
|
82
|
+
RUCY_DEF0(width)
|
83
|
+
{
|
84
|
+
CHECK;
|
102
85
|
return value(THIS->width());
|
103
86
|
}
|
104
|
-
|
87
|
+
RUCY_END
|
105
88
|
|
106
89
|
static
|
107
|
-
|
90
|
+
RUCY_DEF0(height)
|
108
91
|
{
|
109
92
|
CHECK;
|
110
|
-
|
111
93
|
return value(THIS->height());
|
112
94
|
}
|
113
|
-
|
95
|
+
RUCY_END
|
114
96
|
|
115
97
|
static
|
116
|
-
|
98
|
+
RUCY_DEF0(color_space)
|
117
99
|
{
|
118
100
|
CHECK;
|
119
|
-
|
120
|
-
return value(THIS->color_space().type());
|
101
|
+
return value(THIS->color_space());
|
121
102
|
}
|
122
|
-
|
103
|
+
RUCY_END
|
123
104
|
|
124
105
|
static
|
125
|
-
|
106
|
+
RUCY_DEF0(alpha_only)
|
126
107
|
{
|
127
108
|
CHECK;
|
109
|
+
return value(THIS->alpha_only());
|
110
|
+
}
|
111
|
+
RUCY_END
|
128
112
|
|
113
|
+
static
|
114
|
+
RUCY_DEF0(bitmap)
|
115
|
+
{
|
116
|
+
CHECK;
|
129
117
|
return value(THIS->bitmap());
|
130
118
|
}
|
131
|
-
|
119
|
+
RUCY_END
|
132
120
|
|
133
121
|
static
|
134
|
-
|
122
|
+
RUCY_DEF0(texture)
|
135
123
|
{
|
136
124
|
CHECK;
|
137
|
-
|
138
125
|
return value(THIS->texture());
|
139
126
|
}
|
140
|
-
|
141
|
-
|
127
|
+
RUCY_END
|
142
128
|
|
143
129
|
static
|
144
|
-
|
130
|
+
RUCY_DEF1(save, path)
|
145
131
|
{
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
132
|
+
CHECK;
|
133
|
+
Rays::save_image(*THIS, path.c_str());
|
134
|
+
return self;
|
135
|
+
}
|
136
|
+
RUCY_END
|
150
137
|
|
151
|
-
Rays::Image img;
|
152
|
-
if (!Rays::load_image(&img, path.c_str(), alphaonly))
|
153
|
-
{
|
154
|
-
rays_error(
|
155
|
-
"Image.load('%s', %s) failed.",
|
156
|
-
path.c_str(), alphaonly ? "true" : "false");
|
157
|
-
}
|
158
138
|
|
159
|
-
|
139
|
+
static
|
140
|
+
RUCY_DEF2(load, path, alpha_only)
|
141
|
+
{
|
142
|
+
return value(Rays::load_image(path.c_str(), to<bool>(alpha_only)));
|
160
143
|
}
|
161
|
-
|
144
|
+
RUCY_END
|
162
145
|
|
163
146
|
|
164
147
|
void
|
@@ -169,10 +152,28 @@ Init_image ()
|
|
169
152
|
cImage = mRays.define_class("Image");
|
170
153
|
cImage.define_alloc_func(alloc);
|
171
154
|
cImage.define_private_method("initialize", initialize);
|
155
|
+
cImage.define_private_method("initialize_copy", initialize_copy);
|
156
|
+
cImage.define_method("painter", painter);
|
172
157
|
cImage.define_method("width", width);
|
173
158
|
cImage.define_method("height", height);
|
174
159
|
cImage.define_method("color_space", color_space);
|
160
|
+
cImage.define_method("alpha_only", alpha_only);
|
175
161
|
cImage.define_method("bitmap", bitmap);
|
176
162
|
cImage.define_method("texture", texture);
|
177
|
-
cImage.
|
163
|
+
cImage.define_method("save", save);
|
164
|
+
cImage.define_function("load_image", load);
|
178
165
|
}
|
166
|
+
|
167
|
+
|
168
|
+
namespace Rays
|
169
|
+
{
|
170
|
+
|
171
|
+
|
172
|
+
Class
|
173
|
+
image_class ()
|
174
|
+
{
|
175
|
+
return cImage;
|
176
|
+
}
|
177
|
+
|
178
|
+
|
179
|
+
}// Rays
|
data/ext/rays/matrix.cpp
CHANGED
@@ -10,60 +10,25 @@ 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
|
54
|
-
|
21
|
+
RUCY_DEF_ALLOC(alloc, klass)
|
55
22
|
{
|
56
23
|
return new_type<Rays::Matrix>(klass);
|
57
24
|
}
|
58
|
-
|
25
|
+
RUCY_END
|
59
26
|
|
60
27
|
static
|
61
|
-
|
28
|
+
RUCY_DEFN(initialize)
|
62
29
|
{
|
63
|
-
|
64
|
-
|
65
|
-
if (argc != 0 && argc != 1 && argc != 16)
|
66
|
-
arg_count_error("Matrix#initialize", argc, 0, 1, 16);
|
30
|
+
CHECK;
|
31
|
+
check_arg_count(__FILE__, __LINE__, "Matrix#initialize", argc, 0, 1, 16);
|
67
32
|
|
68
33
|
if (argc == 0) return self;
|
69
34
|
|
@@ -84,28 +49,22 @@ RUBY_DEFN(initialize)
|
|
84
49
|
|
85
50
|
return self;
|
86
51
|
}
|
87
|
-
|
52
|
+
RUCY_END
|
88
53
|
|
89
54
|
static
|
90
|
-
|
55
|
+
RUCY_DEF1(initialize_copy, obj)
|
91
56
|
{
|
92
|
-
|
93
|
-
|
94
|
-
Rays::Matrix* matrix = to<Rays::Matrix*>(obj);
|
95
|
-
if (!matrix) argument_error();
|
96
|
-
|
97
|
-
*THIS = *matrix;
|
57
|
+
CHECK;
|
58
|
+
*THIS = to<Rays::Matrix&>(obj);
|
98
59
|
return self;
|
99
60
|
}
|
100
|
-
|
61
|
+
RUCY_END
|
101
62
|
|
102
63
|
static
|
103
|
-
|
64
|
+
RUCY_DEFN(set)
|
104
65
|
{
|
105
66
|
CHECK;
|
106
|
-
|
107
|
-
if (argc != 0 && argc != 1 && argc != 16)
|
108
|
-
arg_count_error("Matrix#initialize", argc, 0, 1, 16);
|
67
|
+
check_arg_count(__FILE__, __LINE__, "Matrix#initialize", argc, 0, 1, 16);
|
109
68
|
|
110
69
|
switch (argc)
|
111
70
|
{
|
@@ -128,16 +87,15 @@ RUBY_DEFN(set)
|
|
128
87
|
|
129
88
|
return self;
|
130
89
|
}
|
131
|
-
|
90
|
+
RUCY_END
|
132
91
|
|
133
92
|
static
|
134
|
-
|
93
|
+
RUCY_DEF2(at, row, column)
|
135
94
|
{
|
136
95
|
CHECK;
|
137
|
-
|
138
96
|
return value(THIS->at(row.as_i(), column.as_i()));
|
139
97
|
}
|
140
|
-
|
98
|
+
RUCY_END
|
141
99
|
|
142
100
|
|
143
101
|
void
|
@@ -152,3 +110,17 @@ Init_matrix ()
|
|
152
110
|
cMatrix.define_method("set", set);
|
153
111
|
cMatrix.define_method("at", at);
|
154
112
|
}
|
113
|
+
|
114
|
+
|
115
|
+
namespace Rays
|
116
|
+
{
|
117
|
+
|
118
|
+
|
119
|
+
Class
|
120
|
+
matrix_class ()
|
121
|
+
{
|
122
|
+
return cMatrix;
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
}// Rays
|
data/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
|
}
|