jruby_art 0.4.2 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c07e2583ae91828f56b50199830ca327fe9eadeb
4
- data.tar.gz: 4afbc2e0d2437a6bcb5a30507a45797b309af3e6
3
+ metadata.gz: e332b6721afc72be284cccd025b766e6be4e3708
4
+ data.tar.gz: 32c62377c9263fc52c0d67efcb88e831cd33a3b5
5
5
  SHA512:
6
- metadata.gz: 5153f072f9d863a5660b35f00eb6442d8fbc40a57e54a543f1fdbcc40dfca331157a5146312aa39292845645b171f8ad37bc81d95a66ef2fd80e5578fb268bb4
7
- data.tar.gz: 29cb4e2832285999382f91874cae603090aca811f4546b66370e31d92372ec13c973820d300894a7c7a68ba57cf843d0f79a2af499ce81736a938d18f9cfbfde
6
+ metadata.gz: b6933e91fc6f1d3dfc963ff792a0dc6b402b02e734c2d662127c890ef2478276b5c7a273321f05c3ed4654ba1d9fcc08484a33424c156cd17d8a82a3140d5b3f
7
+ data.tar.gz: f9d69826c96c98aef1f591abaff889dc76dd0e7dfa631ba208031a2a061878ce6f455eac14b79ceba33ea34613dccf7fa35122aa4bbf0adbdb7c541d76408c99
data/lib/jruby_art/app.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'java'
2
2
  require_relative '../rpextras'
3
3
  require_relative '../jruby_art/helper_methods'
4
+ require_relative '../jruby_art/helpers/aabb'
4
5
  require_relative '../jruby_art/helpers/string_extra'
5
6
  require_relative '../jruby_art/library_loader'
6
7
  require_relative '../jruby_art/config'
@@ -12,11 +13,12 @@ module Processing
12
13
  end
13
14
  # Include some core processing classes that we'd like to use:
14
15
  include_package 'processing.core'
15
- # Load vecmath and fastmath modules
16
+ # Load vecmath, fastmath and mathtool modules
16
17
  Java::MonkstoneArcball::ArcballLibrary.new.load(JRuby.runtime, false)
17
18
  Java::MonkstoneVecmathVec2::Vec2Library.new.load(JRuby.runtime, false)
18
19
  Java::MonkstoneVecmathVec3::Vec3Library.new.load(JRuby.runtime, false)
19
20
  Java::MonkstoneFastmath::DeglutLibrary.new.load(JRuby.runtime, false)
21
+ Java::Monkstone::MathToolLibrary.new.load(JRuby.runtime, false)
20
22
  AppRender ||= Java::MonkstoneVecmath::AppRender
21
23
  ShapeRender ||= Java::MonkstoneVecmath::ShapeRender
22
24
 
@@ -34,7 +36,7 @@ module Processing
34
36
  }
35
37
  # All sketches extend this class
36
38
  class App < PApplet
37
- include HelperMethods, Math
39
+ include HelperMethods, Math, MathTool
38
40
  # Alias some methods for familiarity for Shoes coders.
39
41
  # surface replaces :frame, but needs field_reader for access
40
42
  alias_method :oval, :ellipse
@@ -47,6 +47,30 @@ class %s < Processing::App
47
47
  end
48
48
  CODE
49
49
 
50
+ EMACS_BASIC = <<-CODE
51
+ require 'jruby_art'
52
+ require 'jruby_art/app'
53
+
54
+ Processing::App::SKETCH_PATH = __FILE__
55
+
56
+ class %s < Processing::App
57
+ def setup
58
+ sketch_title '%s'
59
+ end
60
+
61
+ def draw
62
+
63
+ end
64
+
65
+ def settings
66
+ size %s, %s
67
+ # smooth # here
68
+ end
69
+ end
70
+
71
+ %s.new unless defined? $app
72
+ CODE
73
+
50
74
  CLASS_MODE = <<-CODE
51
75
  class %s < Processing::App
52
76
  def setup
@@ -64,6 +88,30 @@ class %s < Processing::App
64
88
  end
65
89
  CODE
66
90
 
91
+ EMACS_MODE = <<-CODE
92
+ require 'jruby_art'
93
+ require 'jruby_art/app'
94
+
95
+ Processing::App::SKETCH_PATH = __FILE__
96
+
97
+ class %s < Processing::App
98
+ def setup
99
+ sketch_title '%s'
100
+ end
101
+
102
+ def draw
103
+
104
+ end
105
+
106
+ def settings
107
+ size %s, %s, %s
108
+ # smooth # here
109
+ end
110
+ end
111
+
112
+ %s.new unless defined? $app
113
+ CODE
114
+
67
115
  INNER = <<-CODE
68
116
  class %s
69
117
  include Processing::Proxy
@@ -168,6 +216,31 @@ module Processing
168
216
  writer.save(template)
169
217
  end
170
218
  end
219
+
220
+ # This class creates class wrapped sketches, with an optional render mode
221
+ class EmacsSketch < Creator
222
+ def emacs_template
223
+ format(EMACS_BASIC, @name, @title, @width, @height, @name)
224
+ end
225
+
226
+ def emacs_template_mode
227
+ format(EMACS_MODE, @name, @title, @width, @height, @mode, @name)
228
+ end
229
+ # Create a class wrapped sketch, given a path.
230
+ def create!(path, args)
231
+ return usage if /\?/ =~ path || /--help/ =~ path
232
+ main_file = File.basename(path, '.rb') # allow uneeded extension input
233
+ # Check to make sure that the main file doesn't exist already
234
+ already_exist(path)
235
+ @name = CamelString.new(main_file).camelize
236
+ writer = SketchWriter.new(main_file)
237
+ @title = StringExtra.new(main_file).titleize
238
+ @width, @height = args[0], args[1]
239
+ @mode = args[2].upcase unless args[2].nil?
240
+ template = @mode.nil? ? emacs_template : emacs_template_mode
241
+ writer.save(template)
242
+ end
243
+ end
171
244
 
172
245
  # This class creates a pseudo 'java inner class' of the sketch
173
246
  class Inner < Creator
@@ -16,6 +16,13 @@ module Processing
16
16
  buf.end_draw
17
17
  buf
18
18
  end
19
+
20
+ def kamera(
21
+ eye: Vec3D.new(width / 2.0, height / 2.0, (height / 2.0) / tan(PI * 30.0 / 180.0)),
22
+ center: Vec3D.new(width / 2.0, height / 2.0, 0),
23
+ up: Vec3D.new(0, 1.0, 0))
24
+ camera(eye.x, eye.y, eye.z, center.x, center.y, center.z, up.x, up.y, up.z)
25
+ end
19
26
 
20
27
  # A nice method to run a given block for a grid.
21
28
  # Lifted from action_coding/Nodebox.
@@ -48,52 +55,6 @@ module Processing
48
55
  end
49
56
  end
50
57
 
51
- # Explicitly provides 'processing.org' map instance method, in which
52
- # value is mapped from range 1, to range 2 (NB: values are not clamped to
53
- # range 1). It may be better to explicitly write your own interpolate
54
- # function
55
- # @param [float] value input
56
- # @param [range] start1, stop1
57
- # @param [range] start2, stop2
58
- # @return [float] mapped value
59
- def map(value, start1, stop1, start2, stop2)
60
- start2 + (stop2 - start2) * ((value - start1).to_f / (stop1 - start1))
61
- end
62
-
63
- # ruby alternative implementation of map using range parameters
64
- # (begin..end) and excluded end (begin...end) produce the same result
65
- def map1d(val, r_in, r_out)
66
- r_out.begin + (r_out.end - r_out.begin) *
67
- ((val - r_in.begin).to_f / (r_in.end - r_in.begin))
68
- end
69
-
70
- # Explicitly provides 'processing.org' map instance method, where
71
- # value is mapped from range 1 to range 2 where values are clamped to
72
- # range 2.
73
- # @param val input
74
- # @param [r_in] start1, stop1
75
- # @param [r_out] start2, stop2
76
- # @return mapped value
77
- def constrained_map(val, r_in, r_out)
78
- unless r_in.include? val
79
- return r_out.begin if (val < r_in.begin && r_in.begin < r_in.end) ||
80
- (val > r_in.begin && r_in.begin > r_in.end)
81
- return r_out.end
82
- end
83
- r_out.begin + (r_out.end - r_out.begin) *
84
- ((val - r_in.begin).to_f / (r_in.end - r_in.begin))
85
- end
86
-
87
- # explicitly provide 'processing.org' norm instance method
88
- def norm(value, start, stop)
89
- (value - start).to_f / (stop - start)
90
- end
91
-
92
- # explicitly provide 'processing.org' lerp instance method
93
- def lerp(start, stop, amt)
94
- start + (stop - start) * amt
95
- end
96
-
97
58
  # explicitly provide 'processing.org' min instance method
98
59
  # to return a float:- a, b and c need to be floats
99
60
 
@@ -210,9 +171,9 @@ module Processing
210
171
  def hex_color(a)
211
172
  if a.is_a?(Fixnum)
212
173
  return Java::Monkstone::ColorUtil.colorLong(a)
213
- elsif a.is_a?(String)
174
+ elsif a.is_a?(String)
214
175
  return Java::Monkstone::ColorUtil.colorString(a) if a =~ /#\h+/
215
- raise StandardError, 'Dodgy Hexstring'
176
+ fail StandardError, 'Dodgy Hexstring'
216
177
  end
217
178
  Java::Monkstone::ColorUtil.colorDouble(a)
218
179
  end
@@ -0,0 +1,28 @@
1
+ # Axis aligned bounding box
2
+ class AABB
3
+ attr_reader :center, :extent
4
+
5
+ def initialize(center:, extent:)
6
+ @center = center
7
+ @extent = extent
8
+ end
9
+
10
+ def self.from_min_max(min:, max:)
11
+ new(center: (min + max) * 0.5, extent: max - min)
12
+ end
13
+
14
+ def position(vec)
15
+ return @center = vec unless block_given?
16
+ @center = vec if yield
17
+ end
18
+
19
+ def scale(d)
20
+ @extent *= d
21
+ end
22
+
23
+ def contains?(vec)
24
+ rad = extent * 0.5
25
+ return false unless (center.x - rad.x..center.x + rad.x).cover? vec.x
26
+ (center.y - rad.y..center.y + rad.y).cover? vec.y
27
+ end
28
+ end
@@ -77,6 +77,7 @@ module Processing
77
77
  # Parse the command-line options. Keep it simple.
78
78
  def parse_options(args)
79
79
  @options = OpenStruct.new
80
+ @options.emacs = !args.delete('--emacs').nil?
80
81
  @options.wrap = !args.delete('--wrap').nil?
81
82
  @options.inner = !args.delete('--inner').nil?
82
83
  @options.jruby = !args.delete('--jruby').nil?
@@ -92,6 +93,7 @@ module Processing
92
93
  require_relative '../jruby_art/creators/creator'
93
94
  return Processing::Inner.new.create!(sketch, args) if @options.inner
94
95
  return Processing::ClassSketch.new.create!(sketch, args) if @options.wrap
96
+ return Processing::EmacsSketch.new.create!(sketch, args) if @options.emacs
95
97
  Processing::BasicSketch.new.create!(sketch, args)
96
98
  end
97
99
 
@@ -1,3 +1,3 @@
1
1
  module JRubyArt
2
- VERSION = '0.4.2'
2
+ VERSION = '0.5.0'
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.5'
12
+ EXAMPLES = '0.6'
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.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ashkenas
@@ -10,14 +10,14 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-08-10 00:00:00.000000000 Z
13
+ date: 2015-08-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.3'
20
+ version: '1.10'
21
21
  name: bundler
22
22
  prerelease: false
23
23
  type: :development
@@ -25,13 +25,13 @@ dependencies:
25
25
  requirements:
26
26
  - - "~>"
27
27
  - !ruby/object:Gem::Version
28
- version: '1.3'
28
+ version: '1.10'
29
29
  - !ruby/object:Gem::Dependency
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '10.3'
34
+ version: '10.4'
35
35
  name: rake
36
36
  prerelease: false
37
37
  type: :development
@@ -39,7 +39,7 @@ dependencies:
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '10.3'
42
+ version: '10.4'
43
43
  - !ruby/object:Gem::Dependency
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
@@ -59,7 +59,7 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '5.3'
62
+ version: '5.8'
63
63
  name: minitest
64
64
  prerelease: false
65
65
  type: :development
@@ -67,10 +67,24 @@ dependencies:
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '5.3'
70
+ version: '5.8'
71
+ - !ruby/object:Gem::Dependency
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '3.3'
77
+ name: rspec
78
+ prerelease: false
79
+ type: :development
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '3.3'
71
85
  description: |2
72
86
  JRubyArt is a ruby wrapper for the processing art framework.
73
- The current version supports processing-3.0b2, and uses jruby-9.0.0.0
87
+ The current version supports processing-3.0b4, and uses jruby-9.0.0.0
74
88
  as the glue between ruby and java. You can use both processing libraries and ruby
75
89
  gems in your sketches. Features create/run/watch/live modes. The "watch" mode,
76
90
  provides a nice REPL-ish way to work on your processing sketches. Includes:-
@@ -89,6 +103,7 @@ files:
89
103
  - lib/jruby_art/config.rb
90
104
  - lib/jruby_art/creators/creator.rb
91
105
  - lib/jruby_art/helper_methods.rb
106
+ - lib/jruby_art/helpers/aabb.rb
92
107
  - lib/jruby_art/helpers/camel_string.rb
93
108
  - lib/jruby_art/helpers/numeric.rb
94
109
  - lib/jruby_art/helpers/range.rb
@@ -128,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
143
  requirements:
129
144
  - A decent graphics card
130
145
  - java runtime >= 1.8+
131
- - processing = 3.0a11+
146
+ - processing = 3.0b4+
132
147
  rubyforge_project:
133
148
  rubygems_version: 2.4.8
134
149
  signing_key: