propane 3.7.1-java → 3.8.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
  SHA256:
3
- metadata.gz: 8d91c85e879a5cf795566043ce69accbc17b2d71f34ddbfbe7f3a7855975b5e3
4
- data.tar.gz: 70ddc22146913b60b6cf5dc66e9cbb47efa20e394acc039aca71a16282f80e76
3
+ metadata.gz: 5df47b4eba645e3b5de5e4c6bbcd5af6c2955cc2e34c326fcb712b967d272c2e
4
+ data.tar.gz: fd791b044c4780f082aa2f6660a7818266603fd6fdcbb6463c8af6c42e34a41d
5
5
  SHA512:
6
- metadata.gz: 6d17d5093f9e26213ec22d936ae15cf0c50b3cc9ae162423c7499294cc0d96df7bc964e20f9cd9bfb47b31afeed9d1407482a1137fc0f837e7235950fb25963b
7
- data.tar.gz: e22db42e8e8b3a780da3faa62fbbcb7bd7f653ba6bda5f92cc3338853178d2a21e77662e1d08871cbb2b6223ccdffe4047d4e5ec7e78bea946424c6d660d7190
6
+ metadata.gz: 49bab01156deeea38dc4710486fa371dc93a0b0056f7e93d5110fc2343f4477093fcbd2cc50cc7d3153668916d80ed1dff74a0e3fdcce652784d0d6d8d99c90a
7
+ data.tar.gz: 752c53bb1719652fc1b11514add89b0dff33b2dba23b72ed44db0c58a3d86b99373d1f69f7d928c12e829fb4d1b942da89805d3d4dc3c427bcc36477d60abd75
data/.mvn/extensions.xml CHANGED
@@ -3,6 +3,6 @@
3
3
  <extension>
4
4
  <groupId>io.takari.polyglot</groupId>
5
5
  <artifactId>polyglot-ruby</artifactId>
6
- <version>0.4.5</version>
6
+ <version>0.4.6</version>
7
7
  </extension>
8
8
  </extensions>
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ **v3.8.0** Refactor noise to delegate pattern, improve default implementation and add simplex noise option
2
+
1
3
  **v3.7.1** Recommend JRuby-9.2.15.0 use
2
4
 
3
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.
data/README.md CHANGED
@@ -8,12 +8,10 @@ adjust above for your OS/distro setup.
8
8
 
9
9
  ## Requirements
10
10
 
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.
11
+ Previously there has been linker issue with P2D or P3D sketches with stock openjdk with some linux distros, but that seems to have gone away. [Adopt open jdk binaries][adopt] have always worked.
12
12
 
13
13
  - `jdk-11.0.7+`
14
- - `jruby-9.2.14.0`
15
-
16
- Currently you can ignore `illegal reflective access` warnings, see [here how to suppress them][warning].
14
+ - `jruby-9.2.16.0`
17
15
 
18
16
  ## Building and testing
19
17
 
@@ -27,10 +25,10 @@ rake javadoc
27
25
 
28
26
  ```bash
29
27
  jgem install propane # from rubygems
30
- jgem install propane-3.6.0-java.gem # local install
28
+ jgem install propane-3.8.0-java.gem # local install
31
29
  # Alternative
32
30
  jruby -S gem install propane # from rubygems
33
- jruby -S gem install propane-3.6.0-java.gem # local install
31
+ jruby -S gem install propane-3.8.0-java.gem # local install
34
32
  ```
35
33
 
36
34
  ## Check Install
@@ -39,11 +37,6 @@ To check version and confirm gem bin files are on your path (also checks JDK ver
39
37
  ```bash
40
38
  propane --version
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
-
47
40
  ## Usage
48
41
 
49
42
  A propane sketch:-
@@ -100,7 +93,7 @@ See [gh-pages][gh-pages] for more detailed instructions and much more.
100
93
  ```bash
101
94
  propane --install samples
102
95
  ```
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.
96
+ please move existing `propane_samples` if you wish to keep them. The current release features some noise sketches that exploit the new choice of noise implementation.
104
97
 
105
98
  [adopt]: https://adoptopenjdk.net/
106
99
  [building]:http://ruby-processing.github.io/building/building/
data/lib/propane/app.rb CHANGED
@@ -16,6 +16,9 @@ module Propane
16
16
  java_import 'monkstone.vecmath.ShapeRender'
17
17
  end
18
18
 
19
+ VALUE = Java::MonkstoneNoise::NoiseMode::PERLIN
20
+ SIMPLEX = Java::MonkstoneNoise::NoiseMode::SIMPLEX
21
+
19
22
  # This class is the base class the user should inherit from when making
20
23
  # their own sketch.
21
24
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Propane
4
- VERSION = '3.7.1'
4
+ VERSION = '3.8.0'
5
5
  end
data/pom.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  project 'propane', 'https://github.com/monkstone/propane' do
4
4
  model_version '4.0.0'
5
- id 'propane:propane:3.7.1'
5
+ id 'propane:propane:3.8.0'
6
6
  packaging 'jar'
7
7
 
8
8
  description 'An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.'
@@ -46,7 +46,7 @@ project 'propane', 'https://github.com/monkstone/propane' do
46
46
  'jogl.version' => '2.3.2', # for compiling actual included 2.4.0-rc
47
47
  'jruby.api' => 'http://jruby.org/apidocs/')
48
48
 
49
- pom 'org.jruby:jruby:9.2.15.0'
49
+ pom 'org.jruby:jruby:9.2.16.0'
50
50
  jar 'org.processing:video:3.3.7' # only for compiling
51
51
  jar 'org.jogamp.jogl:jogl-all:${jogl.version}'
52
52
  jar 'org.jogamp.gluegen:gluegen-rt-main:${jogl.version}'
data/pom.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <!--
3
3
 
4
4
 
5
- DO NOT MODIFIY - GENERATED CODE
5
+ DO NOT MODIFY - GENERATED CODE
6
6
 
7
7
 
8
8
  -->
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
11
11
  <modelVersion>4.0.0</modelVersion>
12
12
  <groupId>propane</groupId>
13
13
  <artifactId>propane</artifactId>
14
- <version>3.7.1</version>
14
+ <version>3.8.0</version>
15
15
  <name>propane</name>
16
16
  <description>An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.</description>
17
17
  <url>https://github.com/monkstone/propane</url>
@@ -74,7 +74,7 @@ DO NOT MODIFIY - GENERATED CODE
74
74
  <dependency>
75
75
  <groupId>org.jruby</groupId>
76
76
  <artifactId>jruby</artifactId>
77
- <version>9.2.15.0</version>
77
+ <version>9.2.16.0</version>
78
78
  <type>pom</type>
79
79
  </dependency>
80
80
  <dependency>
data/propane.gemspec CHANGED
@@ -21,9 +21,11 @@ Gem::Specification.new do |gem|
21
21
  gem.files << 'lib/jogl-all.jar'
22
22
  gem.files << 'lib/gluegen-rt-natives-linux-amd64.jar'
23
23
  gem.files << 'lib/gluegen-rt-natives-macosx-universal.jar'
24
+ # gem.files << 'lib/gluegen-rt-natives-ios-arm64.jar'
24
25
  gem.files << 'lib/gluegen-rt-natives-windows-amd64.jar'
25
26
  gem.files << 'lib/jogl-all-natives-linux-amd64.jar'
26
27
  gem.files << 'lib/jogl-all-natives-macosx-universal.jar'
28
+ # gem.files << 'lib/jogl-all-natives-ios-arm64.jar'
27
29
  gem.files << 'lib/jogl-all-natives-windows-amd64.jar'
28
30
  gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
29
31
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -0,0 +1,111 @@
1
+ /*
2
+ * Copyright (c) 2021 Martin Prout
3
+ *
4
+ * This library is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU Lesser General Public
6
+ * License as published by the Free Software Foundation; either
7
+ * version 2.1 of the License, or (at your option) any later version.
8
+ *
9
+ * http://creativecommons.org/licenses/LGPL/2.1/
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
+ */
20
+ package monkstone.fastmath;
21
+
22
+ public final class DegLutTables {
23
+
24
+ /**
25
+ *
26
+ */
27
+ static public final float PI = 3.1415927f;
28
+
29
+ /**
30
+ *
31
+ */
32
+ static public final float PI2 = PI * 2;
33
+ static private final int SIN_BITS = 15; // 16KB. Adjust for accuracy.
34
+ static private final int SIN_MASK = ~(-1 << SIN_BITS);
35
+ static private final int SIN_COUNT = SIN_MASK + 1;
36
+
37
+ static private final float RAD_FULL = PI * 2;
38
+ static private final float DEG_FULL = 360;
39
+ static private final float RAD_TO_INDEX = SIN_COUNT / RAD_FULL;
40
+ static private final float DEG_TO_INDEX = SIN_COUNT / DEG_FULL;
41
+
42
+ /**
43
+ * multiply by this to convert from radians to degrees
44
+ */
45
+ static public final float RADIANS_TO_DEGREES = 180f / PI;
46
+
47
+ /**
48
+ *
49
+ */
50
+ static public final float RAD_DEG = RADIANS_TO_DEGREES;
51
+ /**
52
+ * multiply by this to convert from degrees to radians
53
+ */
54
+ static public final float DEGREES_TO_RADIANS = PI / 180;
55
+
56
+ /**
57
+ *
58
+ */
59
+ static public final float DEG_RAD = DEGREES_TO_RADIANS;
60
+
61
+ static private class Sin {
62
+
63
+ static final float[] table = new float[SIN_COUNT];
64
+
65
+ static {
66
+ for (int i = 0; i < SIN_COUNT; i++) {
67
+ table[i] = (float) Math.sin((i + 0.5f) / SIN_COUNT * RAD_FULL);
68
+ }
69
+ for (int i = 0; i < 360; i += 90) {
70
+ table[(int) (i * DEG_TO_INDEX) & SIN_MASK] = (float) Math.sin(i * DEGREES_TO_RADIANS);
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Returns the sine in radians from a lookup table.
77
+ * @param radians
78
+ * @return
79
+ */
80
+ static public final float sin(float radians) {
81
+ return Sin.table[(int) (radians * RAD_TO_INDEX) & SIN_MASK];
82
+ }
83
+
84
+ /**
85
+ * Returns the cosine in radians from a lookup table.
86
+ * @param radians
87
+ * @return
88
+ */
89
+ static public final float cos(float radians) {
90
+ return Sin.table[(int) ((radians + PI / 2) * RAD_TO_INDEX) & SIN_MASK];
91
+ }
92
+
93
+ /**
94
+ * Returns the sine in radians from a lookup table.
95
+ * @param degrees
96
+ * @return
97
+ */
98
+ static public final float sinDeg(float degrees) {
99
+ return Sin.table[(int) (degrees * DEG_TO_INDEX) & SIN_MASK];
100
+ }
101
+
102
+ /**
103
+ * Returns the cosine in radians from a lookup table.
104
+ * @param degrees
105
+ * @return
106
+ */
107
+ static public final float cosDeg(float degrees) {
108
+ return Sin.table[(int) ((degrees + 90) * DEG_TO_INDEX) & SIN_MASK];
109
+ }
110
+ }
111
+
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2015-20 Martin Prout
2
+ * Copyright (c) 2015-21 Martin Prout
3
3
  *
4
4
  * This library is free software; you can redistribute it and/or
5
5
  * modify it under the terms of the GNU Lesser General Public
@@ -20,7 +20,7 @@
20
20
  package monkstone.fastmath;
21
21
 
22
22
  import org.jruby.Ruby;
23
- import org.jruby.RubyInteger;
23
+ import org.jruby.RubyNumeric;
24
24
  import org.jruby.RubyModule;
25
25
  import org.jruby.anno.JRubyModule;
26
26
  import org.jruby.anno.JRubyMethod;
@@ -34,38 +34,6 @@ import org.jruby.runtime.builtin.IRubyObject;
34
34
  @JRubyModule(name = "DegLut")
35
35
  public class Deglut {
36
36
 
37
- /**
38
- * Lookup table for degree cosine/sine, has a fixed precision 1.0 degrees
39
- * Quite accurate but imprecise
40
- *
41
- * @author Martin Prout <martin_p@lineone.net>
42
- */
43
- static final double[] SIN_DEG_LUT = new double[91];
44
- /**
45
- *
46
- */
47
- public static final double TO_RADIANS = Math.PI / 180;
48
- /**
49
- *
50
- */
51
- private static boolean initialized = false;
52
-
53
- private final static int NINETY = 90;
54
- private final static int FULL = 360;
55
- private static final long serialVersionUID = -1466528933765940101L;
56
-
57
- /**
58
- * Initialize sin table with values (first quadrant only)
59
- */
60
- public static final void initTable() {
61
- if (initialized == false) {
62
- for (int i = 0; i <= NINETY; i++) {
63
- SIN_DEG_LUT[i] = Math.sin(TO_RADIANS * i);
64
- }
65
- initialized = true;
66
- }
67
- }
68
-
69
37
  /**
70
38
  *
71
39
  * @param runtime Ruby
@@ -73,7 +41,6 @@ public class Deglut {
73
41
  public static void createDeglut(final Ruby runtime) {
74
42
  RubyModule deglutModule = runtime.defineModule("DegLut");
75
43
  deglutModule.defineAnnotatedMethods(Deglut.class);
76
- Deglut.initTable();
77
44
  }
78
45
 
79
46
  /**
@@ -84,18 +51,9 @@ public class Deglut {
84
51
  * @return sin IRubyObject
85
52
  */
86
53
  @JRubyMethod(name = "sin", module = true)
87
-
88
54
  public static IRubyObject sin(ThreadContext context, IRubyObject recv, IRubyObject other) {
89
- int thet = (int) ((RubyInteger) other).getLongValue();
90
- while (thet < 0) {
91
- thet += FULL; // Needed because negative modulus plays badly in java
92
- }
93
- int theta = thet % FULL;
94
- int y = theta % NINETY;
95
- double result = (theta < NINETY) ? SIN_DEG_LUT[y] : (theta < 180)
96
- ? SIN_DEG_LUT[NINETY - y] : (theta < 270)
97
- ? -SIN_DEG_LUT[y] : -SIN_DEG_LUT[NINETY - y];
98
- return context.runtime.newFloat(result);
55
+ float thet = (float) ((RubyNumeric) other).getLongValue();
56
+ return context.runtime.newFloat(DegLutTables.sinDeg(thet));
99
57
  }
100
58
 
101
59
  /**
@@ -107,15 +65,7 @@ public class Deglut {
107
65
  */
108
66
  @JRubyMethod(name = "cos", module = true)
109
67
  public static IRubyObject cos(ThreadContext context, IRubyObject recv, IRubyObject other) {
110
- int thet = (int) ((RubyInteger) other).getLongValue();
111
- while (thet < 0) {
112
- thet += FULL; // Needed because negative modulus plays badly in java
113
- }
114
- int theta = thet % FULL;
115
- int y = theta % NINETY;
116
- double result = (theta < NINETY) ? SIN_DEG_LUT[NINETY - y] : (theta < 180)
117
- ? -SIN_DEG_LUT[y] : (theta < 270)
118
- ? -SIN_DEG_LUT[NINETY - y] : SIN_DEG_LUT[y];
119
- return context.runtime.newFloat(result);
68
+ float thet = (float) ((RubyNumeric) other).getLongValue();
69
+ return context.runtime.newFloat(DegLutTables.cosDeg(thet));
120
70
  }
121
71
  }
@@ -0,0 +1,116 @@
1
+ package monkstone.noise;
2
+
3
+ /*
4
+ * Copyright (c) 2021 Martin Prout
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU General Public
8
+ * License as published by the Free Software Foundation; either
9
+ * version 3.0 of the License, or (at your option) any later version.
10
+ *
11
+ * http://creativecommons.org/licenses/LGPL/2.1/
12
+ *
13
+ * This library is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
+ * Lesser General Public License for more details.
17
+ *
18
+ * You should have received a copy of the GNU General Public
19
+ * License along with this library; if not, write to the Free Software
20
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
+ */
22
+ public interface Noise {
23
+
24
+ /**
25
+ *
26
+ * @param x
27
+ * @return
28
+ */
29
+ default float noise(float x) {
30
+ return noise(x, 0);
31
+ }
32
+
33
+ /**
34
+ *
35
+ * @param x
36
+ * @param y
37
+ * @return
38
+ */
39
+ default float noise(float x, float y) {
40
+ return noise(x, y, 0);
41
+ }
42
+
43
+ /**
44
+ * <p>
45
+ * Returns the Perlin noise value at specified coordinates. Perlin noise is
46
+ * a random sequence generator producing a more natural ordered, harmonic
47
+ * succession of numbers compared to the standard <b>random()</b> function.
48
+ * It was invented by Ken Perlin in the 1980s and been used since in
49
+ * graphical applications to produce procedural textures, natural motion,
50
+ * shapes, terrains etc. The main difference to the
51
+ * <b>random()</b> function is that Perlin noise is defined in an infinite
52
+ * n-dimensional space where each pair of coordinates corresponds to a fixed
53
+ * semi-random value (fixed only for the lifespan of the program). The
54
+ * resulting value will always be between 0.0 and 1.0. Processing can
55
+ * compute 1D, 2D and 3D noise, depending on the number of coordinates
56
+ * given. The noise value can be animated by moving through the noise space
57
+ * as demonstrated in the example above. The 2nd and 3rd dimension can also
58
+ * be interpreted as time.The actual noise is structured similar to an audio
59
+ * signal, in respect to the function's use of frequencies. Similar to the
60
+ * concept of harmonics in physics, perlin noise is computed over several
61
+ * octaves which are added together for the final result. Another way to
62
+ * adjust the character of the resulting sequence is the scale of the input
63
+ * coordinates. As the function works within an infinite space the value of
64
+ * the coordinates doesn't matter as such, only the distance between
65
+ * successive coordinates does (eg. when using <b>noise()</b> within a
66
+ * loop). As a general rule the smaller the difference between coordinates,
67
+ * the smoother the resulting noise sequence will be. Steps of 0.005-0.03
68
+ * work best for most applications, but this will differ depending on use.
69
+ * <p>
70
+ * @param x x-coordinate in noise space
71
+ * @param y y-coordinate in noise space
72
+ * @param z z-coordinate in noise space
73
+ * @return
74
+ */
75
+ float noise(float x, float y, float z);
76
+
77
+ float noise(float x, float y, float z, float w);
78
+
79
+ void noiseMode(NoiseMode mode);
80
+
81
+ /**
82
+ * Adjusts the character and level of detail produced by the Perlin noise
83
+ * function.Similar to harmonics in physics, noise is computed over several
84
+ * octaves. Lower octaves contribute more to the output signal and as such
85
+ * define the overal intensity of the noise, whereas higher octaves create
86
+ * finer grained details in the noise sequence. By default, noise is
87
+ * computed over 4 octaves with each octave contributing exactly half than
88
+ * its predecessor, starting at 50% strength for the 1st octave. This
89
+ * falloff amount can be changed by adding an additional function parameter.
90
+ * Eg. a falloff factor of 0.75 means each octave will now have 75% impact
91
+ * (25% less) of the previous lower octave. Any value between 0.0 and 1.0 is
92
+ * valid, however note that values greater than 0.5 might result in greater
93
+ * than 1.0 values returned by <b>noise()</b>.By changing these parameters,
94
+ * the signal created by the <b>noise()</b>
95
+ * function can be adapted to fit very specific needs and characteristics.
96
+ *
97
+ * @param lod
98
+ */
99
+ void noiseDetail(int lod);
100
+
101
+ /**
102
+ * @param lod
103
+ * @param falloff falloff factor for each octave
104
+ */
105
+ void noiseDetail(int lod, float falloff);
106
+
107
+ /**
108
+ * Sets the seed value for <b>noise()</b>.By default, <b>noise()</b>
109
+ * produces different results each time the program is run. Set the
110
+ * <b>value</b> parameter to a constant to return the same pseudo-random
111
+ * numbers each time the software is run.
112
+ *
113
+ * @param seed
114
+ */
115
+ void noiseSeed(long seed);
116
+ }