jruby_art 0.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.md +39 -0
  3. data/README.md +88 -0
  4. data/Rakefile +93 -0
  5. data/bin/k9 +10 -0
  6. data/lib/core.jar +0 -0
  7. data/lib/export.txt +10 -0
  8. data/lib/gluegen-rt-natives-linux-amd64.jar +0 -0
  9. data/lib/gluegen-rt-natives-linux-armv6hf.jar +0 -0
  10. data/lib/gluegen-rt-natives-linux-i586.jar +0 -0
  11. data/lib/gluegen-rt-natives-macosx-universal.jar +0 -0
  12. data/lib/gluegen-rt-natives-windows-amd64.jar +0 -0
  13. data/lib/gluegen-rt-natives-windows-i586.jar +0 -0
  14. data/lib/gluegen-rt.jar +0 -0
  15. data/lib/jogl-all-natives-linux-amd64.jar +0 -0
  16. data/lib/jogl-all-natives-linux-armv6hf.jar +0 -0
  17. data/lib/jogl-all-natives-linux-i586.jar +0 -0
  18. data/lib/jogl-all-natives-macosx-universal.jar +0 -0
  19. data/lib/jogl-all-natives-windows-amd64.jar +0 -0
  20. data/lib/jogl-all-natives-windows-i586.jar +0 -0
  21. data/lib/jogl-all.jar +0 -0
  22. data/lib/jruby_art.rb +27 -0
  23. data/lib/jruby_art/app.rb +153 -0
  24. data/lib/jruby_art/config.rb +18 -0
  25. data/lib/jruby_art/creator.rb +100 -0
  26. data/lib/jruby_art/helper_methods.rb +220 -0
  27. data/lib/jruby_art/helpers/camel_string.rb +18 -0
  28. data/lib/jruby_art/helpers/numeric.rb +9 -0
  29. data/lib/jruby_art/helpers/range.rb +11 -0
  30. data/lib/jruby_art/helpers/string_extra.rb +33 -0
  31. data/lib/jruby_art/parse.rb +60 -0
  32. data/lib/jruby_art/runner.rb +142 -0
  33. data/lib/jruby_art/version.rb +3 -0
  34. data/lib/jruby_art/writer.rb +40 -0
  35. data/lib/rpextras.jar +0 -0
  36. data/spec/app_spec.rb +208 -0
  37. data/spec/deglut_spec.rb +25 -0
  38. data/spec/spec_helper.rb +96 -0
  39. data/spec/vecmath_spec.rb +277 -0
  40. data/vendors/Rakefile +95 -0
  41. metadata +116 -0
@@ -0,0 +1,277 @@
1
+ require_relative '../lib/ribiprocessing'
2
+
3
+ Java::ProcessingVecmathVec2::Vec2Library.new.load(JRuby.runtime, false)
4
+
5
+ EPSILON = 1.0e-04
6
+
7
+ describe 'Vec2D#to_a' do
8
+ it 'should return x, y as an array' do
9
+ x, y = 1.0000001, 1.01
10
+ a = Vec2D.new(x, y)
11
+ expect(a.to_a).to eq([x, y])
12
+ end
13
+ end
14
+
15
+ describe 'Vec2D#copy' do
16
+ it 'should return a deep copy' do
17
+ x, y = 1.0000001, 1.01
18
+ a = Vec2D.new(x, y)
19
+ expect(a.copy.to_a).to eq([x, y])
20
+ end
21
+ end
22
+
23
+ describe 'Vec2D#copy' do
24
+ it 'should return a deep copy' do
25
+ x, y = 1.0000001, 1.01
26
+ a = Vec2D.new(x, y)
27
+ b = a.copy
28
+ b *= 0
29
+ expect(a.to_a).not_to eq(b.to_a)
30
+ end
31
+ end
32
+
33
+ describe 'Vec2D#==' do
34
+ it 'should return a == b' do
35
+ a = Vec2D.new(3, 5)
36
+ b = Vec2D.new(6, 7)
37
+ expect(a == b).to eq(false)
38
+ end
39
+ end
40
+
41
+ describe 'Vec2D#==' do
42
+ it 'should return a == b' do
43
+ a = Vec2D.new(3.0000000, 5.00000)
44
+ b = Vec2D.new(3.0000000, 5.000001)
45
+ expect(a == b).to eq(true)
46
+ end
47
+ end
48
+
49
+ describe 'Vec2D#+' do
50
+ it 'should return Vec2D sum of a + b' do
51
+ a = Vec2D.new(3, 5)
52
+ b = Vec2D.new(6, 7)
53
+ expect(a + b).to eq Vec2D.new(9, 12)
54
+ end
55
+ end
56
+
57
+ describe 'Vec2D#-' do
58
+ it 'should return Vec2D sum of a - b' do
59
+ a = Vec2D.new(3, 5)
60
+ b = Vec2D.new(6, 7)
61
+ expect(a - b).to eq Vec2D.new(-3, -2)
62
+ end
63
+ end
64
+
65
+
66
+ describe 'Vec2D#*' do
67
+ it 'should return Vec2D sum of a * b' do
68
+ a = Vec2D.new(3, 5)
69
+ b = 2
70
+ expect(a * b).to eq Vec2D.new(6, 10)
71
+ end
72
+ end
73
+
74
+ describe 'Vec2D#from_angle' do
75
+ it 'should return Vec2D.from_angle' do
76
+ a = Vec2D.from_angle(Math::PI / 4.0)
77
+ expect(a).to eq Vec2D.new(Math.sqrt(0.5), Math.sqrt(0.5))
78
+ end
79
+ end
80
+
81
+ describe 'Vec2D#from_angle' do
82
+ it 'should return Vec2D.from_angle' do
83
+ a = Vec2D.from_angle(Math::PI * 0.75)
84
+ expect(a).to eq Vec2D.new(-1 * Math.sqrt(0.5), Math.sqrt(0.5))
85
+ end
86
+ end
87
+
88
+ describe 'Vec2D2#x=' do
89
+ it 'should set x to supplied value' do
90
+ a = Vec2D.new(3, 5)
91
+ a.x=23
92
+ expect(a.x).to eq 23.0
93
+ end
94
+ end
95
+
96
+ describe 'Vec2D mag' do
97
+ it 'should return Vec2D mag' do
98
+ a = Vec2D.new(-3, -4)
99
+ expect(a.mag).to eq 5
100
+ end
101
+ end
102
+
103
+ describe 'Vec2D mag' do
104
+ it 'should return Vec2D mag' do
105
+ a = Vec2D.new(3.0, 2)
106
+ expect(a.mag).to be_within(EPSILON).of(Math.sqrt(3.0**2 + 2**2))
107
+ end
108
+ end
109
+
110
+ describe 'Vec2D mag' do
111
+ it 'should return Vec2D dist' do
112
+ a = Vec2D.new(3, 4)
113
+ expect(a.mag).to eq(5)
114
+ end
115
+ end
116
+
117
+ describe 'Vec2D mag' do
118
+ it 'should return Vec2D dist' do
119
+ a = Vec2D.new(-1, 0)
120
+ expect(a.mag).to eq(1)
121
+ end
122
+ end
123
+
124
+
125
+ describe 'Vec2D lerp' do
126
+ it 'should return Vec2D lerp' do
127
+ a = Vec2D.new(1, 1)
128
+ b = Vec2D.new(3, 3)
129
+ expect(a.lerp(b, 0.5)).to eq Vec2D.new(2, 2)
130
+ end
131
+ end
132
+
133
+ describe 'Vec2D lerp' do
134
+ it 'should return Vec2D lerp' do
135
+ a = Vec2D.new(1, 1)
136
+ b = Vec2D.new(3, 3)
137
+ expect(a.lerp(b, 5)).to eq Vec2D.new(11, 11)
138
+ end
139
+ end
140
+
141
+ describe 'Vec2D lerp!' do
142
+ it 'should return Vec2D lerp!' do
143
+ a = Vec2D.new(1, 1)
144
+ b = Vec2D.new(3, 3)
145
+ a.lerp!(b, 0.5)
146
+ expect(a).to eq Vec2D.new(2, 2)
147
+ end
148
+ end
149
+
150
+ describe 'Vec2D lerp!' do
151
+ it 'should return Vec2D lerp!' do
152
+ a = Vec2D.new(1, 1)
153
+ b = Vec2D.new(3, 3)
154
+ a.lerp!(b, -0.5)
155
+ expect(a).to eq Vec2D.new(0, 0)
156
+ end
157
+ end
158
+
159
+ describe 'Vec2D#set_mag' do
160
+ it 'should return Vec2D#set_mag' do
161
+ a = Vec2D.new(1, 1)
162
+ expect(a.set_mag(Math.sqrt(32))).to eq Vec2D.new(4, 4)
163
+ end
164
+ end
165
+
166
+ describe 'Vec2D#set_mag_block_false' do
167
+ it 'should return Vec2D#set_mag' do
168
+ a = Vec2D.new(1, 1)
169
+ expect(a.set_mag(Math.sqrt(32)) { false }).to eq Vec2D.new(1, 1)
170
+ end
171
+ end
172
+
173
+ describe 'Vec2D#set_mag_block_true' do
174
+ it 'sho uld return Vec2D#set_mag' do
175
+ a = Vec2D.new(1, 1)
176
+ expect(a.set_mag(Math.sqrt(32)) { true }).to eq Vec2D.new(4, 4)
177
+ end
178
+ end
179
+
180
+ describe 'Vec2D dist' do
181
+ it 'should return a.dist(b)' do
182
+ a = Vec2D.new(3, 5)
183
+ b = Vec2D.new(6, 7)
184
+ expect(a.dist(b)).to eq Math.sqrt(3.0**2 + 2**2)
185
+ end
186
+ end
187
+
188
+
189
+ describe 'Vec2D dot' do
190
+ it 'should return Vec2D dist(a, b)' do
191
+ a = Vec2D.new(3, 5)
192
+ b = Vec2D.new(6, 7)
193
+ expect(a.dot(b)).to eq 53
194
+ end
195
+ end
196
+
197
+ describe 'Vec2D #/' do
198
+ it 'should return Vec2D sum of a * b' do
199
+ a = Vec2D.new(6, 10)
200
+ b = 2
201
+ expect(a / b).to eq Vec2D.new(3, 5)
202
+ end
203
+ end
204
+
205
+ describe 'Vec2D #+=' do
206
+ it 'should return Vec2D result of a += b' do
207
+ a = Vec2D.new(3, 5)
208
+ b = Vec2D.new(6, 7)
209
+ a += b
210
+ expect(a).to eq Vec2D.new(9, 12)
211
+ end
212
+ end
213
+
214
+ describe 'Vec2D#normalize' do
215
+ it 'should return Vec2D#normalize a new Vec2D with mag 1.0' do
216
+ a = Vec2D.new(3, 5)
217
+ b = a.normalize
218
+ expect(b.mag).to be_within(EPSILON).of(1.0)
219
+ end
220
+ end
221
+
222
+ describe 'Vec2D#normalize!' do
223
+ it 'should return Vec2D#normalize! Vec2D#mag == 1.0' do
224
+ a = Vec2D.new(3, 5)
225
+ a.normalize!
226
+ expect(a.mag).to be_within(EPSILON).of(1.0)
227
+ end
228
+ end
229
+
230
+ describe 'Vec2D#heading' do
231
+ it 'should return Vec2D#heading in radians' do
232
+ a = Vec2D.new(1, 1)
233
+ expect(a.heading).to be_within(EPSILON).of(Math::PI / 4.0)
234
+ end
235
+ end
236
+
237
+ describe 'Vec2D#inspect' do
238
+ it 'should return a String' do
239
+ a = Vec2D.new(3, 2.000000000000001)
240
+ expect(a.inspect).to eq 'Vec2D(x = 3.0000, y = 2.0000)'
241
+ end
242
+ end
243
+
244
+ describe 'Vec2D#to_a' do
245
+ it 'should return x, y as an array' do
246
+ x, y = 1.0000001, 1.01
247
+ a = Vec2D.new(x, y)
248
+ expect(a.to_a).to eq([x, y])
249
+ end
250
+ end
251
+
252
+ describe 'Vec2D#array.reduce' do
253
+ it 'should correctly sum objects of Vec2D' do
254
+ array = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)]
255
+ sum = array.reduce(Vec2D.new) { |c, d| c + d }
256
+ expect(sum).to eq(Vec2D.new(12, 6))
257
+ end
258
+ end
259
+
260
+ describe 'Vec2D#array.zip(Vec2D#array)' do
261
+ it 'should correctly zip arrays of Vec2D' do
262
+ one = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)]
263
+ two = [Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(1, 2)]
264
+ zipped = one.zip(two).flatten
265
+ puts zipped
266
+ expect(zipped).to eq([Vec2D.new(1, 2), Vec2D.new(1, 2), Vec2D.new(10, 2), Vec2D.new(10, 2), Vec2D.new(1, 2), Vec2D.new(1, 2)])
267
+ end
268
+ end
269
+
270
+ describe 'Vec2D#rotate rot' do
271
+ it 'should return a rotated vector with same mag' do
272
+ x, y = 20, 10
273
+ b = Vec2D.new(x, y)
274
+ a = b.rotate(Math::PI / 2)
275
+ expect(a).to eq(Vec2D.new(-10.0, 20.0))
276
+ end
277
+ end
@@ -0,0 +1,95 @@
1
+ require 'rake/clean'
2
+
3
+ WARNING = <<-EOS
4
+ WARNING: you may not have wget installed, you could just download
5
+ the correct version of jruby-complete and/or examples to the vendors
6
+ folder, and re-run k9 setup install instead of installing wget. Some
7
+ systems may also require 'sudo' access to install jruby-complete,
8
+ NB: this is untested....
9
+
10
+ EOS
11
+
12
+ JRUBYC_VERSION = '1.7.18'
13
+ EXAMPLES = '0.0.4'
14
+ HOME_DIR = ENV['HOME']
15
+ MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
16
+ CLOBBER.include("jruby-complete-#{JRUBYC_VERSION}.jar", "#{EXAMPLES}.tar.gz")
17
+
18
+ desc "download, and copy to ruby-processing"
19
+ task :default => [:download, :copy_ruby, :download_examples, :copy_examples]
20
+
21
+ desc "download JRuby upstream sources"
22
+ task :download => ["jruby-complete-#{JRUBYC_VERSION}.jar"]
23
+
24
+ file "jruby-complete-#{JRUBYC_VERSION}.jar" do
25
+ begin
26
+ sh "wget https://s3.amazonaws.com/jruby.org/downloads/#{JRUBYC_VERSION}/jruby-complete-#{JRUBYC_VERSION}.jar"
27
+ rescue
28
+ warn(WARNING)
29
+ end
30
+ check_sha1("jruby-complete-#{JRUBYC_VERSION}.jar", "a1be3e1790aace5c99614a87785454d875eb21c2")
31
+ end
32
+
33
+ directory "../lib/ruby"
34
+
35
+ desc "copy jruby-complete"
36
+ task :copy_ruby => ["../lib/ruby"] do
37
+ sh "cp -v jruby-complete-#{JRUBYC_VERSION}.jar ../lib/ruby/jruby-complete.jar"
38
+ end
39
+
40
+ desc 'download and copy examples to user home'
41
+ task :download_examples
42
+ file "#{EXAMPLES}" do
43
+ begin
44
+ if MAC_OR_LINUX.nil?
45
+ sh "wget https://github.com/ruby-processing/JRubyArt-examples/archive/#{EXAMPLES}.zip"
46
+ else
47
+ sh "wget https://github.com/ruby-processing/JRubyArt-examples/archive/#{EXAMPLES}.tar.gz"
48
+ end
49
+ rescue
50
+ warn(WARNING)
51
+ end
52
+ end
53
+
54
+ desc "download, and copy to JRubyArt"
55
+ task :unpack_samples => [:download_examples, :copy_examples]
56
+
57
+ desc 'download and copy examples to user home'
58
+ task :download_examples
59
+ file_name = (MAC_OR_LINUX.nil?) ? "#{EXAMPLES}.zip" : "#{EXAMPLES}.tar.gz"
60
+ file file_name do
61
+ begin
62
+ if MAC_OR_LINUX.nil?
63
+ sh "wget https://github.com/ruby-processing/JRubyArt-examples/archive/#{EXAMPLES}.zip"
64
+ else
65
+ sh "wget https://github.com/ruby-processing/JRubyArt-examples/archive/#{EXAMPLES}.tar.gz"
66
+ end
67
+ rescue
68
+ warn(WARNING)
69
+ end
70
+ end
71
+
72
+ desc "copy examples"
73
+ task :copy_examples => file_name do
74
+ if MAC_OR_LINUX.nil?
75
+ sh "unzip #{EXAMPLES},zip"
76
+ else
77
+ sh "tar xzvf #{EXAMPLES}.tar.gz"
78
+ end
79
+ sh "cp -r JRubyArt-examples-#{EXAMPLES} #{HOME_DIR}/examples"
80
+ sh "rm -r JRubyArt-examples-#{EXAMPLES}"
81
+ end
82
+
83
+
84
+ def check_sha1(filename, expected_hash)
85
+ require "digest/sha1"
86
+ sha1 = Digest::SHA1.new
87
+ File.open(filename, "r") do |f|
88
+ while buf = f.read(4096)
89
+ sha1.update(buf)
90
+ end
91
+ end
92
+ if sha1.hexdigest != expected_hash
93
+ raise "bad sha1 checksum for #{filename} (expected #{expected_hash} got #{sha1.hexdigest})"
94
+ end
95
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jruby_art
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0.pre
5
+ platform: ruby
6
+ authors:
7
+ - Martin Prout
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ~>
17
+ - !ruby/object:Gem::Version
18
+ version: '10.3'
19
+ name: rake
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '10.3'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
33
+ name: rake-compiler
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ description: A jruby wrapper for processing
42
+ email: martin_p@lineone.net
43
+ executables:
44
+ - k9
45
+ extensions: []
46
+ extra_rdoc_files:
47
+ - README.md
48
+ - LICENSE.md
49
+ files:
50
+ - LICENSE.md
51
+ - README.md
52
+ - Rakefile
53
+ - bin/k9
54
+ - lib/gluegen-rt.jar
55
+ - lib/rpextras.jar
56
+ - lib/gluegen-rt-natives-windows-i586.jar
57
+ - lib/gluegen-rt-natives-linux-armv6hf.jar
58
+ - lib/jogl-all.jar
59
+ - lib/jogl-all-natives-windows-i586.jar
60
+ - lib/jogl-all-natives-linux-armv6hf.jar
61
+ - lib/export.txt
62
+ - lib/jruby_art.rb
63
+ - lib/gluegen-rt-natives-linux-amd64.jar
64
+ - lib/gluegen-rt-natives-linux-i586.jar
65
+ - lib/gluegen-rt-natives-windows-amd64.jar
66
+ - lib/jogl-all-natives-linux-amd64.jar
67
+ - lib/jogl-all-natives-macosx-universal.jar
68
+ - lib/gluegen-rt-natives-macosx-universal.jar
69
+ - lib/jogl-all-natives-windows-amd64.jar
70
+ - lib/core.jar
71
+ - lib/jogl-all-natives-linux-i586.jar
72
+ - lib/jruby_art/creator.rb
73
+ - lib/jruby_art/writer.rb
74
+ - lib/jruby_art/config.rb
75
+ - lib/jruby_art/runner.rb
76
+ - lib/jruby_art/helper_methods.rb
77
+ - lib/jruby_art/app.rb
78
+ - lib/jruby_art/version.rb
79
+ - lib/jruby_art/parse.rb
80
+ - lib/jruby_art/helpers/string_extra.rb
81
+ - lib/jruby_art/helpers/camel_string.rb
82
+ - lib/jruby_art/helpers/numeric.rb
83
+ - lib/jruby_art/helpers/range.rb
84
+ - spec/vecmath_spec.rb
85
+ - spec/spec_helper.rb
86
+ - spec/app_spec.rb
87
+ - spec/deglut_spec.rb
88
+ - vendors/Rakefile
89
+ homepage: https://github.com/ruby-processing/JRubyArt
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>'
105
+ - !ruby/object:Gem::Version
106
+ version: 1.3.1
107
+ requirements:
108
+ - A decent graphics card
109
+ - java runtime >= 1.7+
110
+ - processing = 2.2.1+
111
+ rubyforge_project:
112
+ rubygems_version: 2.1.9
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Ruby processing development branch
116
+ test_files: []