propane 0.6.0-java → 0.7.0-java

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: fc959038fd93430af113ed74e02ae78b8edcebc7
4
- data.tar.gz: e0bd4194934a2c0ae4c57220a0f253ab29b14b9a
3
+ metadata.gz: 6f7c8e44c6fbe975880869f4c5e8949c7292ab5b
4
+ data.tar.gz: 63dbc144992f49211386bcf673f24e3d72c9d9d4
5
5
  SHA512:
6
- metadata.gz: a3ced8d05e48c9064445279d75eaf36f7ae29fcbbb667f1a68e22276f65673972580e341d06991d3fa0833e2bef7a722e47bb6900e7dfcdb8c8129c30171c3e1
7
- data.tar.gz: 12b365acf34662ec7c526e86140ca684622fc47c8fba798b7658c7fcbc8f1df66013be766383f64cf5d3ac493777e16c9384226f7932777c81af7e434fe88063
6
+ metadata.gz: f8bc2eed2c1d79dae5a22c68af081955380070feb81ad96de689612d2d2f8037b6f613f5964268c523ffdc001890e98f17cb0a1b8897d4bbe53e727c9cce359e
7
+ data.tar.gz: 61c449de0ace22d8c04be925a6bb6354ccbe93a7b4f10f9fbb20b5e3d1a617e94a120959ab09fb7e870641a49633055c72b7411a410470d066e8bf8e25a652d5
@@ -3,6 +3,6 @@
3
3
  <extension>
4
4
  <groupId>io.takari.polyglot</groupId>
5
5
  <artifactId>polyglot-ruby</artifactId>
6
- <version>0.1.15</version>
6
+ <version>0.1.18</version>
7
7
  </extension>
8
8
  </extensions>
@@ -1,9 +1,17 @@
1
1
  language: ruby
2
+ sudo: false
3
+ addons:
4
+ apt:
5
+ packages:
6
+ -oracle-java8-installer
7
+
8
+ rvm:
9
+ - jruby-9.1.2.0
10
+ jdk:
11
+ - oraclejdk8
12
+ os:
13
+ - linux
2
14
 
3
- rvm:
4
- - jruby-19mode
5
- script:
6
- - bundle exec rake spec
7
15
  before_install:
8
16
  - "export DISPLAY=:99.0"
9
17
  - "sh -e /etc/init.d/xvfb start"
@@ -1,3 +1,4 @@
1
+ **v0.7.0** Update to JRuby-Complete-9.1.2.0.
1
2
 
2
3
  **v0.6.0** Includes a sketch creator utility 3D still only for linux64 and macosx, any Windows developers are welcome to extend to windows (should be easy), includes slider in sketch library, change to requiring jdk8. Update to JRuby-Complete-9.1.0.0, request updated arcball (to run samples).
3
4
 
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ def create_manifest
12
12
  end
13
13
  end
14
14
 
15
- task default: [:init, :compile, :install, :test]
15
+ task default: [:init, :compile, :install, :test, :gem]
16
16
 
17
17
  desc 'Create Manifest'
18
18
  task :init do
@@ -16,7 +16,7 @@ class Landscape < Propane::App
16
16
  no_stroke
17
17
  # The code of this shader shows how to integrate shaders from shadertoy
18
18
  # into Processing with minimal changes.
19
- @landscape = load_shader('landscape.glsl')
19
+ @landscape = load_shader(data_path('landscape.glsl'))
20
20
  landscape.set('resolution', width.to_f, height.to_f)
21
21
  end
22
22
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
1
  # Creating Colors (Homage to Albers).
4
2
  #
5
3
  require 'propane'
@@ -9,7 +7,7 @@ require 'propane'
9
7
  class CreatingColors < Propane::App
10
8
  attr_reader :redder, :yellower, :orangish
11
9
  def setup
12
- size 640, 360
10
+ size 640, 600
13
11
  # palette = web_to_color_array(['#CC6600', '#CC9900', '#993300'].to_java(:string))
14
12
  palette = web_to_color_array(['#CC6600', '#CC9900', '#993300'])
15
13
  # @redder = color 204, 102, 0
@@ -3,7 +3,6 @@ require 'propane'
3
3
  class Tree < Propane::App
4
4
  # http://processing.org/learning/topics/tree.html
5
5
  # by Joe Holt
6
-
7
6
  def setup
8
7
  size 200, 200
9
8
  color_mode RGB, 1
@@ -8,19 +8,20 @@
8
8
  require 'propane'
9
9
 
10
10
  class VectorMath < Propane::App
11
-
11
+ attr_reader :center
12
12
  def setup
13
13
  size(640, 360)
14
14
  stroke(255)
15
15
  stroke_weight(4)
16
+ # A vector that points to the center of the window
17
+ @center = Vec2D.new(width/2, height/2)
18
+ puts (center.eql? center)
16
19
  end
17
20
 
18
21
  def draw
19
22
  background(0)
20
23
  # A vector that points to the mouse location
21
24
  mouse = Vec2D.new(mouse_x, mouse_y)
22
- # A vector that points to the center of the window
23
- center = Vec2D.new(width/2, height/2)
24
25
  # Subtract center from mouse which results in a vector that points from center to mouse
25
26
  mouse -= center
26
27
  # Normalize the vector
@@ -14,8 +14,6 @@ module Propane
14
14
  java_import 'monkstone.vecmath.ShapeRender'
15
15
  end
16
16
 
17
-
18
-
19
17
  # This class is the base class the user should inherit from when making
20
18
  # their own sketch.
21
19
  #
@@ -29,8 +27,7 @@ module Propane
29
27
  #
30
28
  # end
31
29
  class App < PApplet
32
- include Math
33
- include HelperMethods
30
+ include Math, MathTool, HelperMethods
34
31
  attr_reader :title, :arguments, :options
35
32
  # App should be instantiated with an optional list of options
36
33
  # and array of arguments.
@@ -1,9 +1,9 @@
1
1
  class Numeric #:nodoc:
2
2
  def degrees
3
- self * 180 / Math::PI
3
+ self * 57.29577951308232
4
4
  end
5
5
 
6
6
  def radians
7
- self * Math::PI / 180
7
+ self * 0.017453292519943295
8
8
  end
9
9
  end
@@ -1,10 +1,11 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: false
3
2
  require "#{PROPANE_ROOT}/lib/propane"
4
3
  require "#{PROPANE_ROOT}/lib/propane/app"
5
4
  require 'optparse'
6
5
 
7
6
  module Propane
7
+ java_import 'monkstone.WatchSketchDir'
8
+ java_import 'java.nio.file.StandardWatchEventKinds'
8
9
  # Utility class to handle the different commands that the 'rp5' command
9
10
  # offers. Able to run, watch, live, create, app, and unpack
10
11
  class Runner
@@ -26,6 +27,7 @@ module Propane
26
27
  show_help if options.empty?
27
28
  show_version if options[:version]
28
29
  run_sketch if options[:run]
30
+ watch_sketch if options[:watch]
29
31
  create if options[:create]
30
32
  install if options[:install]
31
33
  end
@@ -48,11 +50,16 @@ module Propane
48
50
  options[:install] = true
49
51
  end
50
52
 
53
+ options[:watch] = false
54
+ opts.on('-w', '--watch', 'Watch the sketch') do
55
+ options[:watch] = true
56
+ end
57
+
51
58
  options[:run] = false
52
59
  opts.on('-r', '--run', 'Run the sketch using jruby-complete') do
53
60
  options[:run] = true
54
61
  end
55
-
62
+
56
63
  options[:create] = false
57
64
  opts.on('-c', '--create', 'Create new sketch outline') do
58
65
  options[:create] = true
@@ -68,6 +75,23 @@ module Propane
68
75
  @argc = opt_parser.parse(args)
69
76
  @filename = argc.shift
70
77
  end
78
+
79
+ def watch_sketch
80
+ run_sketch
81
+ root = File.absolute_path(File.dirname(filename))
82
+ watcher = WatchSketchDir.watch(root)
83
+ count = 0 # guard against a duplicate event
84
+ watcher.add_listener do |event|
85
+ if event.kind == StandardWatchEventKinds::ENTRY_MODIFY
86
+ if count == 0
87
+ puts 'reloading sketch...'
88
+ run_sketch
89
+ end
90
+ count += 1
91
+ count = 0 if count == 2
92
+ end
93
+ end
94
+ end
71
95
 
72
96
  def run_sketch
73
97
  root = File.absolute_path(File.dirname(filename))
@@ -75,15 +99,15 @@ module Propane
75
99
  warn_format = 'File %s does not not Exist!'
76
100
  return warn(format(warn_format, sketch)) unless File.exist?(sketch)
77
101
  command = [
78
- 'java',
79
- '-cp',
80
- "#{PROPANE_ROOT}/lib/ruby/jruby-complete.jar",
81
- 'org.jruby.Main',
82
- sketch.to_s
102
+ 'java',
103
+ '-cp',
104
+ "#{PROPANE_ROOT}/lib/ruby/jruby-complete.jar",
105
+ 'org.jruby.Main',
106
+ sketch.to_s
83
107
  ].flatten
84
108
  exec(*command)
85
109
  end
86
-
110
+
87
111
  def create
88
112
  require_relative 'creators/creator'
89
113
  Propane::BasicSketch.new.create!(filename, argc)
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
  module Propane
4
- VERSION = '0.6.0'.freeze
4
+ VERSION = '0.7.0'.freeze
5
5
  end
data/pom.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
  project 'rp5extras', 'https://github.com/monkstone/propane' do
3
3
  model_version '4.0.0'
4
- id 'propane:rp5extras', '0.6.0'
4
+ id 'propane:rp5extras', '0.7.0'
5
5
  packaging 'jar'
6
6
  description 'rp5extras for propane'
7
7
  organization 'ruby-processing', 'https://ruby-processing.github.io'
@@ -33,7 +33,7 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
33
33
  'jogl.version' => '2.1.5-01'
34
34
  )
35
35
 
36
- pom('org.jruby:jruby:9.1.0.0')
36
+ pom('org.jruby:jruby:9.1.2.0')
37
37
  jar('org.processing:core:2.2.1')
38
38
  jar('org.jogamp.jogl:jogl-all:${jogl.version}')
39
39
  jar('org.jogamp.gluegen:gluegen-rt-main:${jogl.version}')
@@ -92,15 +92,15 @@ project 'rp5extras', 'https://github.com/monkstone/propane' do
92
92
  )
93
93
  end
94
94
 
95
- plugin( :compiler, '3.3',
95
+ plugin( :compiler, '3.5.1',
96
96
  source: '${maven.compiler.source}',
97
97
  target: '${maven.compiler.target}'
98
98
  )
99
- plugin( :javadoc, '2.10.3',
99
+ plugin( :javadoc, '2.10.4',
100
100
  detect_offline_links: 'false',
101
101
  links: ['${jruby.api}', '${processing.api}']
102
102
  )
103
- plugin( :jar, '2.6',
103
+ plugin( :jar, '3.0.2',
104
104
  archive: { manifestFile: 'MANIFEST.MF' }
105
105
  )
106
106
  end
data/pom.xml CHANGED
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
11
11
  <modelVersion>4.0.0</modelVersion>
12
12
  <groupId>propane</groupId>
13
13
  <artifactId>rp5extras</artifactId>
14
- <version>0.6.0</version>
14
+ <version>0.7.0</version>
15
15
  <name>rp5extras</name>
16
16
  <description>rp5extras for propane</description>
17
17
  <url>https://github.com/monkstone/propane</url>
@@ -69,7 +69,7 @@ DO NOT MODIFIY - GENERATED CODE
69
69
  <dependency>
70
70
  <groupId>org.jruby</groupId>
71
71
  <artifactId>jruby</artifactId>
72
- <version>9.1.0.0</version>
72
+ <version>9.1.2.0</version>
73
73
  <type>pom</type>
74
74
  </dependency>
75
75
  <dependency>
@@ -166,7 +166,7 @@ DO NOT MODIFIY - GENERATED CODE
166
166
  </plugin>
167
167
  <plugin>
168
168
  <artifactId>maven-compiler-plugin</artifactId>
169
- <version>3.3</version>
169
+ <version>3.5.1</version>
170
170
  <configuration>
171
171
  <source>${maven.compiler.source}</source>
172
172
  <target>${maven.compiler.target}</target>
@@ -174,9 +174,9 @@ DO NOT MODIFIY - GENERATED CODE
174
174
  </plugin>
175
175
  <plugin>
176
176
  <artifactId>maven-javadoc-plugin</artifactId>
177
- <version>2.10.3</version>
177
+ <version>2.10.4</version>
178
178
  <configuration>
179
- <detect_offline_links>false</detect_offline_links>
179
+ <detectOfflineLinks>false</detectOfflineLinks>
180
180
  <links>
181
181
  <link>${jruby.api}</link>
182
182
  <link>${processing.api}</link>
@@ -185,7 +185,7 @@ DO NOT MODIFIY - GENERATED CODE
185
185
  </plugin>
186
186
  <plugin>
187
187
  <artifactId>maven-jar-plugin</artifactId>
188
- <version>2.6</version>
188
+ <version>3.0.2</version>
189
189
  <configuration>
190
190
  <archive>
191
191
  <manifestFile>MANIFEST.MF</manifestFile>
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
23
23
  gem.files << 'lib/jogl-all-2.1.5-01-natives-macosx-universal.jar'
24
24
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
25
25
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
26
- gem.add_runtime_dependency 'arcball', '~> 0.0.2'
26
+ gem.add_runtime_dependency 'arcball', '~> 0.0.3'
27
27
  gem.require_paths = ['lib']
28
28
  gem.platform = 'java'
29
29
  end
@@ -0,0 +1,7 @@
1
+ package monkstone;
2
+
3
+ import java.nio.file.WatchEvent;
4
+
5
+ public interface CodeListener {
6
+ public void code_event(WatchEvent<?> event);
7
+ }
@@ -1,49 +1,47 @@
1
1
  /**
2
- * The purpose of this tool is to allow ruby-processing users to use an alternative
2
+ * The purpose of this tool is to allow JRubyArt users to use an alternative
3
3
  * to processing.org map, lerp and norm methods in their sketches
4
- * Copyright (C) 2015-16 Martin Prout. This tool is free software; you can
5
- * redistribute it and/or modify it under the terms of the GNU Lesser General
4
+ * Copyright (c) 2015-16 Martin Prout. This tool is free software; you can
5
+ * redistribute it and/or modify it under the terms of the GNU Lesser General
6
6
  * Public License as published by the Free Software Foundation; either version
7
7
  * 2.1 of the License, or (at your option) any later version.
8
- *
8
+ *
9
9
  * Obtain a copy of the license at http://www.gnu.org/licenses/lgpl-2.1.html
10
10
  */
11
11
  package monkstone;
12
12
 
13
13
  import org.jruby.Ruby;
14
- import org.jruby.RubyClass;
15
14
  import org.jruby.RubyFloat;
16
15
  import org.jruby.RubyModule;
17
- import org.jruby.RubyObject;
18
16
  import org.jruby.RubyRange;
19
17
  import org.jruby.anno.JRubyMethod;
18
+ import org.jruby.anno.JRubyModule;
20
19
  import org.jruby.runtime.ThreadContext;
21
20
  import org.jruby.runtime.builtin.IRubyObject;
22
21
 
23
22
  /**
24
23
  *
25
- * @author MartinProut
24
+ * @author Martin Prout
26
25
  */
27
-
28
- public class MathTool extends RubyObject {
29
-
30
- private static final long serialVersionUID = 4427564758225746633L;
31
- /**
32
- *
33
- * @param runtime
34
- */
35
- public static void createMathTool(Ruby runtime) {
36
- RubyModule processing = runtime.defineModule("Processing");
37
- RubyModule module = processing.defineModuleUnder("MathTool");
38
- module.defineAnnotatedMethods(MathTool.class);
26
+ @JRubyModule(name = "MathTool")
27
+ public class MathToolModule {
28
+
29
+ /**
30
+ *
31
+ * @param runtime Ruby
32
+ */
33
+
34
+ public static void createMathToolModule(Ruby runtime) {
35
+ RubyModule mtModule = runtime.defineModule("MathTool");
36
+ mtModule.defineAnnotatedMethods(MathToolModule.class);
39
37
  }
40
38
 
41
39
  /**
42
40
  *
43
- * @param context JRuby runtime
44
- * @param recv self
41
+ * @param context ThreadContext
42
+ * @param recv IRubyObject
45
43
  * @param args array of RubyRange (must be be numeric)
46
- * @return RubyFloat
44
+ * @return mapped value RubyFloat
47
45
  */
48
46
  @JRubyMethod(name = "map1d", rest = true, module = true)
49
47
  public static IRubyObject mapOneD(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
@@ -59,10 +57,10 @@ public class MathTool extends RubyObject {
59
57
 
60
58
  /**
61
59
  *
62
- * @param context JRuby runtime
63
- * @param recv self
60
+ * @param context ThreadContext
61
+ * @param recv IRubyObject
64
62
  * @param args array of RubyRange (must be be numeric)
65
- * @return RubyFloat
63
+ * @return mapped value RubyFloat
66
64
  */
67
65
  @JRubyMethod(name = "constrained_map", rest = true, module = true)
68
66
  public static IRubyObject constrainedMap(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
@@ -82,16 +80,16 @@ public class MathTool extends RubyObject {
82
80
  value = max;
83
81
  }
84
82
  return mapMt(context, value, first1, last1, first2, last2);
85
- }
86
-
83
+ }
84
+
87
85
  /**
88
86
  *
89
- * @param context JRuby runtime
90
- * @param recv self
87
+ * @param context ThreadContext
88
+ * @param recv self IRubyObject
91
89
  * @param args floats as in processing map function
92
- * @return RubyFloat
90
+ * @return mapped value RubyFloat
93
91
  */
94
- @JRubyMethod(name = {"p5map", "map"}, rest = true, module = true)
92
+ @JRubyMethod(name = "p5map", rest = true, module = true)
95
93
  public static IRubyObject mapProcessing(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
96
94
  double value = (Double) args[0].toJava(Double.class);
97
95
  double first1 = (Double) args[1].toJava(Double.class);
@@ -99,14 +97,15 @@ public class MathTool extends RubyObject {
99
97
  double last1 = (Double) args[2].toJava(Double.class);
100
98
  double last2 = (Double) args[4].toJava(Double.class);
101
99
  return mapMt(context, value, first1, last1, first2, last2);
102
- }
103
-
100
+ }
101
+
102
+
104
103
  /**
105
104
  * A more correct version than processing.org version
106
- * @param context
107
- * @param recv
105
+ * @param context ThreadContext
106
+ * @param recv self IRubyObject
108
107
  * @param args args[2] should be between 0 and 1.0 if not returns start or stop
109
- * @return lerp value
108
+ * @return lerped value RubyFloat
110
109
  */
111
110
  @JRubyMethod(name = "lerp", rest = true, module = true)
112
111
  public static IRubyObject lerpP(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
@@ -116,32 +115,33 @@ public class MathTool extends RubyObject {
116
115
  if (amount <= 0) return args[0];
117
116
  if (amount >= 1.0) return args[1];
118
117
  return context.getRuntime().newFloat((1 - amount) * start + (stop * amount));
119
- }
120
-
118
+ }
119
+
120
+
121
121
  /**
122
122
  * Identical to p5map(value, low, high, 0, 1).
123
- * Numbers outside of the range are not clamped to 0 and 1,
124
- * because out-of-range values are often intentional and useful.
125
- * @param context
126
- * @param recv
127
- * @param args
128
- * @return norm value
123
+ * Numbers outside of the range are not clamped to 0 and 1,
124
+ * because out-of-range values are often intentional and useful.
125
+ * @param context ThreadContext
126
+ * @param recv IRubyObject
127
+ * @param args array of args must be be numeric
128
+ * @return mapped value RubyFloat
129
129
  */
130
130
  @JRubyMethod(name = "norm", rest = true, module = true)
131
- public static IRubyObject normP(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
131
+ public static IRubyObject normP(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
132
132
  double value = (Double) args[0].toJava(Double.class);
133
133
  double start = (Double) args[1].toJava(Double.class);
134
- double stop = (Double) args[2].toJava(Double.class);
134
+ double stop = (Double) args[2].toJava(Double.class);
135
135
  return mapMt(context, value, start, stop, 0, 1.0);
136
136
  }
137
-
137
+
138
138
  /**
139
139
  * Identical to p5map(value, low, high, 0, 1) but 'clamped'.
140
- * Numbers outside of the range are clamped to 0 and 1,
141
- * @param context
142
- * @param recv
143
- * @param args
144
- * @return strict normalized value ie 0..1.0
140
+ * Numbers outside of the range are clamped to 0 and 1,
141
+ * @param context ThreadContext
142
+ * @param recv IRubyObject
143
+ * @param args array of args must be be numeric
144
+ * @return mapped value RubyFloat
145
145
  */
146
146
  @JRubyMethod(name = "norm_strict", rest = true, module = true)
147
147
  public static IRubyObject norm_strict(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
@@ -156,18 +156,18 @@ public class MathTool extends RubyObject {
156
156
  } else {
157
157
  return mapMt(context, value, start, stop, 0, 1.0);
158
158
  }
159
- }
160
-
161
- static final RubyFloat mapMt(ThreadContext context, double value, double first1, double last1, double first2, double last2) {
159
+ }
160
+
161
+ static final RubyFloat mapMt(ThreadContext context, double value, double first1, double last1, double first2, double last2) {
162
162
  double result = first2 + (last2 - first2) * ((value - first1) / (last1 - first1));
163
163
  return context.getRuntime().newFloat(result);
164
164
  }
165
-
165
+
166
166
  /**
167
167
  * Provides processing constrain method as a ruby module method
168
- * @param context
169
- * @param recv
170
- * @param args
168
+ * @param context ThreadContext
169
+ * @param recv IRubyObject
170
+ * @param args array of args must be be numeric
171
171
  * @return original or limit values
172
172
  */
173
173
  @JRubyMethod(name = "constrain", rest = true, module = true)
@@ -183,13 +183,4 @@ public class MathTool extends RubyObject {
183
183
  return args[1];
184
184
  }
185
185
  }
186
-
187
- /**
188
- *
189
- * @param runtime
190
- * @param metaClass
191
- */
192
- public MathTool(Ruby runtime, RubyClass metaClass) {
193
- super(runtime, metaClass);
194
- }
195
186
  }