rays-video 0.2.0 → 0.3.0

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.
@@ -9,7 +9,7 @@ RUCY_DEFINE_VALUE_FROM_TO(RAYS_VIDEO_EXPORT, Rays::Video)
9
9
 
10
10
  #define THIS to<Rays::Video*>(self)
11
11
 
12
- #define CHECK RUCY_CHECK_OBJECT(Rays::Video, self)
12
+ #define CHECK RUCY_CHECK_OBJ(Rays::Video, self)
13
13
 
14
14
 
15
15
  static
@@ -22,7 +22,7 @@ RUCY_END
22
22
  static
23
23
  RUCY_DEF4(initialize, width, height, fps, pixel_density)
24
24
  {
25
- RUCY_CHECK_OBJ(Rays::Video, self);
25
+ RUCY_CHECK_PTR(Rays::Video, self);
26
26
 
27
27
  float fps_ = to<float>(fps);
28
28
  *THIS = Rays::Video(
@@ -36,35 +36,35 @@ RUCY_END
36
36
  static
37
37
  RUCY_DEF1(initialize_copy, obj)
38
38
  {
39
- RUCY_CHECK_OBJ(Rays::Video, self);
39
+ RUCY_CHECK_PTR(Rays::Video, self);
40
40
 
41
41
  *THIS = to<Rays::Video&>(obj).dup();
42
42
  }
43
43
  RUCY_END
44
44
 
45
45
  static
46
- RUCY_DEF2(insert, index, image)
46
+ RUCY_DEF0(play)
47
47
  {
48
48
  CHECK;
49
- THIS->insert(to<size_t>(index), to<const Rays::Image&>(image));
49
+ THIS->play();
50
50
  return self;
51
51
  }
52
52
  RUCY_END
53
53
 
54
54
  static
55
- RUCY_DEF1(append, image)
55
+ RUCY_DEF0(pause)
56
56
  {
57
57
  CHECK;
58
- THIS->append(to<const Rays::Image&>(image));
58
+ THIS->pause();
59
59
  return self;
60
60
  }
61
61
  RUCY_END
62
62
 
63
63
  static
64
- RUCY_DEF1(remove, index)
64
+ RUCY_DEF0(stop)
65
65
  {
66
66
  CHECK;
67
- THIS->remove(to<size_t>(index));
67
+ THIS->stop();
68
68
  return self;
69
69
  }
70
70
  RUCY_END
@@ -94,6 +94,14 @@ RUCY_DEF0(height)
94
94
  }
95
95
  RUCY_END
96
96
 
97
+ static
98
+ RUCY_DEF0(pixel_density)
99
+ {
100
+ CHECK;
101
+ return value(THIS->pixel_density());
102
+ }
103
+ RUCY_END
104
+
97
105
  static
98
106
  RUCY_DEF0(fps)
99
107
  {
@@ -103,114 +111,115 @@ RUCY_DEF0(fps)
103
111
  RUCY_END
104
112
 
105
113
  static
106
- RUCY_DEF0(pixel_density)
114
+ RUCY_DEF1(set_position, position)
107
115
  {
108
116
  CHECK;
109
- return value(THIS->pixel_density());
117
+ THIS->set_position(to<size_t>(position));
118
+ return position;
110
119
  }
111
120
  RUCY_END
112
121
 
113
122
  static
114
- RUCY_DEF0(size)
123
+ RUCY_DEF0(get_position)
115
124
  {
116
125
  CHECK;
117
- return value(THIS->size());
126
+ return value(THIS->position());
118
127
  }
119
128
  RUCY_END
120
129
 
121
130
  static
122
- RUCY_DEF0(empty)
131
+ RUCY_DEF1(set_time_scale, scale)
123
132
  {
124
133
  CHECK;
125
- return value(THIS->empty());
134
+ THIS->set_time_scale(to<float>(scale));
135
+ return scale;
126
136
  }
127
137
  RUCY_END
128
138
 
129
139
  static
130
- RUCY_DEF1(set_position, position)
140
+ RUCY_DEF0(get_time_scale)
131
141
  {
132
142
  CHECK;
133
- THIS->set_position(to<size_t>(position));
134
- return position;
143
+ return value(THIS->time_scale());
135
144
  }
136
145
  RUCY_END
137
146
 
138
147
  static
139
- RUCY_DEF0(get_position)
148
+ RUCY_DEF2(insert, index, image)
140
149
  {
141
150
  CHECK;
142
- return value(THIS->position());
151
+ THIS->insert(to<size_t>(index), to<const Rays::Image&>(image));
152
+ return self;
143
153
  }
144
154
  RUCY_END
145
155
 
146
156
  static
147
- RUCY_DEF0(each)
157
+ RUCY_DEF1(append, image)
148
158
  {
149
159
  CHECK;
150
- Value ret;
151
- for (auto it = THIS->begin(), end = THIS->end(); it != end; ++it)
152
- ret = yield(value(*it));
153
- return ret;
160
+ THIS->append(to<const Rays::Image&>(image));
161
+ return self;
154
162
  }
155
163
  RUCY_END
156
164
 
157
165
  static
158
- RUCY_DEF0(to_image)
166
+ RUCY_DEF1(remove, index)
159
167
  {
160
168
  CHECK;
161
- return value((Rays::Image) *THIS);
169
+ THIS->remove(to<size_t>(index));
170
+ return self;
162
171
  }
163
172
  RUCY_END
164
173
 
165
174
  static
166
- RUCY_DEF1(at, index)
175
+ RUCY_DEF2(set_at, index, image)
167
176
  {
168
177
  CHECK;
169
- return value((*THIS)[(size_t) to<int>(index)]);
178
+ THIS->set(to<size_t>(index), to<const Rays::Image&>(image));
179
+ return image;
170
180
  }
171
181
  RUCY_END
172
182
 
173
183
  static
174
- RUCY_DEF0(play)
184
+ RUCY_DEF1(get_at, index)
175
185
  {
176
186
  CHECK;
177
- THIS->play();
178
- return self;
187
+ return value(THIS->get(to<size_t>(index)));
179
188
  }
180
189
  RUCY_END
181
190
 
182
191
  static
183
- RUCY_DEF0(pause)
192
+ RUCY_DEF0(size)
184
193
  {
185
194
  CHECK;
186
- THIS->pause();
187
- return self;
195
+ return value(THIS->size());
188
196
  }
189
197
  RUCY_END
190
198
 
191
199
  static
192
- RUCY_DEF0(stop)
200
+ RUCY_DEF0(empty)
193
201
  {
194
202
  CHECK;
195
- THIS->stop();
196
- return self;
203
+ return value(THIS->empty());
197
204
  }
198
205
  RUCY_END
199
206
 
200
207
  static
201
- RUCY_DEF1(set_time_scale, scale)
208
+ RUCY_DEF0(each)
202
209
  {
203
210
  CHECK;
204
- THIS->set_time_scale(to<float>(scale));
205
- return scale;
211
+ Value ret;
212
+ for (auto it = THIS->begin(), end = THIS->end(); it != end; ++it)
213
+ ret = yield(value(*it));
214
+ return ret;
206
215
  }
207
216
  RUCY_END
208
217
 
209
218
  static
210
- RUCY_DEF0(get_time_scale)
219
+ RUCY_DEF0(to_image)
211
220
  {
212
221
  CHECK;
213
- return value(THIS->time_scale());
222
+ return value((Rays::Image) *THIS);
214
223
  }
215
224
  RUCY_END
216
225
 
@@ -224,10 +233,12 @@ RUCY_END
224
233
  static
225
234
  RUCY_DEF0(exts)
226
235
  {
227
- std::vector<Value> list;
228
- for (const auto& ext : Rays::get_video_exts())
229
- list.emplace_back(ext.c_str());
230
- return array(list.data(), list.size());
236
+ const auto& exts = Rays::get_video_exts();
237
+
238
+ Value list = array(NULL, exts.size());
239
+ for (const auto& ext : exts)
240
+ list.push(ext.c_str());
241
+ return list;
231
242
  }
232
243
  RUCY_END
233
244
 
@@ -243,26 +254,27 @@ Init_rays_video ()
243
254
  cVideo.define_alloc_func(alloc);
244
255
  cVideo.define_private_method("initialize!", initialize);
245
256
  cVideo.define_private_method("initialize_copy", initialize_copy);
246
- cVideo.define_method("insert!", insert);
247
- cVideo.define_method("append!", append);
248
- cVideo.define_method("remove!", remove);
249
- cVideo.define_method("save", save);
250
- cVideo.define_method("width", width);
251
- cVideo.define_method("height", height);
252
- cVideo.define_method("fps", fps);
253
- cVideo.define_method("pixel_density", pixel_density);
254
- cVideo.define_method("size", size);
255
- cVideo.define_method("empty?", empty);
256
- cVideo.define_method("position=", set_position);
257
- cVideo.define_method("position", get_position);
258
257
  cVideo.define_method("play", play);
259
258
  cVideo.define_method("pause", pause);
260
259
  cVideo.define_method("stop", stop);
260
+ cVideo.define_method("save", save);
261
+ cVideo.define_method("width", width);
262
+ cVideo.define_method("height", height);
263
+ cVideo.define_method("pixel_density", pixel_density);
264
+ cVideo.define_method("fps", fps);
265
+ cVideo.define_method("position=", set_position);
266
+ cVideo.define_method("position", get_position);
261
267
  cVideo.define_method("time_scale=", set_time_scale);
262
268
  cVideo.define_method("time_scale", get_time_scale);
269
+ cVideo.define_method("insert!", insert);
270
+ cVideo.define_method("append!", append);
271
+ cVideo.define_method("remove!", remove);
272
+ cVideo.define_method("[]=", set_at);
273
+ cVideo.define_method("[]", get_at);
274
+ cVideo.define_method("size", size);
275
+ cVideo.define_method("empty?", empty);
263
276
  cVideo.define_method("each!", each);
264
277
  cVideo.define_method("to_image", to_image);
265
- cVideo.define_method("[]", at);
266
278
  cVideo.define_module_function("load", load);
267
279
  cVideo.define_module_function("exts", exts);
268
280
  }
data/include/rays/video.h CHANGED
@@ -38,40 +38,44 @@ namespace Rays
38
38
 
39
39
  This dup () const;
40
40
 
41
- void insert (size_t index, const Image& image);
42
-
43
- void append (const Image& image);
44
-
45
- void remove (size_t index);
46
-
47
41
  void play ();
48
42
 
49
43
  void pause ();
50
44
 
51
45
  void stop ();
52
46
 
53
- void set_time_scale (float scale);
54
-
55
- float time_scale () const;
56
-
57
47
  void save (const char* path);
58
48
 
59
49
  coord width () const;
60
50
 
61
51
  coord height () const;
62
52
 
63
- float fps () const;
64
-
65
53
  float pixel_density () const;
66
54
 
67
- size_t size () const;
68
-
69
- bool empty () const;
55
+ float fps () const;
70
56
 
71
57
  void set_position (size_t index);
72
58
 
73
59
  size_t position () const;
74
60
 
61
+ void set_time_scale (float scale);
62
+
63
+ float time_scale () const;
64
+
65
+ void insert (size_t index, const Image& image);
66
+
67
+ void append (const Image& image);
68
+
69
+ void remove (size_t index);
70
+
71
+ void set (size_t index, const Image& image);
72
+
73
+ Image get (size_t index) const;
74
+
75
+ size_t size () const;
76
+
77
+ bool empty () const;
78
+
75
79
  const_iterator begin () const;
76
80
 
77
81
  const_iterator end () const;
data/lib/rays/video.rb CHANGED
@@ -22,8 +22,12 @@ module Rays
22
22
 
23
23
  def append(*images)
24
24
  images.each {|image| append! image}
25
+ self
25
26
  end
26
27
 
28
+ alias push append
29
+ alias << append
30
+
27
31
  def remove(index_or_range)
28
32
  case index_or_range
29
33
  when Range then raise NotImplementedError
data/rays-video.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
 
12
12
  ext = RaysVideo::Extension
13
13
  name = ext.name true
14
- rdocs = glob.call *%w[README .doc/ext/**/*.cpp]
14
+ rdocs = glob.call(*%w[README .doc/ext/**/*.cpp])
15
15
 
16
16
  s.name = name
17
17
  s.version = ext.version
@@ -25,10 +25,10 @@ Gem::Specification.new do |s|
25
25
  s.platform = Gem::Platform::RUBY
26
26
  s.required_ruby_version = '>= 3.0.0'
27
27
 
28
- s.add_dependency 'xot', '~> 0.4.0'
29
- s.add_dependency 'rucy', '~> 0.4.0'
30
- s.add_dependency 'beeps', '~> 0.4.0'
31
- s.add_dependency 'rays', '~> 0.4.0'
28
+ s.add_dependency 'xot', '~> 0.5.0'
29
+ s.add_dependency 'rucy', '~> 0.5.0'
30
+ s.add_dependency 'beeps', '~> 0.5.0'
31
+ s.add_dependency 'rays', '~> 0.5.0'
32
32
 
33
33
  s.files = `git ls-files`.split $/
34
34
  s.executables = s.files.grep(%r{^bin/}) {|f| File.basename f}