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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9cb95796a8c672691ee51529359a2f4fbe5476dd7a3edf27d03ac79f40a045e3
4
- data.tar.gz: 3f28f201cffc7d1a021846791ba10ab637ef33aa70618a7fce00085a73438ac4
3
+ metadata.gz: 9afd571fda027a889bb3d2ba60886e08ee8de5b825690d28838d10e729e5097d
4
+ data.tar.gz: 2bd0652be52c0f2f135cad35abe6b1b7140e90185ef9ec725e673aec2563f041
5
5
  SHA512:
6
- metadata.gz: bae41d0c790c9b9e766f5c28849ce91de22be9a27434b1713103cf1a4f93c11b4b2f78c2f4ce6fe7132c44c9baea78c09bb7b6f578bffc87c2b0e706c27398b2
7
- data.tar.gz: 48b7ba9a9b3a8bacd70913b1caa6cf5aaea4eea4397eaea6408278999ccb848720e44f0f6b5c7b851cff7ee987407851a8dc463f8df6cfbefc58cf71e94d25cc
6
+ metadata.gz: 94278334d219aebbaa3bd11b51f87555b230e8cd296115ccc06476b76f4240c0d5c4d976949b7bd04ce4b11aa056b738e7c9e5247dec8d75d14d36d5c7e388a0
7
+ data.tar.gz: 9ffd24082a1f0f37d6fbbb5ce016395069de981ba3c1ff0538392de790029f7ed69d50b739fa6a0debe7b5461b8624704c46b5e36967342c22250f8c655bbf0e
@@ -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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::point_class()))
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 || 1 < i)
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 || 1 < i)
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.is_kind_of(Rays::bounds_class()))
502
+ if (arg.is_a(Rays::bounds_class()))
499
503
  b |= to<Rays::Bounds&>(arg);
500
- else if (arg.is_kind_of(Rays::point_class()))
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->is_kind_of(Rays::point_class()))
604
+ else if (argv->is_a(Rays::point_class()))
601
605
  {
602
606
  switch (argc)
603
607
  {
@@ -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].is_kind_of(Rays::bounds_class()))
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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::bounds_class()))
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].is_kind_of(Rays::point_class()))
165
+ else if (argv[0].is_a(Rays::point_class()))
166
166
  {
167
167
  if (argc < 2)
168
168
  argument_error(__FILE__, __LINE__);
@@ -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
- if (argv[0].is_kind_of(Rays::bitmap_class()))
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
- const Rays::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
34
- if (!bitmap)
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
- float pixel_density = (argc >= 2) ? to<float>(argv[1]) : 1;
38
- *THIS = Rays::Image(*bitmap, pixel_density);
38
+ *THIS = Rays::Image(*bmp, pd, smooth);
39
39
  }
40
40
  else
41
41
  {
42
- check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 2, 3, 4);
43
-
44
- int width = to<int>(argv[0]);
45
- int height = to<int>(argv[1]);
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
- rb_define_private_method(cImage, "initialize", RUBY_METHOD_FUNC(initialize), -1);
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
 
@@ -127,10 +127,10 @@ VALUE mult(VALUE self, VALUE val)
127
127
  {
128
128
  CHECK;
129
129
 
130
- if (val.is_kind_of(Rays::matrix_class()))
130
+ if (val.is_a(Rays::matrix_class()))
131
131
  return value(*THIS * to<Rays::Matrix&>(val));
132
132
 
133
- if (val.is_kind_of(Rays::point_class()))
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())
@@ -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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::point_class()))
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 || 2 < i)
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 || 2 < i)
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]);
@@ -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].is_kind_of(Rays::polyline_class()))
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 || size <= i)
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.is_kind_of(Rays::polyline_class()))
121
+ if (obj.is_a(Rays::polyline_class()))
120
122
  return value(*THIS + to<Rays::Polyline&>(obj));
121
123
 
122
- if (obj.is_kind_of(Rays::polygon_class()))
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].is_kind_of(Rays::polyline_class()))
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->is_kind_of(Rays::polyline_class()))
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));
@@ -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 || size <= i)
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]);
@@ -126,7 +126,9 @@ namespace Rucy
126
126
  }
127
127
 
128
128
  int type = value_to<int>(*argv, convert);
129
- if (type < 0 || Rays::CAP_MAX <= type)
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 || Rays::JOIN_MAX <= type)
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 || Rays::BLEND_MAX <= mode)
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 || Rays::TEXCOORD_MODE_MAX <= mode)
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 || Rays::TEXCOORD_WRAP_MAX <= wrap)
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;
@@ -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].is_kind_of(Rays::image_class()))
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
@@ -1,6 +1,12 @@
1
1
  # rays ChangeLog
2
2
 
3
3
 
4
+ ## [v0.3.1] - 2025-01-13
5
+
6
+ - Update LICENSE
7
+ - Add smooth flag for Image
8
+
9
+
4
10
  ## [v0.3] - 2024-07-06
5
11
 
6
12
  - Support Windows
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GEM
9
9
 
10
10
  PLATFORMS
11
11
  arm64-darwin-21
12
- arm64-darwin-22
12
+ arm64-darwin-23
13
13
 
14
14
  DEPENDENCIES
15
15
  rake
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 xord.org
3
+ Copyright (c) 2011 xord.org
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/Rakefile CHANGED
@@ -1,6 +1,5 @@
1
1
  # -*- mode: ruby -*-
2
2
 
3
-
4
3
  %w[../xot ../rucy .]
5
4
  .map {|s| File.expand_path "#{s}/lib", __dir__}
6
5
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::point_class()))
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 || 1 < i)
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 || 1 < i)
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.is_kind_of(Rays::bounds_class()))
546
+ if (arg.is_a(Rays::bounds_class()))
543
547
  b |= to<Rays::Bounds&>(arg);
544
- else if (arg.is_kind_of(Rays::point_class()))
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->is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::bounds_class()))
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].is_kind_of(Rays::point_class()))
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].is_kind_of(Rays::bounds_class()))
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].is_kind_of(Rays::point_class()))
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
- RUCY_DEFN(initialize)
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
- if (argv[0].is_kind_of(Rays::bitmap_class()))
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
- const Rays::Bitmap* bitmap = to<Rays::Bitmap*>(argv[0]);
35
- if (!bitmap)
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
- float pixel_density = (argc >= 2) ? to<float>(argv[1]) : 1;
39
- *THIS = Rays::Image(*bitmap, pixel_density);
39
+ *THIS = Rays::Image(*bmp, pd, smooth);
40
40
  }
41
41
  else
42
42
  {
43
- check_arg_count(__FILE__, __LINE__, "Image#initialize", argc, 2, 3, 4);
44
-
45
- int width = to<int>(argv[0]);
46
- int height = to<int>(argv[1]);
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", 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.is_kind_of(Rays::matrix_class()))
139
+ if (val.is_a(Rays::matrix_class()))
140
140
  return value(*THIS * to<Rays::Matrix&>(val));
141
141
 
142
- if (val.is_kind_of(Rays::point_class()))
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())