propane 3.4.0-java → 3.7.0.pre-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -2
- data/.mvn/wrapper/MavenWrapperDownloader.java +2 -2
- data/.mvn/wrapper/maven-wrapper.properties +2 -2
- data/.travis.yml +2 -2
- data/CHANGELOG.md +12 -0
- data/Gemfile +2 -0
- data/README.md +17 -8
- data/Rakefile +10 -11
- data/bin/propane +3 -1
- data/lib/propane.rb +6 -4
- data/lib/propane/app.rb +20 -10
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +23 -24
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +10 -9
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +14 -6
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +28 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +6 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +7 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +4 -1
- data/pom.rb +37 -36
- data/pom.xml +7 -7
- data/propane.gemspec +16 -12
- data/src/main/java/monkstone/ColorUtil.java +13 -1
- data/src/main/java/monkstone/MathToolModule.java +253 -203
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +2 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +7 -6
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +3 -3
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
- data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +11 -27
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +781 -285
- data/src/main/java/processing/awt/PImageAWT.java +377 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +56 -52
- data/src/main/java/processing/awt/PSurfaceAWT.java +309 -209
- data/src/main/java/processing/awt/ShimAWT.java +581 -0
- data/src/main/java/processing/core/PApplet.java +4510 -4503
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +914 -880
- data/src/main/java/processing/core/PGraphics.java +193 -177
- data/src/main/java/processing/core/PImage.java +611 -309
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +478 -415
- data/src/main/java/processing/core/PMatrix3D.java +762 -735
- data/src/main/java/processing/core/PShape.java +2888 -2652
- data/src/main/java/processing/core/PShapeOBJ.java +97 -92
- data/src/main/java/processing/core/PShapeSVG.java +1705 -1490
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +139 -97
- data/src/main/java/processing/core/PSurfaceNone.java +296 -218
- data/src/main/java/processing/core/PVector.java +997 -965
- data/src/main/java/processing/core/ThinkDifferent.java +15 -13
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3690 -3510
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +957 -883
- data/src/main/java/processing/dxf/RawDXF.java +404 -0
- data/src/main/java/processing/event/Event.java +87 -67
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +88 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
- data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
- data/src/main/java/processing/net/Client.java +744 -0
- data/src/main/java/processing/net/Server.java +388 -0
- data/src/main/java/processing/opengl/FontTexture.java +289 -270
- data/src/main/java/processing/opengl/FrameBuffer.java +386 -364
- data/src/main/java/processing/opengl/LinePath.java +547 -500
- data/src/main/java/processing/opengl/LineStroker.java +588 -581
- data/src/main/java/processing/opengl/PGL.java +3047 -2914
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
- data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
- data/src/main/java/processing/opengl/PShader.java +1266 -1257
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
- data/src/main/java/processing/opengl/Texture.java +1492 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +35 -22
- data/vendors/Rakefile +33 -62
- metadata +56 -48
- data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
- data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
- data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
- data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
- data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
- data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
- data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
- data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
- data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
- data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
- data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
- data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
- data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
- data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
- data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
- data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
- data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
- data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
- data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
- data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0e8998483c06aa7d27737cd3b9d1f87ef8edb0268367f58d42356b7f5c20aa1
|
4
|
+
data.tar.gz: de9bb8230f17b2aa2cd0da453b465c8d9f529a74b74c0de0f6c39aa62fb39eb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a54ad411a64dd89249880b5a72cf4687b475267196659bb1887b0fe9dbbce3013357ba5196a0da2369cbc92a49a9410c1c9155f9028feff3152149725c021957
|
7
|
+
data.tar.gz: 2ca39c591cb7a15b0a9f592c4f335ba5062c1a9b6dbda26afb7707d981b9d73278c0e84044b948f61f4f53eb274f5dd9430c96600d599db5a29c06cd47849c44
|
data/.mvn/extensions.xml
CHANGED
@@ -20,7 +20,7 @@ import java.util.Properties;
|
|
20
20
|
|
21
21
|
public class MavenWrapperDownloader {
|
22
22
|
|
23
|
-
private static final String WRAPPER_VERSION = "0.5.
|
23
|
+
private static final String WRAPPER_VERSION = "0.5.6";
|
24
24
|
/**
|
25
25
|
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
26
26
|
*/
|
@@ -89,7 +89,7 @@ public class MavenWrapperDownloader {
|
|
89
89
|
System.exit(0);
|
90
90
|
} catch (Throwable e) {
|
91
91
|
System.out.println("- Error downloading");
|
92
|
-
|
92
|
+
|
93
93
|
System.exit(1);
|
94
94
|
}
|
95
95
|
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.
|
2
|
-
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.
|
1
|
+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
|
2
|
+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
**v3.7.0** Experimental support for ios-arm64
|
2
|
+
|
3
|
+
**v3.6.0** Recommend JRuby-9.2.14.0 use video-2.0 release
|
4
|
+
|
5
|
+
**v3.5.0** Rebase processing core code around Sam Pottingers latest fixes for JOGL an image save, does mean breaking some of Diwis and Joshua Davis examples, but one hopes codeanticode knows what he's doing.
|
6
|
+
|
7
|
+
**v3.4.3** Use Map.of to initialize HashMap bump processing version in build bump to jruby-9.2.11.0
|
8
|
+
|
9
|
+
**v3.4.2** Fix native library bug on windows (thanks to Jay Scott). Add minim library examples
|
10
|
+
|
11
|
+
**v3.4.1** Update to jruby-9.2.9.0
|
12
|
+
|
1
13
|
**v3.4.0** Experimental refactoring of ThinkDifferent, and some other processing classes
|
2
14
|
|
3
15
|
**v3.3.1** Reflection makes refactoring a nightmare DesktopHandler => ThinkDifferent
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# Propane ![Travis CI](https://travis-ci.org/ruby-processing/propane.svg)
|
1
|
+
# Propane [![Gem Version](https://badge.fury.io/rb/propane.svg)](https://badge.fury.io/rb/propane) ![Travis CI](https://travis-ci.org/ruby-processing/propane.svg)
|
2
2
|
|
3
|
-
This version is intended to work with openjdk11+, @sampottinger is currently working on [vanilla processing][vanilla] which will enable JRubyArt to catch up.
|
3
|
+
This version is intended to work with openjdk11+, @sampottinger is currently working on [vanilla processing][vanilla] which will enable JRubyArt to catch up.
|
4
4
|
|
5
5
|
A slim layer to communicate with Processing from JRuby, features maven build. We have created a configuration free version of ruby processing, for processing-4.0+, where we include a modified processing core (`public runPropane()` to replace `protected runSketch()`. These jars are small enough to include in a gem distribution, and hence we do not require configuration. This has created a scriptable version, ie files get run direct from jruby. Currently JavaFX is unsupported again @sampottinger is currently working on [vanilla processing][vanilla] to use OpenJFX. It would be nice make use of java modules, but I think we should let jruby project do that first (unless processing.org beat them to it).
|
6
6
|
|
@@ -8,9 +8,12 @@ adjust above for your OS/distro setup.
|
|
8
8
|
|
9
9
|
## Requirements
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
- `
|
11
|
+
There may be a linker issue with P2D or P3D sketches with stock openjdk with some linux distros, in which case you might find [Adopt open jdk binaries][adopt] will work for you.
|
12
|
+
|
13
|
+
- `jdk-11.0.3+`
|
14
|
+
- `jruby-9.2.12.0`
|
15
|
+
|
16
|
+
Currently you can ignore `illegal reflective access` warnings, see [here how to suppress them][warning].
|
14
17
|
|
15
18
|
## Building and testing
|
16
19
|
|
@@ -24,10 +27,10 @@ rake javadoc
|
|
24
27
|
|
25
28
|
```bash
|
26
29
|
jgem install propane # from rubygems
|
27
|
-
jgem install propane-3.
|
30
|
+
jgem install propane-3.6.0-java.gem # local install
|
28
31
|
# Alternative
|
29
32
|
jruby -S gem install propane # from rubygems
|
30
|
-
jruby -S gem install propane-3.
|
33
|
+
jruby -S gem install propane-3.6.0-java.gem # local install
|
31
34
|
```
|
32
35
|
|
33
36
|
## Check Install
|
@@ -37,6 +40,10 @@ To check version and confirm gem bin files are on your path (also checks JDK ver
|
|
37
40
|
propane --version
|
38
41
|
```
|
39
42
|
|
43
|
+
## Suppressing Reflective Access warnings
|
44
|
+
|
45
|
+
Since propane-3.5.0 it is possible to suppress reflective access warnings by setting JAVA_HOME environmental variable jruby does the rest.
|
46
|
+
|
40
47
|
## Usage
|
41
48
|
|
42
49
|
A propane sketch:-
|
@@ -88,13 +95,15 @@ See [gh-pages][gh-pages] for more detailed instructions and much more.
|
|
88
95
|
|
89
96
|
## Examples
|
90
97
|
|
91
|
-
[Worked Examples](https://github.com/ruby-processing/propane-examples) more to follow, feel free to add your own, especially ruby-2.
|
98
|
+
[Worked Examples](https://github.com/ruby-processing/propane-examples) more to follow, feel free to add your own, especially ruby-2.5
|
92
99
|
+ syntax now we can. To install the samples. The samples get copied to `~/propane_samples`. Depends on wget.
|
93
100
|
```bash
|
94
101
|
propane --install samples
|
95
102
|
```
|
96
103
|
please move existing `propane_samples` if you wish to keep them. The current release features several PixelFlow glsl library examples, including a few shadertoy demos as sketches.
|
97
104
|
|
105
|
+
[adopt]: https://adoptopenjdk.net/
|
98
106
|
[building]:http://ruby-processing.github.io/building/building/
|
99
107
|
[gh-pages]:https://ruby-processing.github.io/propane/
|
100
108
|
[vanilla]:https://github.com/processing/processing/pull/5753
|
109
|
+
[warning]: https://monkstone.github.io/jruby_art/update/2019/09/10/Reflective_Access.html
|
data/Rakefile
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
|
+
|
2
3
|
require_relative 'lib/propane/version'
|
3
4
|
|
4
|
-
task default: [
|
5
|
+
task default: %i[init compile install test gem]
|
5
6
|
|
6
|
-
# depends on
|
7
|
+
# Currently depends on local jogl-2.4.0 jars on path ~/jogl24
|
7
8
|
desc 'Copy Jars'
|
8
9
|
task :init do
|
9
|
-
|
10
|
-
|
11
|
-
jar_dir = File.join(processing_root, 'core', 'library')
|
12
|
-
opengl = Dir.entries(jar_dir).grep(/amd64|macosx-universal/)
|
10
|
+
jogl24 = File.join(ENV['HOME'], 'jogl24')
|
11
|
+
opengl = Dir.entries(jogl24).grep(/amd64|universal|arm64/).select { |jar| jar =~ /linux|windows|macosx|ios|/ }
|
13
12
|
opengl.concat %w[jogl-all.jar gluegen-rt.jar]
|
14
13
|
opengl.each do |gl|
|
15
|
-
FileUtils.cp(File.join(
|
14
|
+
FileUtils.cp(File.join(jogl24, gl), File.join('.', 'lib'))
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
@@ -23,17 +22,17 @@ end
|
|
23
22
|
|
24
23
|
desc 'Gem'
|
25
24
|
task :gem do
|
26
|
-
sh '
|
25
|
+
sh 'jgem build propane.gemspec'
|
27
26
|
end
|
28
27
|
|
29
28
|
desc 'Document'
|
30
29
|
task :javadoc do
|
31
|
-
sh '
|
30
|
+
sh './mvnw javadoc:javadoc'
|
32
31
|
end
|
33
32
|
|
34
33
|
desc 'Compile'
|
35
34
|
task :compile do
|
36
|
-
sh '
|
35
|
+
sh './mvnw package'
|
37
36
|
end
|
38
37
|
|
39
38
|
desc 'JRuby-Complete'
|
@@ -53,7 +52,7 @@ end
|
|
53
52
|
|
54
53
|
desc 'clean'
|
55
54
|
task :clean do
|
56
|
-
Dir[
|
55
|
+
Dir['./**/*.{jar,gem}'].each do |path|
|
57
56
|
puts "Deleting #{path} ..."
|
58
57
|
File.delete(path)
|
59
58
|
end
|
data/bin/propane
CHANGED
data/lib/propane.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'java'
|
3
4
|
unless defined? PROPANE_ROOT
|
4
|
-
$LOAD_PATH << File.
|
5
|
-
PROPANE_ROOT = File.
|
5
|
+
$LOAD_PATH << File.dirname(__dir__)
|
6
|
+
PROPANE_ROOT = File.dirname(__dir__)
|
6
7
|
end
|
7
|
-
Dir["#{PROPANE_ROOT}/lib/*.jar"].each do |jar|
|
8
|
+
Dir["#{PROPANE_ROOT}/lib/*.jar"].sort.each do |jar|
|
8
9
|
require jar
|
9
10
|
end
|
10
|
-
|
11
|
+
require "#{PROPANE_ROOT}/lib/propane/app"
|
12
|
+
require "#{PROPANE_ROOT}/lib/propane/helpers/numeric"
|
data/lib/propane/app.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
|
+
|
3
|
+
require 'jruby'
|
2
4
|
require_relative 'helper_methods'
|
3
5
|
require_relative 'library_loader'
|
4
6
|
|
@@ -8,7 +10,7 @@ module Propane
|
|
8
10
|
# Load vecmath, fastmath and mathtool modules
|
9
11
|
Java::Monkstone::PropaneLibrary.load(JRuby.runtime)
|
10
12
|
SKETCH_ROOT = File.absolute_path('.')
|
11
|
-
|
13
|
+
# import custom Vecmath renderers
|
12
14
|
module Render
|
13
15
|
java_import 'monkstone.vecmath.GfxRender'
|
14
16
|
java_import 'monkstone.vecmath.ShapeRender'
|
@@ -49,13 +51,15 @@ module Propane
|
|
49
51
|
|
50
52
|
# All sketches extend this class
|
51
53
|
class App < PApplet
|
52
|
-
include
|
54
|
+
include HelperMethods
|
55
|
+
include Math
|
56
|
+
include MathTool
|
57
|
+
include Render
|
53
58
|
# Alias some methods for familiarity for Shoes coders.
|
54
59
|
alias oval ellipse
|
55
60
|
alias stroke_width stroke_weight
|
56
61
|
alias rgb color
|
57
62
|
alias gray color
|
58
|
-
field_reader :surface
|
59
63
|
|
60
64
|
def sketch_class
|
61
65
|
self.class.sketch_class
|
@@ -75,8 +79,8 @@ module Propane
|
|
75
79
|
#
|
76
80
|
class << self
|
77
81
|
# Handy getters and setters on the class go here:
|
78
|
-
attr_accessor :sketch_class, :library_loader, :
|
79
|
-
|
82
|
+
attr_accessor :sketch_class, :library_loader, :arguments, :options
|
83
|
+
attr_reader :surface
|
80
84
|
def load_libraries(*args)
|
81
85
|
library_loader ||= LibraryLoader.new
|
82
86
|
library_loader.load_library(*args)
|
@@ -99,6 +103,7 @@ module Propane
|
|
99
103
|
# Processing call them by their expected Java names.
|
100
104
|
def method_added(method_name) #:nodoc:
|
101
105
|
return unless METHODS_TO_ALIAS.key?(method_name)
|
106
|
+
|
102
107
|
alias_method METHODS_TO_ALIAS[method_name], method_name
|
103
108
|
end
|
104
109
|
end
|
@@ -112,12 +117,14 @@ module Propane
|
|
112
117
|
proxy_java_fields
|
113
118
|
raise TypeError unless options.is_a? Hash
|
114
119
|
raise TypeError unless arguments.is_a? Array
|
120
|
+
|
115
121
|
# Set up the sketch.
|
116
122
|
super()
|
117
123
|
post_initialize(options)
|
118
124
|
Propane.app = self
|
119
125
|
@arguments = arguments
|
120
126
|
@options = options
|
127
|
+
@surface = get_surface
|
121
128
|
run_propane
|
122
129
|
end
|
123
130
|
|
@@ -126,12 +133,11 @@ module Propane
|
|
126
133
|
@width ||= w
|
127
134
|
@height ||= h
|
128
135
|
@render_mode ||= mode
|
129
|
-
import_opengl if /opengl
|
136
|
+
import_opengl if /opengl/.match?(mode)
|
130
137
|
super(*args)
|
131
138
|
end
|
132
139
|
|
133
|
-
def post_initialize(_args)
|
134
|
-
end
|
140
|
+
def post_initialize(_args); end
|
135
141
|
|
136
142
|
def sketch_title(title)
|
137
143
|
surface.set_title(title)
|
@@ -164,6 +170,7 @@ module Propane
|
|
164
170
|
# Processing call them by their expected Java names.
|
165
171
|
def method_added(method_name) #:nodoc:
|
166
172
|
return unless METHODS_TO_ALIAS.key?(method_name)
|
173
|
+
|
167
174
|
alias_method METHODS_TO_ALIAS[method_name], method_name
|
168
175
|
end
|
169
176
|
end
|
@@ -181,7 +188,10 @@ module Propane
|
|
181
188
|
|
182
189
|
def method_missing(name, *args, &block)
|
183
190
|
return Propane.app.send(name, *args) if Propane.app.respond_to? name
|
191
|
+
|
184
192
|
super
|
185
193
|
end
|
186
|
-
end
|
187
|
-
end
|
194
|
+
end
|
195
|
+
# end Processing::Proxy
|
196
|
+
end
|
197
|
+
# end Propane
|
@@ -5,7 +5,10 @@ class SketchClass
|
|
5
5
|
attr_reader :name, :width, :height, :mode
|
6
6
|
|
7
7
|
def initialize(name:, width: 150, height: 150, mode: nil)
|
8
|
-
@name
|
8
|
+
@name = name
|
9
|
+
@width = width
|
10
|
+
@height = height
|
11
|
+
@mode = mode
|
9
12
|
end
|
10
13
|
|
11
14
|
def class_sketch
|
@@ -26,6 +29,7 @@ class SketchClass
|
|
26
29
|
|
27
30
|
def size
|
28
31
|
return format(' size %d, %d', width.to_i, height.to_i) unless mode
|
32
|
+
|
29
33
|
format(' size %d, %d, %s', width.to_i, height.to_i, mode.upcase)
|
30
34
|
end
|
31
35
|
|
@@ -36,6 +40,7 @@ class SketchClass
|
|
36
40
|
|
37
41
|
def method_lines(name, content = nil)
|
38
42
|
return [format(' def %s', name), '', ' end'] unless content
|
43
|
+
|
39
44
|
[format(' def %s', name), content, ' end', '']
|
40
45
|
end
|
41
46
|
|
@@ -43,6 +48,7 @@ class SketchClass
|
|
43
48
|
lines = [
|
44
49
|
'#!/usr/bin/env jruby',
|
45
50
|
'# frozen_string_literal: false',
|
51
|
+
'',
|
46
52
|
"require 'propane'",
|
47
53
|
'',
|
48
54
|
class_sketch
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'sketch_writer'
|
2
4
|
|
3
5
|
class SketchFactory
|
4
|
-
NAMES = %w[One Two Three]
|
5
|
-
def initialize(
|
6
|
+
NAMES = %w[One Two Three].freeze
|
7
|
+
def initialize(_argc)
|
6
8
|
NAMES.each do |name|
|
7
9
|
SketchWriter.new(File.basename(name, '.rb'), width: 300, height: 300).write
|
8
10
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: false
|
2
|
+
|
2
3
|
# processing module wrapper
|
3
|
-
require_relative 'helpers/numeric'
|
4
4
|
module Propane
|
5
5
|
# Provides some convenience methods
|
6
6
|
module HelperMethods
|
@@ -52,11 +52,12 @@ module Propane
|
|
52
52
|
|
53
53
|
def color(*args)
|
54
54
|
return super(*args) unless args.length == 1
|
55
|
+
|
55
56
|
super(hex_color(args[0]))
|
56
57
|
end
|
57
58
|
|
58
59
|
def web_to_color_array(web)
|
59
|
-
Java::Monkstone::ColorUtil.webArray(web)
|
60
|
+
Java::Monkstone::ColorUtil.webArray(web.to_java(:string))
|
60
61
|
end
|
61
62
|
|
62
63
|
def int_to_ruby_colors(hex)
|
@@ -66,11 +67,8 @@ module Propane
|
|
66
67
|
# Overrides Processing convenience function thread, which takes a String
|
67
68
|
# arg (for a function) to more rubylike version, takes a block...
|
68
69
|
def thread(&block)
|
69
|
-
|
70
|
-
|
71
|
-
else
|
72
|
-
raise ArgumentError, 'thread must be called with a block', caller
|
73
|
-
end
|
70
|
+
warn 'A Block is Needed' unless block_given?
|
71
|
+
Java::JavaLang::Thread.new(&block).start
|
74
72
|
end
|
75
73
|
|
76
74
|
# explicitly provide 'processing.org' min instance method
|
@@ -94,9 +92,9 @@ module Propane
|
|
94
92
|
def dist(*args)
|
95
93
|
case args.length
|
96
94
|
when 4
|
97
|
-
|
95
|
+
dist2d(*args)
|
98
96
|
when 6
|
99
|
-
|
97
|
+
dist3d(*args)
|
100
98
|
else
|
101
99
|
raise ArgumentError, 'takes 4 or 6 parameters'
|
102
100
|
end
|
@@ -111,13 +109,13 @@ module Propane
|
|
111
109
|
# Here's a convenient way to look for them.
|
112
110
|
def find_method(method_name)
|
113
111
|
reg = Regexp.new(method_name.to_s, true)
|
114
|
-
methods.sort.select { |meth| reg.match(meth) }
|
112
|
+
methods.sort.select { |meth| reg.match?(meth) }
|
115
113
|
end
|
116
114
|
|
117
115
|
# Proxy over a list of Java declared fields that have the same name as
|
118
116
|
# some methods. Add to this list as needed.
|
119
117
|
def proxy_java_fields
|
120
|
-
fields = %w
|
118
|
+
fields = %w[key frameRate mousePressed keyPressed]
|
121
119
|
methods = fields.map { |field| java_class.declared_field(field) }
|
122
120
|
@declared_fields = Hash[fields.zip(methods)]
|
123
121
|
end
|
@@ -163,6 +161,7 @@ module Propane
|
|
163
161
|
# frame_rate needs to support reading and writing
|
164
162
|
def frame_rate(fps = nil)
|
165
163
|
return @declared_fields['frameRate'].value(java_self) unless fps
|
164
|
+
|
166
165
|
super(fps)
|
167
166
|
end
|
168
167
|
|
@@ -178,21 +177,19 @@ module Propane
|
|
178
177
|
|
179
178
|
private
|
180
179
|
|
181
|
-
INTEGER_COL = -> (x) { x.is_a?(Integer) }
|
182
|
-
STRING_COL = -> (x) { x.is_a?(String) }
|
183
|
-
FLOAT_COL = -> (x) { x.is_a?(Float) }
|
184
180
|
# parse single argument color int/double/String
|
185
|
-
def hex_color(
|
186
|
-
case
|
187
|
-
when
|
188
|
-
Java::Monkstone::ColorUtil.colorLong(
|
189
|
-
when
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
181
|
+
def hex_color(arg)
|
182
|
+
case arg
|
183
|
+
when Integer
|
184
|
+
Java::Monkstone::ColorUtil.colorLong(arg)
|
185
|
+
when String
|
186
|
+
raise 'Dodgy Hexstring' unless /#\h{6}$/.match?(arg)
|
187
|
+
|
188
|
+
Java::Monkstone::ColorUtil.colorString(arg)
|
189
|
+
when Float
|
190
|
+
Java::Monkstone::ColorUtil.colorDouble(arg)
|
194
191
|
else
|
195
|
-
raise
|
192
|
+
raise 'Dodgy Color Conversion'
|
196
193
|
end
|
197
194
|
end
|
198
195
|
|
@@ -200,6 +197,7 @@ module Propane
|
|
200
197
|
dx = args[0] - args[2]
|
201
198
|
dy = args[1] - args[3]
|
202
199
|
return 0 if dx.abs < EPSILON && dy.abs < EPSILON
|
200
|
+
|
203
201
|
Math.hypot(dx, dy)
|
204
202
|
end
|
205
203
|
|
@@ -208,6 +206,7 @@ module Propane
|
|
208
206
|
dy = args[1] - args[4]
|
209
207
|
dz = args[2] - args[5]
|
210
208
|
return 0 if dx.abs < EPSILON && dy.abs < EPSILON && dz.abs < EPSILON
|
209
|
+
|
211
210
|
Math.sqrt(dx * dx + dy * dy + dz * dz)
|
212
211
|
end
|
213
212
|
end
|