rubysketch 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release-gem.yml +1 -1
- data/ChangeLog.md +10 -0
- data/RubySketch.podspec +101 -12
- data/VERSION +1 -1
- data/examples/hello.rb +1 -1
- data/lib/rubysketch/all.rb +3 -0
- data/lib/rubysketch/context.rb +4 -0
- data/lib/rubysketch/sound.rb +55 -0
- data/lib/rubysketch/sprite.rb +30 -3
- data/lib/rubysketch/window.rb +13 -0
- data/lib/rubysketch.rb +2 -2
- data/pod.rake +33 -0
- data/rubysketch.gemspec +6 -6
- data/src/RubySketch.h +22 -0
- data/src/RubySketch.mm +92 -0
- data/test/helper.rb +3 -2
- data/test/test_sound.rb +90 -0
- metadata +22 -17
- data/src/RubyProcessing.h +0 -11
- data/src/RubyProcessing.mm +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2aae68b50056538ec9f1de57091af05176af8b629331d40e16b640de83d4a610
|
4
|
+
data.tar.gz: 8929fd46a62eeb5457f386a72b255d3a6267fc1380bb29aabe9b093a722ecb34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe6b88ffc3d9ee14f6b9206df4b554d498cd6a4b5b13a21baf8a6b0cfcebec4888322d12f6cee09829cc7a1038ad9ad2854945d5bb4e8706337bbfa310c113ab
|
7
|
+
data.tar.gz: 56dac7438fb09ed3d8164e390e44dc785be289e6c4a4e5c3b9550fd5363c87f0a5a05f94806b6f68e691019e9297e2be6710435c5b0cafa35b2527ca1d7d1124
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
# rubysketch ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.5.3] - 2023-04-22
|
5
|
+
|
6
|
+
- Depends on Beeps
|
7
|
+
- Update RubySketch.podspec to include beeps, rays, reflex, and processing libs
|
8
|
+
- Add RubySketch.h and RubySketch.mm
|
9
|
+
- Add Sound class and loadSound()
|
10
|
+
- Add vx, vy accessors and will_contact? callback to Sprite class
|
11
|
+
- Add RubySketch::Window andd calls Beeps.process_streams!
|
12
|
+
|
13
|
+
|
4
14
|
## [v0.5.2] - 2023-03-02
|
5
15
|
|
6
16
|
- depend to processing-0.5.2 gem
|
data/RubySketch.podspec
CHANGED
@@ -14,16 +14,105 @@ Pod::Spec.new do |s|
|
|
14
14
|
s.osx.deployment_target = "10.10"
|
15
15
|
s.ios.deployment_target = "10.0"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
root = "${PODS_ROOT}/#{s.name}"
|
18
|
+
exts = File.read(File.expand_path 'Rakefile', __dir__)
|
19
|
+
.lines(chomp: true)
|
20
|
+
.map {|line| line[%r|require\s*['"](\w+)/extension['"]|, 1]}
|
21
|
+
.compact - [s.name.downcase]
|
22
|
+
|
23
|
+
incdirs = exts.map {|x| "#{root}/#{x}/include"}.concat %W[
|
24
|
+
#{root}/src
|
25
|
+
#{root}/beeps/vendor/stk/include
|
26
|
+
#{root}/rays/vendor/glm
|
27
|
+
#{root}/rays/vendor/clipper/cpp
|
28
|
+
#{root}/rays/vendor/poly2tri/poly2tri
|
29
|
+
#{root}/rays/vendor/splines-lib
|
30
|
+
#{root}/reflex/vendor/Box2D/Box2D
|
31
|
+
${PODS_ROOT}/CRuby/CRuby/include
|
32
|
+
]
|
33
|
+
|
34
|
+
s.prepare_command = 'rake -f pod.rake setup'
|
35
|
+
s.preserve_paths = exts + %w[src]
|
36
|
+
s.requires_arc = false
|
37
|
+
s.osx.compiler_flags = "-DOSX"
|
38
|
+
s.ios.compiler_flags = "-DIOS"
|
39
|
+
s.library = %w[c++]
|
40
|
+
s.xcconfig = {
|
41
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => 'c++20',
|
42
|
+
"HEADER_SEARCH_PATHS" => incdirs.join(' ')
|
43
|
+
}
|
44
|
+
|
45
|
+
#s.dependency = 'CRuby', git: 'https://github.com/xord/cruby'
|
46
|
+
|
47
|
+
s.source_files = "src/*.mm"
|
48
|
+
s.resource_bundles =
|
49
|
+
exts.each_with_object({'RubySketch' => %w[lib VERSION]}) do |ext, hash|
|
50
|
+
hash[ext.capitalize] = %W[#{ext}/lib VERSION]
|
51
|
+
end
|
52
|
+
|
53
|
+
s.subspec "Xot" do |spec|
|
54
|
+
spec.source_files = "xot/src/*.cpp"
|
55
|
+
end
|
56
|
+
|
57
|
+
s.subspec "Rucy" do |spec|
|
58
|
+
spec.source_files = "rucy/src/*.cpp"
|
59
|
+
|
60
|
+
spec.subspec "Ext" do |ext|
|
61
|
+
ext.source_files = "rucy/ext/rucy/*.cpp"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
s.subspec "Beeps" do |spec|
|
66
|
+
spec.source_files = "beeps/src/*.cpp"
|
67
|
+
spec.frameworks = %w[OpenAL]
|
68
|
+
|
69
|
+
spec.subspec "STK" do |sub|
|
70
|
+
sub.source_files = "beeps/vendor/stk/src/*.cpp"
|
71
|
+
sub.exclude_files = %W[Tcp Udp Socket Thread Mutex InetWv Rt].map {|s|
|
72
|
+
"beeps/vendor/stk/src/#{s}*.cpp"
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
spec.subspec "Ext" do |ext|
|
77
|
+
ext.source_files = "beeps/ext/beeps/*.cpp"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
s.subspec "Rays" do |spec|
|
82
|
+
spec .source_files = "rays/src/*.cpp"
|
83
|
+
spec.osx.source_files = "rays/src/osx/*.{cpp,mm}"
|
84
|
+
spec.ios.source_files = "rays/src/ios/*.{cpp,mm}"
|
85
|
+
spec.ios.frameworks = %w[GLKit MobileCoreServices AVFoundation]# ImageIO
|
86
|
+
|
87
|
+
spec.subspec "Clipper" do |sub|
|
88
|
+
sub.source_files = "rays/vendor/clipper/cpp/*.cpp"
|
89
|
+
end
|
90
|
+
|
91
|
+
spec.subspec "Poly2Tri" do |sub|
|
92
|
+
sub.source_files = "rays/vendor/poly2tri/poly2tri/**/*.cc"
|
93
|
+
end
|
94
|
+
|
95
|
+
spec.subspec "SplineLib" do |sub|
|
96
|
+
sub.source_files = "rays/vendor/splines-lib/Splines.cpp"
|
97
|
+
end
|
98
|
+
|
99
|
+
spec.subspec "Ext" do |ext|
|
100
|
+
ext.source_files = "rays/ext/rays/*.cpp"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
s.subspec "Reflex" do |spec|
|
105
|
+
spec .source_files = "reflex/src/*.cpp"
|
106
|
+
spec.osx.source_files = "reflex/src/osx/*.{cpp,mm}"
|
107
|
+
spec.ios.source_files = "reflex/src/ios/*.{cpp,mm}"
|
108
|
+
spec.ios.frameworks = %w[CoreMotion]
|
109
|
+
|
110
|
+
spec.subspec "Box2D" do |sub|
|
111
|
+
sub.source_files = "reflex/vendor/Box2D/Box2D/Box2D/**/*.cpp"
|
112
|
+
end
|
113
|
+
|
114
|
+
spec.subspec "Ext" do |ext|
|
115
|
+
ext.source_files = "reflex/ext/reflex/*.cpp"
|
116
|
+
end
|
117
|
+
end
|
29
118
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.3
|
data/examples/hello.rb
CHANGED
data/lib/rubysketch/all.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
require 'forwardable'
|
2
|
+
require 'beeps'
|
2
3
|
require 'processing/all'
|
3
4
|
|
4
5
|
require 'rubysketch/extension'
|
6
|
+
require 'rubysketch/window'
|
5
7
|
require 'rubysketch/helper'
|
6
8
|
|
7
9
|
require 'rubysketch/sprite'
|
10
|
+
require 'rubysketch/sound'
|
8
11
|
require 'rubysketch/graphics_context'
|
9
12
|
require 'rubysketch/context'
|
data/lib/rubysketch/context.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
module RubySketch
|
2
|
+
|
3
|
+
|
4
|
+
class Sound
|
5
|
+
|
6
|
+
# @private
|
7
|
+
def initialize(sound)
|
8
|
+
@sound = sound
|
9
|
+
end
|
10
|
+
|
11
|
+
def play()
|
12
|
+
old = @player
|
13
|
+
@player = @sound.play
|
14
|
+
old&.stop
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def pause()
|
19
|
+
return false unless @player
|
20
|
+
@player.pause
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
def stop()
|
25
|
+
return false unless @player
|
26
|
+
@player.stop
|
27
|
+
@player = nil
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def playing?()
|
32
|
+
@player ? @player.playing? : false
|
33
|
+
end
|
34
|
+
|
35
|
+
def paused?()
|
36
|
+
!playing? && !stopped?
|
37
|
+
end
|
38
|
+
|
39
|
+
def stopped?()
|
40
|
+
@player ? @player.stopped? : true
|
41
|
+
end
|
42
|
+
|
43
|
+
def save(path)
|
44
|
+
@sound.save path
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.load(path)
|
48
|
+
f = Beeps::FileIn.new path
|
49
|
+
self.new Beeps::Sound.new(f, f.seconds, nchannels: f.nchannels)
|
50
|
+
end
|
51
|
+
|
52
|
+
end# Sound
|
53
|
+
|
54
|
+
|
55
|
+
end# RubySketch
|
data/lib/rubysketch/sprite.rb
CHANGED
@@ -25,11 +25,15 @@ module RubySketch
|
|
25
25
|
:restitution, :restitution=
|
26
26
|
|
27
27
|
def update(&block)
|
28
|
-
@view__.
|
28
|
+
@view__.on_update = block
|
29
29
|
end
|
30
30
|
|
31
31
|
def contact(&block)
|
32
|
-
@view__.
|
32
|
+
@view__.on_contact = block
|
33
|
+
end
|
34
|
+
|
35
|
+
def contact?(&block)
|
36
|
+
@view__.will_contact = block
|
33
37
|
end
|
34
38
|
|
35
39
|
def position()
|
@@ -60,6 +64,24 @@ module RubySketch
|
|
60
64
|
@view__.velocity = vector.getInternal__
|
61
65
|
end
|
62
66
|
|
67
|
+
def vx()
|
68
|
+
@view__.velocity.x
|
69
|
+
end
|
70
|
+
|
71
|
+
def vx=(value)
|
72
|
+
@view__.velocity = @view__.velocity.tap {|v| v.x = value}
|
73
|
+
value
|
74
|
+
end
|
75
|
+
|
76
|
+
def vy()
|
77
|
+
@view__.velocity.y
|
78
|
+
end
|
79
|
+
|
80
|
+
def vy=(value)
|
81
|
+
@view__.velocity = @view__.velocity.tap {|v| v.y = value}
|
82
|
+
value
|
83
|
+
end
|
84
|
+
|
63
85
|
alias pos position
|
64
86
|
alias pos= position=
|
65
87
|
alias vel velocity
|
@@ -77,7 +99,7 @@ module RubySketch
|
|
77
99
|
end
|
78
100
|
|
79
101
|
class View < Reflex::View
|
80
|
-
attr_accessor :update, :contact
|
102
|
+
attr_accessor :update, :contact, :will_contact
|
81
103
|
attr_reader :sprite
|
82
104
|
|
83
105
|
def initialize(sprite, *a, **k, &b)
|
@@ -93,6 +115,11 @@ module RubySketch
|
|
93
115
|
v = e.view
|
94
116
|
@contact.call v.sprite, e.action if @contact && v.is_a?(View)
|
95
117
|
end
|
118
|
+
|
119
|
+
def will_contact?(v)
|
120
|
+
return true if !@will_contact || !v.is_a?(View)
|
121
|
+
@will_contact.call v.sprite
|
122
|
+
end
|
96
123
|
end
|
97
124
|
|
98
125
|
end# Sprite
|
data/lib/rubysketch.rb
CHANGED
@@ -2,7 +2,7 @@ require 'rubysketch/all'
|
|
2
2
|
|
3
3
|
|
4
4
|
module RubySketch
|
5
|
-
WINDOW =
|
5
|
+
WINDOW = RubySketch::Window.new {start}
|
6
6
|
CONTEXT = RubySketch::Context.new WINDOW
|
7
7
|
|
8
8
|
refine Object do
|
@@ -25,6 +25,6 @@ begin
|
|
25
25
|
w.__send__ :begin_draw
|
26
26
|
at_exit do
|
27
27
|
w.__send__ :end_draw
|
28
|
-
Processing::App.new {w.show}.start if c.
|
28
|
+
Processing::App.new {w.show}.start if c.hasUserBlocks__ && !$!
|
29
29
|
end
|
30
30
|
end
|
data/pod.rake
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
|
3
|
+
|
4
|
+
github = 'https://github.com/xord'
|
5
|
+
renames = {reflexion: 'reflex'}
|
6
|
+
regexp = /add\w+dependency.*['"](\w+)['"].*['"]\s*~>\s*([\d\.]+)\s*['"]/
|
7
|
+
repos = File.readlines('rubysketch.gemspec', chomp: true)
|
8
|
+
.map {|s| regexp.match(s)&.values_at 1, 2}
|
9
|
+
.compact
|
10
|
+
.to_h
|
11
|
+
.transform_keys {|name| renames[name.to_sym].then {|s| s || name}}
|
12
|
+
|
13
|
+
|
14
|
+
task :clobber do
|
15
|
+
sh %( rm -rf #{repos.keys.join ' '} )
|
16
|
+
end
|
17
|
+
|
18
|
+
task :setup
|
19
|
+
|
20
|
+
repos.each do |repo, ver|
|
21
|
+
rakefile = "#{repo}/Rakefile"
|
22
|
+
opts = {
|
23
|
+
depth: 1,
|
24
|
+
branch: (ENV['RUBYSKETCH_BRANCH'] || "v#{ver}")
|
25
|
+
}.map {|k, v| "--#{k} #{v}"}.join ' '
|
26
|
+
|
27
|
+
task :setup => rakefile
|
28
|
+
|
29
|
+
file rakefile do
|
30
|
+
sh %( git clone #{opts} #{github}/#{repo} )
|
31
|
+
sh %( cd #{repo} && VENDOR_NOCOMPILE=1 rake vendor erb )
|
32
|
+
end
|
33
|
+
end
|
data/rubysketch.gemspec
CHANGED
@@ -28,12 +28,12 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.platform = Gem::Platform::RUBY
|
29
29
|
s.required_ruby_version = '>= 2.7.0'
|
30
30
|
|
31
|
-
s.add_runtime_dependency 'xot', '~> 0.1.
|
32
|
-
s.add_runtime_dependency 'rucy', '~> 0.1.
|
33
|
-
s.add_runtime_dependency 'beeps', '~> 0.1.
|
34
|
-
s.add_runtime_dependency 'rays', '~> 0.1.
|
35
|
-
s.add_runtime_dependency 'reflexion', '~> 0.1.
|
36
|
-
s.add_runtime_dependency 'processing', '~> 0.5.
|
31
|
+
s.add_runtime_dependency 'xot', '~> 0.1.33'
|
32
|
+
s.add_runtime_dependency 'rucy', '~> 0.1.33'
|
33
|
+
s.add_runtime_dependency 'beeps', '~> 0.1.33'
|
34
|
+
s.add_runtime_dependency 'rays', '~> 0.1.33'
|
35
|
+
s.add_runtime_dependency 'reflexion', '~> 0.1.33'
|
36
|
+
s.add_runtime_dependency 'processing', '~> 0.5.3'
|
37
37
|
|
38
38
|
s.add_development_dependency 'rake'
|
39
39
|
s.add_development_dependency 'test-unit'
|
data/src/RubySketch.h
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
// -*- mode: objc -*-
|
2
|
+
#import <Foundation/Foundation.h>
|
3
|
+
#import <CRBValue.h>
|
4
|
+
|
5
|
+
|
6
|
+
@interface RubySketch : NSObject
|
7
|
+
|
8
|
+
typedef void (^RescueBlock) (CRBValue* exception);
|
9
|
+
|
10
|
+
+ (void) setup;
|
11
|
+
|
12
|
+
+ (BOOL) start;
|
13
|
+
+ (BOOL) startWithRescue: (RescueBlock) rescue;
|
14
|
+
|
15
|
+
+ (BOOL) start: (NSString*) path;
|
16
|
+
+ (BOOL) start: (NSString*) path rescue: (RescueBlock) rescue;
|
17
|
+
|
18
|
+
+ (void) setActiveReflexViewController: (id) reflexViewController;
|
19
|
+
|
20
|
+
+ (void) resetActiveReflexViewController;
|
21
|
+
|
22
|
+
@end
|
data/src/RubySketch.mm
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
// -*- mode: objc -*-
|
2
|
+
#import <CRuby.h>
|
3
|
+
#import "RubySketch.h"
|
4
|
+
#include "../reflex/src/ios/view_controller.h"
|
5
|
+
|
6
|
+
|
7
|
+
extern "C"
|
8
|
+
{
|
9
|
+
void Init_beeps_native ();
|
10
|
+
void Init_rays_native ();
|
11
|
+
void Init_reflex_native ();
|
12
|
+
}
|
13
|
+
|
14
|
+
|
15
|
+
static ReflexViewController* active_reflex_view_controller = nil;
|
16
|
+
|
17
|
+
static ReflexViewController*
|
18
|
+
ReflexViewController_create()
|
19
|
+
{
|
20
|
+
return active_reflex_view_controller;
|
21
|
+
}
|
22
|
+
|
23
|
+
static void
|
24
|
+
ReflexViewController_show (UIViewController*, ReflexViewController*)
|
25
|
+
{
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
@implementation RubySketch
|
30
|
+
|
31
|
+
+ (void) setup
|
32
|
+
{
|
33
|
+
static BOOL done = NO;
|
34
|
+
if (done) return;
|
35
|
+
done = YES;
|
36
|
+
|
37
|
+
[CRuby addExtension:@"beeps/native" init:^{Init_beeps_native();}];
|
38
|
+
[CRuby addExtension:@"rays/native" init:^{Init_rays_native();}];
|
39
|
+
[CRuby addExtension:@"reflex/native" init:^{Init_reflex_native();}];
|
40
|
+
|
41
|
+
for (NSString *ext in @[
|
42
|
+
@"Xot",
|
43
|
+
@"Rucy",
|
44
|
+
@"Beeps",
|
45
|
+
@"Rays",
|
46
|
+
@"Reflex",
|
47
|
+
@"Processing",
|
48
|
+
@"RubySketch"
|
49
|
+
]) [CRuby addLibrary:ext bundle:[NSBundle bundleForClass:RubySketch.class]];
|
50
|
+
|
51
|
+
ReflexViewController_set_create_fun(ReflexViewController_create);
|
52
|
+
ReflexViewController_set_show_fun(ReflexViewController_show);
|
53
|
+
}
|
54
|
+
|
55
|
+
+ (BOOL) start
|
56
|
+
{
|
57
|
+
return [self start:@"main.rb" rescue:nil];
|
58
|
+
}
|
59
|
+
|
60
|
+
+ (BOOL) startWithRescue: (RescueBlock) rescue
|
61
|
+
{
|
62
|
+
return [self start:@"main.rb" rescue:rescue];
|
63
|
+
}
|
64
|
+
|
65
|
+
+ (BOOL) start: (NSString*) path
|
66
|
+
{
|
67
|
+
return [self start:path rescue:nil];
|
68
|
+
}
|
69
|
+
|
70
|
+
+ (BOOL) start: (NSString*) path rescue: (RescueBlock) rescue
|
71
|
+
{
|
72
|
+
CRBValue* ret = [CRuby evaluate:[NSString stringWithFormat:@
|
73
|
+
"raise 'already started' unless require 'rubysketch'\n"
|
74
|
+
"load '%@'\n"
|
75
|
+
"RubySketch::WINDOW.__send__ :end_draw\n"
|
76
|
+
"RubySketch::WINDOW.show",
|
77
|
+
path
|
78
|
+
]];
|
79
|
+
return ret && ret.toBOOL;
|
80
|
+
}
|
81
|
+
|
82
|
+
+ (void) setActiveReflexViewController: (id) reflexViewController
|
83
|
+
{
|
84
|
+
active_reflex_view_controller = reflexViewController;
|
85
|
+
}
|
86
|
+
|
87
|
+
+ (void) resetActiveReflexViewController
|
88
|
+
{
|
89
|
+
active_reflex_view_controller = nil;
|
90
|
+
}
|
91
|
+
|
92
|
+
@end
|
data/test/helper.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
|
3
3
|
|
4
|
-
%w[../xot ../rucy ../rays ../reflex ../processing .]
|
4
|
+
%w[../xot ../rucy ../beeps ../rays ../reflex ../processing .]
|
5
5
|
.map {|s| File.expand_path "../#{s}/lib", __dir__}
|
6
6
|
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
7
7
|
|
8
|
-
require 'test/unit'
|
9
8
|
require 'xot/test'
|
10
9
|
require 'rubysketch/all'
|
11
10
|
|
11
|
+
require 'test/unit'
|
12
|
+
|
12
13
|
include Xot::Test
|
data/test/test_sound.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require_relative 'helper'
|
5
|
+
|
6
|
+
|
7
|
+
class TestSound < Test::Unit::TestCase
|
8
|
+
|
9
|
+
RS = RubySketch
|
10
|
+
B = Beeps
|
11
|
+
|
12
|
+
PATH = 'test.wav'
|
13
|
+
|
14
|
+
def sound()
|
15
|
+
RS::Sound.load PATH
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup()
|
19
|
+
B::Sound.new(B::Oscillator.new >> B::Gain.new(gain: 0), 0.1).save PATH
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown()
|
23
|
+
B::SoundPlayer.stop_all
|
24
|
+
File.delete PATH if File.exist?(PATH)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_play()
|
28
|
+
s = sound
|
29
|
+
assert_equal [false, false, true], [s.playing?, s.paused?, s.stopped?]
|
30
|
+
s.play
|
31
|
+
assert_equal [true, false, false], [s.playing?, s.paused?, s.stopped?]
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_pause()
|
35
|
+
s = sound
|
36
|
+
s.play
|
37
|
+
assert_equal [true, false, false], [s.playing?, s.paused?, s.stopped?]
|
38
|
+
s.pause
|
39
|
+
assert_equal [false, true, false], [s.playing?, s.paused?, s.stopped?]
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_stop()
|
43
|
+
s = sound
|
44
|
+
s.play
|
45
|
+
assert_equal [true, false, false], [s.playing?, s.paused?, s.stopped?]
|
46
|
+
s.stop
|
47
|
+
assert_equal [false, false, true], [s.playing?, s.paused?, s.stopped?]
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_play_end_then_stop()
|
51
|
+
s = sound
|
52
|
+
s.play
|
53
|
+
assert_equal [true, false, false], [s.playing?, s.paused?, s.stopped?]
|
54
|
+
sleep 0.2
|
55
|
+
assert_equal [false, false, true], [s.playing?, s.paused?, s.stopped?]
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_play_after_pause()
|
59
|
+
s = sound
|
60
|
+
s.play
|
61
|
+
s.pause
|
62
|
+
assert_equal [false, true, false], [s.playing?, s.paused?, s.stopped?]
|
63
|
+
s.play
|
64
|
+
assert_equal [true, false, false], [s.playing?, s.paused?, s.stopped?]
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_stop_after_pause()
|
68
|
+
s = sound
|
69
|
+
s.play
|
70
|
+
s.pause
|
71
|
+
assert_equal [false, true, false], [s.playing?, s.paused?, s.stopped?]
|
72
|
+
s.stop
|
73
|
+
assert_equal [false, false, true], [s.playing?, s.paused?, s.stopped?]
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_save()
|
77
|
+
s = sound
|
78
|
+
|
79
|
+
File.delete PATH
|
80
|
+
assert_false File.exist? PATH
|
81
|
+
|
82
|
+
s.save PATH
|
83
|
+
assert_true File.exist? PATH
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_load()
|
87
|
+
assert_nothing_raised {sound.play}
|
88
|
+
end
|
89
|
+
|
90
|
+
end# TestSound
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysketch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -16,84 +16,84 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1.
|
19
|
+
version: 0.1.33
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.
|
26
|
+
version: 0.1.33
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rucy
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.1.
|
33
|
+
version: 0.1.33
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.1.
|
40
|
+
version: 0.1.33
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: beeps
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
47
|
+
version: 0.1.33
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.
|
54
|
+
version: 0.1.33
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rays
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.
|
61
|
+
version: 0.1.33
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.
|
68
|
+
version: 0.1.33
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: reflexion
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.1.
|
75
|
+
version: 0.1.33
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.1.
|
82
|
+
version: 0.1.33
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: processing
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.5.
|
89
|
+
version: 0.5.3
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.5.
|
96
|
+
version: 0.5.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -162,11 +162,15 @@ files:
|
|
162
162
|
- lib/rubysketch/extension.rb
|
163
163
|
- lib/rubysketch/graphics_context.rb
|
164
164
|
- lib/rubysketch/helper.rb
|
165
|
+
- lib/rubysketch/sound.rb
|
165
166
|
- lib/rubysketch/sprite.rb
|
167
|
+
- lib/rubysketch/window.rb
|
168
|
+
- pod.rake
|
166
169
|
- rubysketch.gemspec
|
167
|
-
- src/
|
168
|
-
- src/
|
170
|
+
- src/RubySketch.h
|
171
|
+
- src/RubySketch.mm
|
169
172
|
- test/helper.rb
|
173
|
+
- test/test_sound.rb
|
170
174
|
- test/test_sprite.rb
|
171
175
|
homepage: https://github.com/xord/rubysketch
|
172
176
|
licenses: []
|
@@ -186,10 +190,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
190
|
- !ruby/object:Gem::Version
|
187
191
|
version: '0'
|
188
192
|
requirements: []
|
189
|
-
rubygems_version: 3.4.
|
193
|
+
rubygems_version: 3.4.10
|
190
194
|
signing_key:
|
191
195
|
specification_version: 4
|
192
196
|
summary: A game engine based on the Processing API.
|
193
197
|
test_files:
|
194
198
|
- test/helper.rb
|
199
|
+
- test/test_sound.rb
|
195
200
|
- test/test_sprite.rb
|
data/src/RubyProcessing.h
DELETED
data/src/RubyProcessing.mm
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
// -*- mode: objc -*-
|
2
|
-
#import <CRuby.h>
|
3
|
-
#import "RubyProcessing.h"
|
4
|
-
#import "RubySketch.h"
|
5
|
-
|
6
|
-
|
7
|
-
@implementation RubySketch
|
8
|
-
|
9
|
-
+ (void) setup
|
10
|
-
{
|
11
|
-
static BOOL done = NO;
|
12
|
-
if (done) return;
|
13
|
-
done = YES;
|
14
|
-
|
15
|
-
[RubyProcessing setup];
|
16
|
-
[CRuby addLibrary:@"RubySketch" bundle:[NSBundle bundleForClass:RubySketch.class]];
|
17
|
-
}
|
18
|
-
|
19
|
-
+ (void) start: (NSString*) path
|
20
|
-
{
|
21
|
-
[CRuby evaluate:@"raise 'already started' unless require 'rubysketch'\n"];
|
22
|
-
[RubyProcessing start: path];
|
23
|
-
}
|
24
|
-
|
25
|
-
@end
|