jruby_art 0.4.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd9cb0f962dc0a84b23505e358c06629c40f68e6
4
- data.tar.gz: fbe671a54abacc8ba092e8a0990a4001f2801eca
3
+ metadata.gz: c07e2583ae91828f56b50199830ca327fe9eadeb
4
+ data.tar.gz: 4afbc2e0d2437a6bcb5a30507a45797b309af3e6
5
5
  SHA512:
6
- metadata.gz: 461771d79505d0055e7327292df3c592aa33ad8d5d61a302fc55e09d51f5c40d8f032eb9d9179e47d6fc4c746a0db2fbd875254b4f595572c0f5a0fc9d404746
7
- data.tar.gz: 5e4ecc05a81f62637333b4b8a53c669b292c539e797c1012819f665851cd641c4111c701072b58c1873643fec1f4a0dc290461cc90063bf36659e1c645302dba
6
+ metadata.gz: 5153f072f9d863a5660b35f00eb6442d8fbc40a57e54a543f1fdbcc40dfca331157a5146312aa39292845645b171f8ad37bc81d95a66ef2fd80e5578fb268bb4
7
+ data.tar.gz: 29cb4e2832285999382f91874cae603090aca811f4546b66370e31d92372ec13c973820d300894a7c7a68ba57cf843d0f79a2af499ce81736a938d18f9cfbfde
@@ -1,4 +1,4 @@
1
- require 'psych'
1
+ require 'yaml'
2
2
 
3
3
  # The wrapper module
4
4
  module Processing
@@ -6,7 +6,7 @@ module Processing
6
6
  config_path = '~/.jruby_art/config.yml'
7
7
  begin
8
8
  CONFIG_FILE_PATH = File.expand_path(config_path)
9
- RP_CONFIG = (Psych.load_file(CONFIG_FILE_PATH))
9
+ RP_CONFIG = (YAML.load_file(CONFIG_FILE_PATH))
10
10
  rescue
11
11
  warn(format('WARN: you need to set PROCESSING_ROOT in %s', config_path))
12
12
  end
@@ -1,4 +1,6 @@
1
1
  # processing module wrapper
2
+ require_relative '../rpextras'
3
+
2
4
  module Processing
3
5
  # Provides some convenience methods
4
6
  module HelperMethods
@@ -32,17 +34,8 @@ module Processing
32
34
  end
33
35
 
34
36
  def color(*args)
35
- a = args[0]
36
- # convert to signed int
37
- if args.length == 1
38
- if a.is_a?(Fixnum) && a >= 2**31
39
- args = [a - 2**32]
40
- elsif a.is_a?(String) && a[0].eql?('#')
41
- h = a[1..-1].rjust(6, '0').prepend('ff')
42
- return color(h.hex)
43
- end
44
- end
45
- super(*args)
37
+ return super(*args) unless args.length == 1
38
+ super(hex_color(args[0]))
46
39
  end
47
40
 
48
41
  # Overrides Processing convenience function thread, which takes a String
@@ -134,7 +127,7 @@ module Processing
134
127
 
135
128
  # Uses PImage class method under hood
136
129
  def blend_color(c1, c2, mode)
137
- Java::ProcessingCore::PImage::blendColor(c1, c2, mode)
130
+ Java::ProcessingCore::PImage.blendColor(c1, c2, mode)
138
131
  end
139
132
 
140
133
  # There's just so many functions in Processing,
@@ -147,7 +140,7 @@ module Processing
147
140
  # Proxy over a list of Java declared fields that have the same name as
148
141
  # some methods. Add to this list as needed.
149
142
  def proxy_java_fields
150
- fields = %w(sketchPath key frameRate frame mousePressed keyPressed)
143
+ fields = %w(sketchPath key frameRate mousePressed keyPressed)
151
144
  methods = fields.map { |field| java_class.declared_field(field) }
152
145
  @declared_fields = Hash[fields.zip(methods)]
153
146
  end
@@ -213,6 +206,17 @@ module Processing
213
206
 
214
207
  private
215
208
 
209
+ # parse single argument color int/double/String
210
+ def hex_color(a)
211
+ if a.is_a?(Fixnum)
212
+ return Java::Monkstone::ColorUtil.colorLong(a)
213
+ elsif a.is_a?(String)
214
+ return Java::Monkstone::ColorUtil.colorString(a) if a =~ /#\h+/
215
+ raise StandardError, 'Dodgy Hexstring'
216
+ end
217
+ Java::Monkstone::ColorUtil.colorDouble(a)
218
+ end
219
+
216
220
  def dist2d(*args)
217
221
  dx = args[0] - args[2]
218
222
  dy = args[1] - args[3]
@@ -21,6 +21,7 @@ module Processing
21
21
  choice:-
22
22
  run: run sketch once
23
23
  watch: watch for changes on the file and relaunch it on the fly
24
+ live: run sketch and open a pry console bound to $app
24
25
  create [width height][mode][flag]: create a new sketch.
25
26
  setup: check setup, install jruby-complete, unpack samples
26
27
 
@@ -62,6 +63,7 @@ module Processing
62
63
  def execute!
63
64
  case @options.action
64
65
  when 'run' then run(@options.path, @options.args)
66
+ when 'live' then live(@options.path, @options.args)
65
67
  when 'watch' then watch(@options.path, @options.args)
66
68
  when 'create' then create(@options.path, @options.args)
67
69
  when 'setup' then setup(@options.path)
@@ -98,6 +100,12 @@ module Processing
98
100
  ensure_exists(sketch)
99
101
  spin_up('run.rb', sketch, args)
100
102
  end
103
+
104
+ # Just simply run a JRubyArt sketch.
105
+ def live(sketch, args)
106
+ ensure_exists(sketch)
107
+ spin_up('live.rb', sketch, args)
108
+ end
101
109
 
102
110
  # Run a sketch, keeping an eye on it's file, and reloading
103
111
  # whenever it changes.
@@ -0,0 +1,16 @@
1
+ # A pry shell for live coding.
2
+ # Will start with your sketch.
3
+ require_relative 'base'
4
+ Processing.load_and_run_sketch
5
+
6
+ class PryException < StandardError
7
+ end
8
+
9
+ MESSAGE = "You need to 'jruby -S gem install pry' for 'live' mode"
10
+
11
+ if Gem::Specification.find_all_by_name('pry').any?
12
+ require 'pry'
13
+ $app.pry
14
+ else
15
+ fail(PryException.new, MESSAGE)
16
+ end
@@ -1,10 +1,23 @@
1
1
  require_relative 'base'
2
+ require_relative '../config'
2
3
 
3
4
  module Processing
5
+ class WatchException < StandardError
6
+ end
7
+
4
8
  # A sketch loader, observer, and reloader, to tighten
5
9
  # the feedback between code and effect.
6
10
  class Watcher
7
11
  # Sic a new Processing::Watcher on the sketch
12
+ WATCH_MESSAGE ||= <<-EOS
13
+ Warning:
14
+ To protect you from running watch mode in a top level
15
+ directory with lots of nested ruby or GLSL files we
16
+ limit the number of files to watch to %d.
17
+ If you really want to watch %d files you should
18
+ increase MAX_WATCH in ~/.jruby_art/config.yml
19
+
20
+ EOS
8
21
  SLEEP_TIME = 0.2
9
22
  def initialize
10
23
  reload_files_to_watch
@@ -52,6 +65,11 @@ module Processing
52
65
 
53
66
  def reload_files_to_watch
54
67
  @files = Dir.glob(File.join(SKETCH_ROOT, '**/*.{rb,glsl}'))
68
+ count = @files.length
69
+ max_watch = RP_CONFIG.fetch('MAX_WATCH', 20)
70
+ return unless count > max_watch
71
+ warn format(WATCH_MESSAGE, max_watch, count)
72
+ abort
55
73
  end
56
74
  end
57
75
  end
@@ -1,3 +1,3 @@
1
1
  module JRubyArt
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.2'
3
3
  end
data/lib/rpextras.jar CHANGED
Binary file
data/vendors/Rakefile CHANGED
@@ -9,7 +9,7 @@ WARNING = <<-EOS
9
9
  EOS
10
10
 
11
11
  JRUBYC_VERSION = '9.0.0.0'
12
- EXAMPLES = '0.4'
12
+ EXAMPLES = '0.5'
13
13
  HOME_DIR = ENV['HOME']
14
14
  MAC_OR_LINUX = /linux|mac|darwin/ =~ RbConfig::CONFIG['host_os']
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby_art
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-07-25 00:00:00.000000000 Z
13
+ date: 2015-08-10 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement
@@ -70,9 +70,9 @@ dependencies:
70
70
  version: '5.3'
71
71
  description: |2
72
72
  JRubyArt is a ruby wrapper for the processing art framework.
73
- The current version supports processing-3.0a11, and uses jruby-9.0.0.0
73
+ The current version supports processing-3.0b2, and uses jruby-9.0.0.0
74
74
  as the glue between ruby and java. You can use both processing libraries and ruby
75
- gems in your sketches. Features create/run/watch modes. The "watch" mode,
75
+ gems in your sketches. Features create/run/watch/live modes. The "watch" mode,
76
76
  provides a nice REPL-ish way to work on your processing sketches. Includes:-
77
77
  A "Control Panel" library, so that you can easily create sliders, buttons,
78
78
  checkboxes and drop-down menus, and hook them into your sketch's instance
@@ -96,6 +96,7 @@ files:
96
96
  - lib/jruby_art/library_loader.rb
97
97
  - lib/jruby_art/runner.rb
98
98
  - lib/jruby_art/runners/base.rb
99
+ - lib/jruby_art/runners/live.rb
99
100
  - lib/jruby_art/runners/run.rb
100
101
  - lib/jruby_art/runners/watch.rb
101
102
  - lib/jruby_art/version.rb