jruby_art 2.2.2 → 2.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/bin/k9 +4 -3
  3. data/lib/gluegen-rt-natives-linux-amd64.jar +0 -0
  4. data/lib/gluegen-rt-natives-macosx-universal.jar +0 -0
  5. data/lib/gluegen-rt-natives-windows-amd64.jar +0 -0
  6. data/lib/gluegen-rt.jar +0 -0
  7. data/lib/jogl-all-natives-linux-amd64.jar +0 -0
  8. data/lib/jogl-all-natives-macosx-universal.jar +0 -0
  9. data/lib/jogl-all-natives-windows-amd64.jar +0 -0
  10. data/lib/jogl-all.jar +0 -0
  11. data/lib/jruby_art-2.4.3.jar +0 -0
  12. data/lib/jruby_art/app.rb +8 -7
  13. data/lib/jruby_art/config.rb +2 -0
  14. data/lib/jruby_art/creators/sketch_writer.rb +31 -13
  15. data/lib/jruby_art/default_config.rb +2 -0
  16. data/lib/jruby_art/helper_methods.rb +22 -22
  17. data/lib/jruby_art/helpers/aabb.rb +3 -0
  18. data/lib/jruby_art/helpers/numeric.rb +1 -0
  19. data/lib/jruby_art/installer.rb +10 -7
  20. data/lib/jruby_art/java_opts.rb +2 -0
  21. data/lib/jruby_art/jruby_complete.rb +2 -0
  22. data/lib/jruby_art/launcher.rb +8 -3
  23. data/lib/jruby_art/library.rb +67 -67
  24. data/lib/jruby_art/library_loader.rb +4 -1
  25. data/lib/jruby_art/native_folder.rb +16 -14
  26. data/lib/jruby_art/native_loader.rb +3 -0
  27. data/lib/jruby_art/processing_ide.rb +5 -1
  28. data/lib/jruby_art/runner.rb +12 -10
  29. data/lib/jruby_art/runners/base.rb +1 -0
  30. data/lib/jruby_art/runners/live.rb +10 -7
  31. data/lib/jruby_art/runners/run.rb +1 -0
  32. data/lib/jruby_art/runners/watch.rb +6 -4
  33. data/lib/jruby_art/version.rb +2 -1
  34. data/library/boids/boids.rb +19 -10
  35. data/library/chooser/chooser.rb +10 -9
  36. data/library/color_group/color_group.rb +2 -0
  37. data/library/control_panel/control_panel.rb +8 -5
  38. data/library/dxf/dxf.rb +2 -0
  39. data/library/library_proxy/library_proxy.rb +2 -0
  40. data/library/net/net.rb +2 -0
  41. data/library/slider/slider.rb +24 -23
  42. data/library/vector_utils/vector_utils.rb +5 -1
  43. data/library/video_event/video_event.rb +3 -0
  44. data/vendors/Rakefile +23 -17
  45. metadata +13 -13
  46. data/lib/jruby_art-2.2.2.jar +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e25d59a1fa21e3d739e0216f56a1f4ae478f754abfe1d5d3244c54eeecca5899
4
- data.tar.gz: 19d230b5ef2d9783903428d4d4a0ccad4dc1057cff71089a657057bfdd220f85
3
+ metadata.gz: cafc35006284d38ccaed17cef28be7d8021f2064379017e4e1b73317426cbc3d
4
+ data.tar.gz: 7b88b27b2600fc8936fb045b1dbe578b68f4e4a4e13500208a18b84c479ffc23
5
5
  SHA512:
6
- metadata.gz: 464399ff7d12d8440410cec971d8802a2f1ee6659152560bfd77e171671c6ecf2d78a829c2550d31055de90432b7485e7d790baec26fe804ed163742b0a93ed1
7
- data.tar.gz: 7e397c9136a757036c0234bf98801688000316a88120d3afac822a3cf7669d100621f0b143d47a31ddd3f0b3376aac8af31568fa9f2178a07e4261fc380ad37e
6
+ metadata.gz: fced963e69ada654ec3650c6fa9b2493ca0e0d39a39b01482492572cca90a95b17af425cd2521fda286a44bcbdec1c665b3469bfb7928bbafa5d10b102e096b3
7
+ data.tar.gz: 81c447cfdcfe22ab23da5ee95a3f04b7d70d69957e8a54b1f418b4d796978562a2e959088b47c4cb6f31eb9b0416412afe7617626c24cf42ae1fc311425ee756
data/bin/k9 CHANGED
@@ -1,10 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  file = __FILE__
4
- if test(?l, file)
5
- require "pathname"
5
+ if test('l', file)
6
+ require 'pathname'
6
7
  file = Pathname.new(file).realpath
7
8
  end
8
9
 
9
- require File.expand_path(File.dirname(file) + "/../lib/jruby_art")
10
+ require File.expand_path(File.dirname(file) + '/../lib/jruby_art')
10
11
  Processing::Runner.execute
Binary file
Binary file
Binary file
@@ -1,6 +1,8 @@
1
- require 'java'
1
+ # frozen_string_literal: true
2
+
3
+ require 'jruby'
2
4
  require_relative '../jruby_art'
3
- Dir["#{K9_ROOT}/lib/*.jar"].each do |jar|
5
+ Dir["#{K9_ROOT}/lib/*.jar"].sort.each do |jar|
4
6
  require jar
5
7
  end
6
8
  require_relative '../jruby_art/helper_methods'
@@ -10,7 +12,6 @@ require_relative '../jruby_art/config'
10
12
 
11
13
  # A wrapper module for the processing App
12
14
  module Processing
13
-
14
15
  # Include some core processing classes that we'd like to use:
15
16
  include_package 'processing.core'
16
17
  # Load vecmath, fastmath and mathtool modules
@@ -113,7 +114,7 @@ module Processing
113
114
  puts(exception.backtrace.map { |trace| "\t#{trace}" })
114
115
  close
115
116
  end
116
- @surface = self.get_surface
117
+ @surface = get_surface
117
118
  # NB: this is the processing runSketch() method as used by processing.py
118
119
  run_sketch
119
120
  end
@@ -123,7 +124,7 @@ module Processing
123
124
  @width ||= width
124
125
  @height ||= height
125
126
  @render_mode ||= mode
126
- import_opengl if /opengl/ =~ mode
127
+ import_opengl if /opengl/.match?(mode)
127
128
  super(*args)
128
129
  end
129
130
 
@@ -183,7 +184,7 @@ module Processing
183
184
  klass = Processing::App.sketch_class
184
185
  klass.constants.each do |name|
185
186
  const = klass.const_get name
186
- next if const.class != Class || const.to_s.match(/^Java::/)
187
+ next if const.class != Class || /^Java::/.match?(const.to_s)
187
188
 
188
189
  const.class_eval 'include Processing::Proxy', __FILE__, __LINE__
189
190
  end
@@ -214,7 +215,7 @@ module Processing
214
215
 
215
216
  def method_missing(name, *args)
216
217
  app = Processing.app
217
- return app.send(name, *args) if app && app.respond_to?(name)
218
+ return app.send(name, *args) if app&.respond_to?(name)
218
219
 
219
220
  super
220
221
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
  require_relative 'default_config'
3
5
  require_relative 'version'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: false
2
+
2
3
  # The SketchParameters class knows how to format, size, title & class name
3
4
  class SketchParameters
4
5
  attr_reader :name, :args
@@ -13,13 +14,19 @@ class SketchParameters
13
14
 
14
15
  def sketch_title
15
16
  human = name.split('_').collect(&:capitalize).join(' ')
16
- format("sketch_title '%s'", human)
17
+ format("sketch_title '%<title>s'", title: human)
17
18
  end
18
19
 
19
20
  def sketch_size
20
- mode = args.length == 3 ? format(', %s', args[2].upcase) : ''
21
+ mode = args.length == 3 ? format(', %<mode>s', mode: args[2].upcase) : ''
21
22
  return 'size 200, 200' if args.empty?
22
- format('size %d, %d%s', args[0].to_i, args[1].to_i, mode)
23
+
24
+ format(
25
+ 'size %<width>d, %<height>d%<mode>s',
26
+ width: args[0].to_i,
27
+ height: args[1].to_i,
28
+ mode: mode
29
+ )
23
30
  end
24
31
  end
25
32
 
@@ -29,7 +36,9 @@ class SketchWriter
29
36
 
30
37
  def initialize(path, args)
31
38
  @param = SketchParameters.new(name: path, args: args)
32
- @file = format('%s/%s.rb', File.dirname(path), path)
39
+ @file = format(
40
+ '%<dir>s/%<file>s.rb', dir: File.dirname(path), file: path
41
+ )
33
42
  end
34
43
 
35
44
  def write
@@ -45,7 +54,6 @@ class Sketch
45
54
 
46
55
  def initialize(param)
47
56
  @param = param
48
- self
49
57
  end
50
58
 
51
59
  BLANK ||= ''.freeze
@@ -59,18 +67,25 @@ class Sketch
59
67
  end
60
68
 
61
69
  def class_methods
62
- lines = [format('class %s < Processing::App', param.class_name)]
70
+ lines = [format('class %<name>s < Processing::App', name: param.class_name)]
63
71
  lines.concat methods(INDENT)
64
72
  lines << 'end'
65
73
  end
66
74
 
67
75
  private
68
76
 
77
+ def content(content, indent)
78
+ return BLANK if content.empty?
79
+
80
+ format(' %<indent>s%<content>s', indent: indent, content: content)
81
+ end
82
+
69
83
  def method_lines(name, content, indent)
70
- one = format('%sdef %s', indent, name)
71
- two = content.empty? ? BLANK : format(' %s%s', indent, content)
72
- three = format('%send', indent)
73
- return [one, two, three] if /draw/ =~ name
84
+ one = format('%<indent>sdef %<name>s', indent: indent, name: name)
85
+ two = content(content, indent)
86
+ three = format('%<indent>send', indent: indent)
87
+ return [one, two, three] if /draw/.match?(name)
88
+
74
89
  [one, two, three, BLANK]
75
90
  end
76
91
  end
@@ -99,7 +114,7 @@ end
99
114
  # A simple class wrapped sketch
100
115
  class ClassSketch < Sketch
101
116
  def code
102
- lines = ['# frozen_string_literal: false', BLANK]
117
+ lines = ['# frozen_string_literal: true', BLANK]
103
118
  lines.concat class_methods
104
119
  end
105
120
  end
@@ -108,7 +123,8 @@ end
108
123
  class EmacsSketch < Sketch
109
124
  def code
110
125
  lines = [
111
- '# frozen_string_literal: false',
126
+ '# frozen_string_literal: true',
127
+ BLANK,
112
128
  "require 'jruby_art'",
113
129
  "require 'jruby_art/app'",
114
130
  BLANK,
@@ -117,6 +133,8 @@ class EmacsSketch < Sketch
117
133
  ]
118
134
  lines.concat class_methods
119
135
  lines << BLANK
120
- lines << format('%s.new if Processing.app.nil?', param.class_name)
136
+ lines << format(
137
+ '%<name>s.new if Processing.app.nil?', name: param.class_name
138
+ )
121
139
  end
122
140
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # default configuration
2
4
  class Default
3
5
  def self.config
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: false
2
+
2
3
  # processing module wrapper
3
4
  require_relative '../jruby_art'
4
5
 
@@ -53,6 +54,7 @@ module Processing
53
54
 
54
55
  def color(*args)
55
56
  return super(*args) unless args.length == 1
57
+
56
58
  super(hex_color(args[0]))
57
59
  end
58
60
 
@@ -61,7 +63,7 @@ module Processing
61
63
  end
62
64
 
63
65
  def int_to_ruby_colors(p5color)
64
- warn "[DEPRECATION] `int_to_ruby_colors` is deprecated. Please use `p52ruby` instead."
66
+ warn '[DEPRECATION] `int_to_ruby_colors` is deprecated. Please use `p52ruby` instead.'
65
67
  p52ruby(p5color)
66
68
  end
67
69
 
@@ -72,11 +74,8 @@ module Processing
72
74
  # Overrides Processing convenience function thread, which takes a String
73
75
  # arg (for a function) to more rubylike version, takes a block...
74
76
  def thread(&block)
75
- if block_given?
76
- Thread.new(&block)
77
- else
78
- raise ArgumentError, 'thread must be called with a block', caller
79
- end
77
+ warn 'A Block is Needed' unless block_given?
78
+ Java::JavaLang::Thread.new(&block).start
80
79
  end
81
80
 
82
81
  # explicitly provide 'processing.org' min instance method
@@ -100,9 +99,9 @@ module Processing
100
99
  def dist(*args)
101
100
  case args.length
102
101
  when 4
103
- return dist2d(*args)
102
+ dist2d(*args)
104
103
  when 6
105
- return dist3d(*args)
104
+ dist3d(*args)
106
105
  else
107
106
  raise ArgumentError, 'takes 4 or 6 parameters'
108
107
  end
@@ -117,13 +116,13 @@ module Processing
117
116
  # Here's a convenient way to look for them.
118
117
  def find_method(method_name)
119
118
  reg = Regexp.new(method_name.to_s, true)
120
- methods.sort.select { |meth| reg.match(meth) }
119
+ methods.sort.select { |meth| reg.match?(meth) }
121
120
  end
122
121
 
123
122
  # Proxy over a list of Java declared fields that have the same name as
124
123
  # some methods. Add to this list as needed.
125
124
  def proxy_java_fields
126
- fields = %w(key frameRate mousePressed keyPressed)
125
+ fields = %w[key frameRate mousePressed keyPressed]
127
126
  methods = fields.map { |field| java_class.declared_field(field) }
128
127
  @declared_fields = Hash[fields.zip(methods)]
129
128
  end
@@ -169,6 +168,7 @@ module Processing
169
168
  # frame_rate needs to support reading and writing
170
169
  def frame_rate(fps = nil)
171
170
  return @declared_fields['frameRate'].value(java_self) unless fps
171
+
172
172
  super(fps)
173
173
  end
174
174
 
@@ -184,19 +184,17 @@ module Processing
184
184
 
185
185
  private
186
186
 
187
- FIXNUM_COL = -> (x) { x.is_a?(Integer) }
188
- STRING_COL = -> (x) { x.is_a?(String) }
189
- FLOAT_COL = -> (x) { x.is_a?(Float) }
190
187
  # parse single argument color int/double/String
191
- def hex_color(a)
192
- case a
193
- when FIXNUM_COL
194
- Java::Monkstone::ColorUtil.colorLong(a)
195
- when STRING_COL
196
- return Java::Monkstone::ColorUtil.colorString(a) if a =~ /#\h+/
197
- raise StandardError, 'Dodgy Hexstring'
198
- when FLOAT_COL
199
- Java::Monkstone::ColorUtil.colorDouble(a)
188
+ def hex_color(arg)
189
+ case arg
190
+ when Integer
191
+ Java::Monkstone::ColorUtil.colorLong(arg)
192
+ when String
193
+ raise StandardError, 'Dodgy Hexstring' unless /#\h{6}$/.match?(arg)
194
+
195
+ Java::Monkstone::ColorUtil.colorString(arg)
196
+ when Float
197
+ Java::Monkstone::ColorUtil.colorDouble(arg)
200
198
  else
201
199
  raise StandardError, 'Dodgy Color Conversion'
202
200
  end
@@ -206,6 +204,7 @@ module Processing
206
204
  dx = args[0] - args[2]
207
205
  dy = args[1] - args[3]
208
206
  return 0 if dx.abs < EPSILON && dy.abs < EPSILON
207
+
209
208
  Math.hypot(dx, dy)
210
209
  end
211
210
 
@@ -214,6 +213,7 @@ module Processing
214
213
  dy = args[1] - args[4]
215
214
  dz = args[2] - args[5]
216
215
  return 0 if dx.abs < EPSILON && dy.abs < EPSILON && dz.abs < EPSILON
216
+
217
217
  Math.sqrt(dx * dx + dy * dy + dz * dz)
218
218
  end
219
219
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Axis aligned bounding box class (AABB would clash with Toxicgem)
3
4
  class AaBb
4
5
  attr_reader :center, :extent
@@ -14,6 +15,7 @@ class AaBb
14
15
 
15
16
  def position(vec)
16
17
  return @center = vec unless block_given?
18
+
17
19
  @center = vec if yield
18
20
  end
19
21
 
@@ -24,6 +26,7 @@ class AaBb
24
26
  def contains?(vec)
25
27
  rad = extent * 0.5
26
28
  return false unless (center.x - rad.x..center.x + rad.x).cover? vec.x
29
+
27
30
  (center.y - rad.y..center.y + rad.y).cover? vec.y
28
31
  end
29
32
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  # Re-open Numeric so that we can do simple degree and radian conversions
3
4
  # conversion factors are 180 / Math::PI and Math::PI / 180
4
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'config'
2
4
  require_relative 'processing_ide'
3
5
 
@@ -8,13 +10,14 @@ class Installer
8
10
  end
9
11
 
10
12
  def install
11
- if processing_ide.installed?
12
- config = Config.new(
13
- 'processing_ide' => true,
14
- 'library_path' => processing_ide.sketchbook_path)
15
- else
16
- config = Config.new('processing_ide' => false)
17
- end
13
+ config = if processing_ide.installed?
14
+ Config.new(
15
+ 'processing_ide' => true,
16
+ 'library_path' => processing_ide.sketchbook_path
17
+ )
18
+ else
19
+ Config.new('processing_ide' => false)
20
+ end
18
21
  config.write_to_file
19
22
  end
20
23
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: false
2
+
2
3
  # class to parse java_args.txt or java_args in config.yml
3
4
  class JavaOpts
4
5
  attr_reader :opts
@@ -8,6 +9,7 @@ class JavaOpts
8
9
  @opts = []
9
10
  @opts += File.read(arg_file).split(/\s+/) if FileTest.exist?(arg_file)
10
11
  return unless opts.empty? && Processing::RP_CONFIG.fetch('java_args', false)
12
+
11
13
  @opts += Processing::RP_CONFIG['java_args'].split(/\s+/)
12
14
  end
13
15
  end
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  class JRubyComplete
3
4
  def self.complete
4
5
  rcomplete = File.join(K9_ROOT, 'lib/ruby/jruby-complete.jar')
5
6
  return [rcomplete] if FileTest.exist?(rcomplete)
7
+
6
8
  warn "#{rcomplete} does not exist\nTry running `k9 --install`"
7
9
  exit
8
10
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require_relative '../jruby_art/jruby_complete'
3
4
  require_relative '../jruby_art/java_opts'
4
5
  module Processing
@@ -32,10 +33,12 @@ end
32
33
 
33
34
  # Wrap creation of java command string as a class
34
35
  class JavaCommand
35
- MAIN = 'org.jruby.Main'.freeze
36
+ MAIN = 'org.jruby.Main'
36
37
  attr_reader :runner, :args, :filename, :opts, :complete
37
38
  def initialize(runner, args, filename)
38
- @runner, @args, @filename = runner, args, filename
39
+ @runner = runner
40
+ @args = args
41
+ @filename = filename
39
42
  @complete = JRubyComplete.complete
40
43
  @opts = JavaOpts.new.opts
41
44
  end
@@ -49,7 +52,9 @@ end
49
52
  class JRubyCommand
50
53
  attr_reader :runner, :args, :filename, :opts
51
54
  def initialize(runner, args, filename)
52
- @runner, @args, @filename = runner, args, filename
55
+ @runner = runner
56
+ @args = args
57
+ @filename = filename
53
58
  @opts = JRubyOpts.new.opts
54
59
  end
55
60