rays 0.3 → 0.3.1
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 +4 -4
- data/.doc/ext/rays/bounds.cpp +14 -10
- data/.doc/ext/rays/defs.cpp +4 -4
- data/.doc/ext/rays/image.cpp +31 -17
- data/.doc/ext/rays/matrix.cpp +2 -2
- data/.doc/ext/rays/point.cpp +8 -4
- data/.doc/ext/rays/polygon.cpp +8 -6
- data/.doc/ext/rays/polyline.cpp +3 -1
- data/.doc/ext/rays/rays.cpp +15 -5
- data/.doc/ext/rays/shader.cpp +1 -1
- data/ChangeLog.md +6 -0
- data/Gemfile.lock +1 -1
- data/LICENSE +1 -1
- data/Rakefile +0 -1
- data/VERSION +1 -1
- data/ext/rays/bounds.cpp +14 -10
- data/ext/rays/defs.cpp +4 -4
- data/ext/rays/image.cpp +33 -17
- data/ext/rays/matrix.cpp +2 -2
- data/ext/rays/point.cpp +8 -4
- data/ext/rays/polygon.cpp +8 -6
- data/ext/rays/polyline.cpp +3 -1
- data/ext/rays/rays.cpp +15 -5
- data/ext/rays/shader.cpp +1 -1
- data/include/rays/image.h +8 -2
- data/lib/rays/image.rb +4 -0
- data/rays.gemspec +2 -2
- data/src/bounds.cpp +6 -2
- data/src/color.cpp +12 -4
- data/src/image.cpp +32 -4
- data/src/ios/bitmap.mm +18 -4
- data/src/ios/font.mm +3 -1
- data/src/osx/bitmap.mm +18 -4
- data/src/osx/font.mm +3 -1
- data/src/painter.cpp +3 -1
- data/src/point.cpp +15 -3
- data/src/polygon.cpp +3 -5
- data/src/render_buffer.cpp +11 -3
- data/src/shader_program.cpp +19 -9
- data/src/shader_source.cpp +5 -1
- data/src/texture.cpp +33 -11
- data/src/texture.h +6 -2
- data/src/win32/bitmap.cpp +12 -2
- data/src/win32/font.cpp +3 -1
- data/test/test_painter_shape.rb +6 -5
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9afd571fda027a889bb3d2ba60886e08ee8de5b825690d28838d10e729e5097d
|
4
|
+
data.tar.gz: 2bd0652be52c0f2f135cad35abe6b1b7140e90185ef9ec725e673aec2563f041
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94278334d219aebbaa3bd11b51f87555b230e8cd296115ccc06476b76f4240c0d5c4d976949b7bd04ce4b11aa056b738e7c9e5247dec8d75d14d36d5c7e388a0
|
7
|
+
data.tar.gz: 9ffd24082a1f0f37d6fbbb5ce016395069de981ba3c1ff0538392de790029f7ed69d50b739fa6a0debe7b5461b8624704c46b5e36967342c22250f8c655bbf0e
|
data/.doc/ext/rays/bounds.cpp
CHANGED
@@ -70,7 +70,7 @@ VALUE move_to(VALUE self)
|
|
70
70
|
CHECK;
|
71
71
|
check_arg_count(__FILE__, __LINE__, "Bounds#move_to", argc, 1, 2, 3);
|
72
72
|
|
73
|
-
if (argv[0].
|
73
|
+
if (argv[0].is_a(Rays::point_class()))
|
74
74
|
THIS->move_to(to<Rays::Point&>(argv[0]));
|
75
75
|
else
|
76
76
|
{
|
@@ -96,7 +96,7 @@ VALUE move_by(VALUE self)
|
|
96
96
|
CHECK;
|
97
97
|
check_arg_count(__FILE__, __LINE__, "Bounds#move_by", argc, 1, 2, 3);
|
98
98
|
|
99
|
-
if (argv[0].
|
99
|
+
if (argv[0].is_a(Rays::point_class()))
|
100
100
|
THIS->move_by(to<Rays::Point&>(argv[0]));
|
101
101
|
else
|
102
102
|
{
|
@@ -121,7 +121,7 @@ VALUE resize_to(VALUE self)
|
|
121
121
|
CHECK;
|
122
122
|
check_arg_count(__FILE__, __LINE__, "Bounds#resize_to", argc, 1, 2, 3);
|
123
123
|
|
124
|
-
if (argv[0].
|
124
|
+
if (argv[0].is_a(Rays::point_class()))
|
125
125
|
THIS->resize_to(to<Rays::Point&>(argv[0]));
|
126
126
|
else
|
127
127
|
{
|
@@ -147,7 +147,7 @@ VALUE resize_by(VALUE self)
|
|
147
147
|
CHECK;
|
148
148
|
check_arg_count(__FILE__, __LINE__, "Bounds#resize_by", argc, 1, 2, 3);
|
149
149
|
|
150
|
-
if (argv[0].
|
150
|
+
if (argv[0].is_a(Rays::point_class()))
|
151
151
|
THIS->resize_by(to<Rays::Point&>(argv[0]));
|
152
152
|
else
|
153
153
|
{
|
@@ -172,7 +172,7 @@ VALUE inset_by(VALUE self)
|
|
172
172
|
CHECK;
|
173
173
|
check_arg_count(__FILE__, __LINE__, "Bounds#inset_by", argc, 1, 2, 3);
|
174
174
|
|
175
|
-
if (argv[0].
|
175
|
+
if (argv[0].is_a(Rays::point_class()))
|
176
176
|
THIS->inset_by(to<Rays::Point&>(argv[0]));
|
177
177
|
else
|
178
178
|
{
|
@@ -460,7 +460,9 @@ VALUE set_at(VALUE self, VALUE index, VALUE value)
|
|
460
460
|
CHECK;
|
461
461
|
|
462
462
|
int i = index.as_i();
|
463
|
-
if (i < 0
|
463
|
+
if (i < 0)
|
464
|
+
index_error(__FILE__, __LINE__);
|
465
|
+
if (i > 1)
|
464
466
|
index_error(__FILE__, __LINE__);
|
465
467
|
|
466
468
|
(*THIS)[i] = to<Rays::Point&>(value);
|
@@ -473,7 +475,9 @@ VALUE get_at(VALUE self, VALUE index)
|
|
473
475
|
CHECK;
|
474
476
|
|
475
477
|
int i = index.as_i();
|
476
|
-
if (i < 0
|
478
|
+
if (i < 0)
|
479
|
+
index_error(__FILE__, __LINE__);
|
480
|
+
if (i > 1)
|
477
481
|
index_error(__FILE__, __LINE__);
|
478
482
|
|
479
483
|
return value((*THIS)[i]);
|
@@ -495,9 +499,9 @@ VALUE op_or(VALUE self, VALUE arg)
|
|
495
499
|
CHECK;
|
496
500
|
|
497
501
|
Rays::Bounds b = *THIS;
|
498
|
-
if (arg.
|
502
|
+
if (arg.is_a(Rays::bounds_class()))
|
499
503
|
b |= to<Rays::Bounds&>(arg);
|
500
|
-
else if (arg.
|
504
|
+
else if (arg.is_a(Rays::point_class()))
|
501
505
|
b |= to<Rays::Point&>(arg);
|
502
506
|
else
|
503
507
|
argument_error(__FILE__, __LINE__);
|
@@ -597,7 +601,7 @@ namespace Rucy
|
|
597
601
|
{
|
598
602
|
if (argc == 0)
|
599
603
|
return Rays::Bounds();
|
600
|
-
else if (argv->
|
604
|
+
else if (argv->is_a(Rays::point_class()))
|
601
605
|
{
|
602
606
|
switch (argc)
|
603
607
|
{
|
data/.doc/ext/rays/defs.cpp
CHANGED
@@ -84,7 +84,7 @@ void get_rect_args (
|
|
84
84
|
if (argc <= 0)
|
85
85
|
argument_error(__FILE__, __LINE__);
|
86
86
|
|
87
|
-
if (argv[0].
|
87
|
+
if (argv[0].is_a(Rays::bounds_class()))
|
88
88
|
{
|
89
89
|
Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
90
90
|
*x = b.x;
|
@@ -96,7 +96,7 @@ void get_rect_args (
|
|
96
96
|
*lb = argc >= 4 ? to<coord>(argv[3]) : *lt;
|
97
97
|
*rb = argc >= 5 ? to<coord>(argv[4]) : *lt;
|
98
98
|
}
|
99
|
-
else if (argv[0].
|
99
|
+
else if (argv[0].is_a(Rays::point_class()))
|
100
100
|
{
|
101
101
|
if (argc < 2)
|
102
102
|
argument_error(__FILE__, __LINE__);
|
@@ -154,7 +154,7 @@ void get_ellipse_args (
|
|
154
154
|
{
|
155
155
|
*x = *y = *w = *h = 0;
|
156
156
|
}
|
157
|
-
else if (argv[0].
|
157
|
+
else if (argv[0].is_a(Rays::bounds_class()))
|
158
158
|
{
|
159
159
|
const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
160
160
|
*x = b.x;
|
@@ -162,7 +162,7 @@ void get_ellipse_args (
|
|
162
162
|
*w = b.w;
|
163
163
|
*h = b.h;
|
164
164
|
}
|
165
|
-
else if (argv[0].
|
165
|
+
else if (argv[0].is_a(Rays::point_class()))
|
166
166
|
{
|
167
167
|
if (argc < 2)
|
168
168
|
argument_error(__FILE__, __LINE__);
|
data/.doc/ext/rays/image.cpp
CHANGED
@@ -21,31 +21,28 @@ VALUE alloc(VALUE klass)
|
|
21
21
|
}
|
22
22
|
|
23
23
|
static
|
24
|
-
VALUE initialize(VALUE self)
|
24
|
+
VALUE initialize(VALUE self, VALUE args, VALUE pixel_density, VALUE smooth)
|
25
25
|
{
|
26
26
|
RUCY_CHECK_OBJ(Rays::Image, self);
|
27
|
-
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3, 4);
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2);
|
28
|
+
size_t argc = args.size();
|
29
|
+
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3);
|
32
30
|
|
33
|
-
|
34
|
-
|
31
|
+
float pd = to<float>(pixel_density);
|
32
|
+
if (args[0].is_a(Rays::bitmap_class()))
|
33
|
+
{
|
34
|
+
const Rays::Bitmap* bmp = to<Rays::Bitmap*>(args[0]);
|
35
|
+
if (!bmp)
|
35
36
|
argument_error(__FILE__, __LINE__);
|
36
37
|
|
37
|
-
|
38
|
-
*THIS = Rays::Image(*bitmap, pixel_density);
|
38
|
+
*THIS = Rays::Image(*bmp, pd, smooth);
|
39
39
|
}
|
40
40
|
else
|
41
41
|
{
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
Rays::ColorSpace cs = (argc >= 3) ? to<Rays::ColorSpace>(argv[2]) : Rays::RGBA;
|
47
|
-
float pixel_density = (argc >= 4) ? to<float>(argv[3]) : 1;
|
48
|
-
*THIS = Rays::Image(width, height, cs, pixel_density);
|
42
|
+
int width = to<int>(args[0]);
|
43
|
+
int height = to<int>(args[1]);
|
44
|
+
auto cs = (argc >= 3) ? to<Rays::ColorSpace>(args[2]) : Rays::RGBA;
|
45
|
+
*THIS = Rays::Image(width, height, cs, pd, smooth);
|
49
46
|
}
|
50
47
|
|
51
48
|
return self;
|
@@ -110,6 +107,21 @@ VALUE get_bitmap(VALUE self, VALUE modify)
|
|
110
107
|
return value(THIS->bitmap(modify));
|
111
108
|
}
|
112
109
|
|
110
|
+
static
|
111
|
+
VALUE set_smooth(VALUE self, VALUE smooth)
|
112
|
+
{
|
113
|
+
CHECK;
|
114
|
+
THIS->set_smooth(smooth);
|
115
|
+
return smooth;
|
116
|
+
}
|
117
|
+
|
118
|
+
static
|
119
|
+
VALUE get_smooth(VALUE self)
|
120
|
+
{
|
121
|
+
CHECK;
|
122
|
+
return value(THIS->smooth());
|
123
|
+
}
|
124
|
+
|
113
125
|
static
|
114
126
|
VALUE load(VALUE self, VALUE path)
|
115
127
|
{
|
@@ -126,7 +138,7 @@ Init_rays_image ()
|
|
126
138
|
|
127
139
|
cImage = rb_define_class_under(mRays, "Image", rb_cObject);
|
128
140
|
rb_define_alloc_func(cImage, alloc);
|
129
|
-
|
141
|
+
cImage.define_private_method("initialize!", initialize);
|
130
142
|
rb_define_private_method(cImage, "initialize_copy", RUBY_METHOD_FUNC(initialize_copy), 1);
|
131
143
|
rb_define_method(cImage, "save", RUBY_METHOD_FUNC(save), 1);
|
132
144
|
rb_define_method(cImage, "width", RUBY_METHOD_FUNC(width), 0);
|
@@ -135,6 +147,8 @@ Init_rays_image ()
|
|
135
147
|
rb_define_method(cImage, "pixel_density", RUBY_METHOD_FUNC(pixel_density), 0);
|
136
148
|
rb_define_method(cImage, "painter", RUBY_METHOD_FUNC(painter), 0);
|
137
149
|
rb_define_private_method(cImage, "get_bitmap", RUBY_METHOD_FUNC(get_bitmap), 1);
|
150
|
+
rb_define_method(cImage, "smooth=", RUBY_METHOD_FUNC(set_smooth), 1);
|
151
|
+
rb_define_method(cImage, "smooth", RUBY_METHOD_FUNC(get_smooth), 0);
|
138
152
|
rb_define_module_function(cImage, "load", RUBY_METHOD_FUNC(load), 1);
|
139
153
|
}
|
140
154
|
|
data/.doc/ext/rays/matrix.cpp
CHANGED
@@ -127,10 +127,10 @@ VALUE mult(VALUE self, VALUE val)
|
|
127
127
|
{
|
128
128
|
CHECK;
|
129
129
|
|
130
|
-
if (val.
|
130
|
+
if (val.is_a(Rays::matrix_class()))
|
131
131
|
return value(*THIS * to<Rays::Matrix&>(val));
|
132
132
|
|
133
|
-
if (val.
|
133
|
+
if (val.is_a(Rays::point_class()))
|
134
134
|
return value(*THIS * to<Rays::Point&>(val));
|
135
135
|
|
136
136
|
if (val.is_array())
|
data/.doc/ext/rays/point.cpp
CHANGED
@@ -44,7 +44,7 @@ VALUE move_to(VALUE self)
|
|
44
44
|
CHECK;
|
45
45
|
check_arg_count(__FILE__, __LINE__, "Point#move_to", argc, 1, 2, 3);
|
46
46
|
|
47
|
-
if (argv[0].
|
47
|
+
if (argv[0].is_a(Rays::point_class()))
|
48
48
|
THIS->move_to(to<Rays::Point&>(argv[0]));
|
49
49
|
else
|
50
50
|
{
|
@@ -64,7 +64,7 @@ VALUE move_by(VALUE self)
|
|
64
64
|
CHECK;
|
65
65
|
check_arg_count(__FILE__, __LINE__, "Point#move_by", argc, 1, 2, 3);
|
66
66
|
|
67
|
-
if (argv[0].
|
67
|
+
if (argv[0].is_a(Rays::point_class()))
|
68
68
|
THIS->move_by(to<Rays::Point&>(argv[0]));
|
69
69
|
else
|
70
70
|
{
|
@@ -204,7 +204,9 @@ VALUE set_at(VALUE self, VALUE index, VALUE value)
|
|
204
204
|
CHECK;
|
205
205
|
|
206
206
|
int i = index.as_i();
|
207
|
-
if (i < 0
|
207
|
+
if (i < 0)
|
208
|
+
index_error(__FILE__, __LINE__);
|
209
|
+
if (i > 2)
|
208
210
|
index_error(__FILE__, __LINE__);
|
209
211
|
|
210
212
|
(*THIS)[i] = to<coord>(value);
|
@@ -217,7 +219,9 @@ VALUE get_at(VALUE self, VALUE index)
|
|
217
219
|
CHECK;
|
218
220
|
|
219
221
|
int i = index.as_i();
|
220
|
-
if (i < 0
|
222
|
+
if (i < 0)
|
223
|
+
index_error(__FILE__, __LINE__);
|
224
|
+
if (i > 2)
|
221
225
|
index_error(__FILE__, __LINE__);
|
222
226
|
|
223
227
|
return value((*THIS)[i]);
|
data/.doc/ext/rays/polygon.cpp
CHANGED
@@ -26,7 +26,7 @@ VALUE setup(VALUE self, VALUE args, VALUE loop, VALUE colors, VALUE texcoords)
|
|
26
26
|
{
|
27
27
|
CHECK;
|
28
28
|
|
29
|
-
if (args[0].
|
29
|
+
if (args[0].is_a(Rays::polyline_class()))
|
30
30
|
*THIS = to<Rays::Polygon>(args.size(), args.as_array());
|
31
31
|
else
|
32
32
|
{
|
@@ -83,7 +83,9 @@ VALUE get_at(VALUE self, VALUE index)
|
|
83
83
|
int i = to<int>(index);
|
84
84
|
if (i < 0) i += size;
|
85
85
|
|
86
|
-
if (i < 0
|
86
|
+
if (i < 0)
|
87
|
+
index_error(__FILE__, __LINE__);
|
88
|
+
if (i >= size)
|
87
89
|
index_error(__FILE__, __LINE__);
|
88
90
|
|
89
91
|
return value((*THIS)[i]);
|
@@ -116,10 +118,10 @@ VALUE op_add(VALUE self, VALUE obj)
|
|
116
118
|
{
|
117
119
|
CHECK;
|
118
120
|
|
119
|
-
if (obj.
|
121
|
+
if (obj.is_a(Rays::polyline_class()))
|
120
122
|
return value(*THIS + to<Rays::Polyline&>(obj));
|
121
123
|
|
122
|
-
if (obj.
|
124
|
+
if (obj.is_a(Rays::polygon_class()))
|
123
125
|
return value(*THIS + to<Rays::Polygon&>(obj));
|
124
126
|
|
125
127
|
if (!obj.is_array())
|
@@ -131,7 +133,7 @@ VALUE op_add(VALUE self, VALUE obj)
|
|
131
133
|
for (const auto& polyline : to<Rays::Polygon&>(self))
|
132
134
|
polylines.emplace_back(polyline);
|
133
135
|
|
134
|
-
if (obj[0].
|
136
|
+
if (obj[0].is_a(Rays::polyline_class()))
|
135
137
|
{
|
136
138
|
each_poly<Rays::Polyline>(obj, [&](const auto& polyline)
|
137
139
|
{
|
@@ -382,7 +384,7 @@ namespace Rucy
|
|
382
384
|
{
|
383
385
|
if (argc <= 0)
|
384
386
|
return Rays::Polygon();
|
385
|
-
else if (argv->
|
387
|
+
else if (argv->is_a(Rays::polyline_class()))
|
386
388
|
{
|
387
389
|
if (argc == 1)
|
388
390
|
return Rays::Polygon(to<Rays::Polyline&>(*argv));
|
data/.doc/ext/rays/polyline.cpp
CHANGED
@@ -102,7 +102,9 @@ VALUE get_at(VALUE self, VALUE index)
|
|
102
102
|
int i = to<int>(index);
|
103
103
|
if (i < 0) i += size;
|
104
104
|
|
105
|
-
if (i < 0
|
105
|
+
if (i < 0)
|
106
|
+
index_error(__FILE__, __LINE__);
|
107
|
+
if (i >= size)
|
106
108
|
index_error(__FILE__, __LINE__);
|
107
109
|
|
108
110
|
return value((*THIS)[i]);
|
data/.doc/ext/rays/rays.cpp
CHANGED
@@ -126,7 +126,9 @@ namespace Rucy
|
|
126
126
|
}
|
127
127
|
|
128
128
|
int type = value_to<int>(*argv, convert);
|
129
|
-
if (type < 0
|
129
|
+
if (type < 0)
|
130
|
+
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
|
131
|
+
if (type >= Rays::CAP_MAX)
|
130
132
|
argument_error(__FILE__, __LINE__, "invalid cap type -- %d", type);
|
131
133
|
|
132
134
|
return (Rays::CapType) type;
|
@@ -157,7 +159,9 @@ namespace Rucy
|
|
157
159
|
}
|
158
160
|
|
159
161
|
int type = value_to<int>(*argv, convert);
|
160
|
-
if (type < 0
|
162
|
+
if (type < 0)
|
163
|
+
argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
|
164
|
+
if (type >= Rays::JOIN_MAX)
|
161
165
|
argument_error(__FILE__, __LINE__, "invalid join type -- %d", type);
|
162
166
|
|
163
167
|
return (Rays::JoinType) type;
|
@@ -188,7 +192,9 @@ namespace Rucy
|
|
188
192
|
}
|
189
193
|
|
190
194
|
int mode = value_to<int>(*argv, convert);
|
191
|
-
if (mode < 0
|
195
|
+
if (mode < 0)
|
196
|
+
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
197
|
+
if (mode >= Rays::BLEND_MAX)
|
192
198
|
argument_error(__FILE__, __LINE__, "invalid blend mode -- %d", mode);
|
193
199
|
|
194
200
|
return (Rays::BlendMode) mode;
|
@@ -219,7 +225,9 @@ namespace Rucy
|
|
219
225
|
}
|
220
226
|
|
221
227
|
int mode = value_to<int>(*argv, convert);
|
222
|
-
if (mode < 0
|
228
|
+
if (mode < 0)
|
229
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %d", mode);
|
230
|
+
if (mode >= Rays::TEXCOORD_MODE_MAX)
|
223
231
|
argument_error(__FILE__, __LINE__, "invalid texcoord mode -- %d", mode);
|
224
232
|
|
225
233
|
return (Rays::TexCoordMode) mode;
|
@@ -250,7 +258,9 @@ namespace Rucy
|
|
250
258
|
}
|
251
259
|
|
252
260
|
int wrap = value_to<int>(*argv, convert);
|
253
|
-
if (wrap < 0
|
261
|
+
if (wrap < 0)
|
262
|
+
argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %d", wrap);
|
263
|
+
if (wrap >= Rays::TEXCOORD_WRAP_MAX)
|
254
264
|
argument_error(__FILE__, __LINE__, "invalid texcoord wrap -- %d", wrap);
|
255
265
|
|
256
266
|
return (Rays::TexCoordWrap) wrap;
|
data/.doc/ext/rays/shader.cpp
CHANGED
@@ -139,7 +139,7 @@ VALUE set_uniform(VALUE self)
|
|
139
139
|
case 4: THIS->set_uniform(name, Af(0), Af(1), Af(2), Af(3)); break;
|
140
140
|
}
|
141
141
|
}
|
142
|
-
else if (argv[0].
|
142
|
+
else if (argv[0].is_a(Rays::image_class()))
|
143
143
|
THIS->set_uniform(name, to<Rays::Image&>(argv[0]));
|
144
144
|
else
|
145
145
|
argument_error(__FILE__, __LINE__);
|
data/ChangeLog.md
CHANGED
data/Gemfile.lock
CHANGED
data/LICENSE
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3
|
1
|
+
0.3.1
|
data/ext/rays/bounds.cpp
CHANGED
@@ -75,7 +75,7 @@ RUCY_DEFN(move_to)
|
|
75
75
|
CHECK;
|
76
76
|
check_arg_count(__FILE__, __LINE__, "Bounds#move_to", argc, 1, 2, 3);
|
77
77
|
|
78
|
-
if (argv[0].
|
78
|
+
if (argv[0].is_a(Rays::point_class()))
|
79
79
|
THIS->move_to(to<Rays::Point&>(argv[0]));
|
80
80
|
else
|
81
81
|
{
|
@@ -102,7 +102,7 @@ RUCY_DEFN(move_by)
|
|
102
102
|
CHECK;
|
103
103
|
check_arg_count(__FILE__, __LINE__, "Bounds#move_by", argc, 1, 2, 3);
|
104
104
|
|
105
|
-
if (argv[0].
|
105
|
+
if (argv[0].is_a(Rays::point_class()))
|
106
106
|
THIS->move_by(to<Rays::Point&>(argv[0]));
|
107
107
|
else
|
108
108
|
{
|
@@ -128,7 +128,7 @@ RUCY_DEFN(resize_to)
|
|
128
128
|
CHECK;
|
129
129
|
check_arg_count(__FILE__, __LINE__, "Bounds#resize_to", argc, 1, 2, 3);
|
130
130
|
|
131
|
-
if (argv[0].
|
131
|
+
if (argv[0].is_a(Rays::point_class()))
|
132
132
|
THIS->resize_to(to<Rays::Point&>(argv[0]));
|
133
133
|
else
|
134
134
|
{
|
@@ -155,7 +155,7 @@ RUCY_DEFN(resize_by)
|
|
155
155
|
CHECK;
|
156
156
|
check_arg_count(__FILE__, __LINE__, "Bounds#resize_by", argc, 1, 2, 3);
|
157
157
|
|
158
|
-
if (argv[0].
|
158
|
+
if (argv[0].is_a(Rays::point_class()))
|
159
159
|
THIS->resize_by(to<Rays::Point&>(argv[0]));
|
160
160
|
else
|
161
161
|
{
|
@@ -181,7 +181,7 @@ RUCY_DEFN(inset_by)
|
|
181
181
|
CHECK;
|
182
182
|
check_arg_count(__FILE__, __LINE__, "Bounds#inset_by", argc, 1, 2, 3);
|
183
183
|
|
184
|
-
if (argv[0].
|
184
|
+
if (argv[0].is_a(Rays::point_class()))
|
185
185
|
THIS->inset_by(to<Rays::Point&>(argv[0]));
|
186
186
|
else
|
187
187
|
{
|
@@ -501,7 +501,9 @@ RUCY_DEF2(set_at, index, value)
|
|
501
501
|
CHECK;
|
502
502
|
|
503
503
|
int i = index.as_i();
|
504
|
-
if (i < 0
|
504
|
+
if (i < 0)
|
505
|
+
index_error(__FILE__, __LINE__);
|
506
|
+
if (i > 1)
|
505
507
|
index_error(__FILE__, __LINE__);
|
506
508
|
|
507
509
|
(*THIS)[i] = to<Rays::Point&>(value);
|
@@ -515,7 +517,9 @@ RUCY_DEF1(get_at, index)
|
|
515
517
|
CHECK;
|
516
518
|
|
517
519
|
int i = index.as_i();
|
518
|
-
if (i < 0
|
520
|
+
if (i < 0)
|
521
|
+
index_error(__FILE__, __LINE__);
|
522
|
+
if (i > 1)
|
519
523
|
index_error(__FILE__, __LINE__);
|
520
524
|
|
521
525
|
return value((*THIS)[i]);
|
@@ -539,9 +543,9 @@ RUCY_DEF1(op_or, arg)
|
|
539
543
|
CHECK;
|
540
544
|
|
541
545
|
Rays::Bounds b = *THIS;
|
542
|
-
if (arg.
|
546
|
+
if (arg.is_a(Rays::bounds_class()))
|
543
547
|
b |= to<Rays::Bounds&>(arg);
|
544
|
-
else if (arg.
|
548
|
+
else if (arg.is_a(Rays::point_class()))
|
545
549
|
b |= to<Rays::Point&>(arg);
|
546
550
|
else
|
547
551
|
argument_error(__FILE__, __LINE__);
|
@@ -644,7 +648,7 @@ namespace Rucy
|
|
644
648
|
{
|
645
649
|
if (argc == 0)
|
646
650
|
return Rays::Bounds();
|
647
|
-
else if (argv->
|
651
|
+
else if (argv->is_a(Rays::point_class()))
|
648
652
|
{
|
649
653
|
switch (argc)
|
650
654
|
{
|
data/ext/rays/defs.cpp
CHANGED
@@ -84,7 +84,7 @@ void get_rect_args (
|
|
84
84
|
if (argc <= 0)
|
85
85
|
argument_error(__FILE__, __LINE__);
|
86
86
|
|
87
|
-
if (argv[0].
|
87
|
+
if (argv[0].is_a(Rays::bounds_class()))
|
88
88
|
{
|
89
89
|
Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
90
90
|
*x = b.x;
|
@@ -96,7 +96,7 @@ void get_rect_args (
|
|
96
96
|
*lb = argc >= 4 ? to<coord>(argv[3]) : *lt;
|
97
97
|
*rb = argc >= 5 ? to<coord>(argv[4]) : *lt;
|
98
98
|
}
|
99
|
-
else if (argv[0].
|
99
|
+
else if (argv[0].is_a(Rays::point_class()))
|
100
100
|
{
|
101
101
|
if (argc < 2)
|
102
102
|
argument_error(__FILE__, __LINE__);
|
@@ -154,7 +154,7 @@ void get_ellipse_args (
|
|
154
154
|
{
|
155
155
|
*x = *y = *w = *h = 0;
|
156
156
|
}
|
157
|
-
else if (argv[0].
|
157
|
+
else if (argv[0].is_a(Rays::bounds_class()))
|
158
158
|
{
|
159
159
|
const Rays::Bounds& b = to<Rays::Bounds&>(argv[0]);
|
160
160
|
*x = b.x;
|
@@ -162,7 +162,7 @@ void get_ellipse_args (
|
|
162
162
|
*w = b.w;
|
163
163
|
*h = b.h;
|
164
164
|
}
|
165
|
-
else if (argv[0].
|
165
|
+
else if (argv[0].is_a(Rays::point_class()))
|
166
166
|
{
|
167
167
|
if (argc < 2)
|
168
168
|
argument_error(__FILE__, __LINE__);
|
data/ext/rays/image.cpp
CHANGED
@@ -22,31 +22,28 @@ RUCY_DEF_ALLOC(alloc, klass)
|
|
22
22
|
RUCY_END
|
23
23
|
|
24
24
|
static
|
25
|
-
|
25
|
+
RUCY_DEF3(initialize, args, pixel_density, smooth)
|
26
26
|
{
|
27
27
|
RUCY_CHECK_OBJ(Rays::Image, self);
|
28
|
-
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3, 4);
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2);
|
29
|
+
size_t argc = args.size();
|
30
|
+
check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 1, 2, 3);
|
33
31
|
|
34
|
-
|
35
|
-
|
32
|
+
float pd = to<float>(pixel_density);
|
33
|
+
if (args[0].is_a(Rays::bitmap_class()))
|
34
|
+
{
|
35
|
+
const Rays::Bitmap* bmp = to<Rays::Bitmap*>(args[0]);
|
36
|
+
if (!bmp)
|
36
37
|
argument_error(__FILE__, __LINE__);
|
37
38
|
|
38
|
-
|
39
|
-
*THIS = Rays::Image(*bitmap, pixel_density);
|
39
|
+
*THIS = Rays::Image(*bmp, pd, smooth);
|
40
40
|
}
|
41
41
|
else
|
42
42
|
{
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
Rays::ColorSpace cs = (argc >= 3) ? to<Rays::ColorSpace>(argv[2]) : Rays::RGBA;
|
48
|
-
float pixel_density = (argc >= 4) ? to<float>(argv[3]) : 1;
|
49
|
-
*THIS = Rays::Image(width, height, cs, pixel_density);
|
43
|
+
int width = to<int>(args[0]);
|
44
|
+
int height = to<int>(args[1]);
|
45
|
+
auto cs = (argc >= 3) ? to<Rays::ColorSpace>(args[2]) : Rays::RGBA;
|
46
|
+
*THIS = Rays::Image(width, height, cs, pd, smooth);
|
50
47
|
}
|
51
48
|
|
52
49
|
return self;
|
@@ -120,6 +117,23 @@ RUCY_DEF1(get_bitmap, modify)
|
|
120
117
|
}
|
121
118
|
RUCY_END
|
122
119
|
|
120
|
+
static
|
121
|
+
RUCY_DEF1(set_smooth, smooth)
|
122
|
+
{
|
123
|
+
CHECK;
|
124
|
+
THIS->set_smooth(smooth);
|
125
|
+
return smooth;
|
126
|
+
}
|
127
|
+
RUCY_END
|
128
|
+
|
129
|
+
static
|
130
|
+
RUCY_DEF0(get_smooth)
|
131
|
+
{
|
132
|
+
CHECK;
|
133
|
+
return value(THIS->smooth());
|
134
|
+
}
|
135
|
+
RUCY_END
|
136
|
+
|
123
137
|
static
|
124
138
|
RUCY_DEF1(load, path)
|
125
139
|
{
|
@@ -137,7 +151,7 @@ Init_rays_image ()
|
|
137
151
|
|
138
152
|
cImage = mRays.define_class("Image");
|
139
153
|
cImage.define_alloc_func(alloc);
|
140
|
-
cImage.define_private_method("initialize",
|
154
|
+
cImage.define_private_method("initialize!", initialize);
|
141
155
|
cImage.define_private_method("initialize_copy", initialize_copy);
|
142
156
|
cImage.define_method("save", save);
|
143
157
|
cImage.define_method("width", width);
|
@@ -146,6 +160,8 @@ Init_rays_image ()
|
|
146
160
|
cImage.define_method("pixel_density", pixel_density);
|
147
161
|
cImage.define_method("painter", painter);
|
148
162
|
cImage.define_private_method("get_bitmap", get_bitmap);
|
163
|
+
cImage.define_method("smooth=", set_smooth);
|
164
|
+
cImage.define_method("smooth", get_smooth);
|
149
165
|
cImage.define_module_function("load", load);
|
150
166
|
}
|
151
167
|
|
data/ext/rays/matrix.cpp
CHANGED
@@ -136,10 +136,10 @@ RUCY_DEF1(mult, val)
|
|
136
136
|
{
|
137
137
|
CHECK;
|
138
138
|
|
139
|
-
if (val.
|
139
|
+
if (val.is_a(Rays::matrix_class()))
|
140
140
|
return value(*THIS * to<Rays::Matrix&>(val));
|
141
141
|
|
142
|
-
if (val.
|
142
|
+
if (val.is_a(Rays::point_class()))
|
143
143
|
return value(*THIS * to<Rays::Point&>(val));
|
144
144
|
|
145
145
|
if (val.is_array())
|