picrate 1.3.0-java → 2.1.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
  3. data/CHANGELOG.md +10 -1
  4. data/Gemfile +3 -1
  5. data/README.md +9 -6
  6. data/Rakefile +8 -3
  7. data/bin/picrate +3 -1
  8. data/docs/_config.yml +1 -1
  9. data/docs/_editors/geany.md +1 -0
  10. data/docs/_gems/gems/gems.md +1 -1
  11. data/docs/_methods/alternative_methods.md +2 -1
  12. data/docs/_posts/2018-05-06-getting_started.md +4 -4
  13. data/docs/_posts/2018-05-06-install_jruby.md +5 -11
  14. data/docs/_posts/2018-05-11-arch-linux-arm.md +1 -11
  15. data/docs/_posts/2018-11-18-building-gem.md +2 -2
  16. data/docs/_posts/2018-11-27-getting_started_geany.md +1 -1
  17. data/docs/_posts/2019-11-11-getting_started_buster.md +3 -6
  18. data/docs/_posts/{2018-06-26-auto_install_picrate.md → 2020-03-09-auto_install_picrate.md} +9 -6
  19. data/docs/_posts/2020-05-11-getting_started_manjaro.md +106 -0
  20. data/docs/about.md +1 -1
  21. data/lib/picrate.rb +3 -2
  22. data/lib/picrate/app.rb +11 -3
  23. data/lib/picrate/creators/parameters.rb +8 -8
  24. data/lib/picrate/creators/sketch_factory.rb +5 -3
  25. data/lib/picrate/helper_methods.rb +22 -22
  26. data/lib/picrate/helpers/numeric.rb +2 -0
  27. data/lib/picrate/library.rb +5 -1
  28. data/lib/picrate/library_loader.rb +2 -0
  29. data/lib/picrate/native_folder.rb +2 -1
  30. data/lib/picrate/native_loader.rb +3 -0
  31. data/lib/picrate/runner.rb +5 -4
  32. data/lib/picrate/version.rb +1 -1
  33. data/library/boids/boids.rb +17 -8
  34. data/library/chooser/chooser.rb +10 -9
  35. data/library/color_group/color_group.rb +2 -0
  36. data/library/control_panel/control_panel.rb +7 -4
  37. data/library/dxf/dxf.rb +2 -0
  38. data/library/jcomplex/jcomplex.rb +1 -0
  39. data/library/library_proxy/library_proxy.rb +2 -0
  40. data/library/net/net.rb +2 -0
  41. data/library/slider/slider.rb +24 -23
  42. data/library/vector_utils/vector_utils.rb +4 -0
  43. data/library/video_event/video_event.rb +2 -0
  44. data/mvnw +2 -2
  45. data/mvnw.cmd +2 -2
  46. data/picrate.gemspec +13 -13
  47. data/pom.rb +26 -23
  48. data/pom.xml +19 -7
  49. data/src/main/java/monkstone/ColorUtil.java +1 -1
  50. data/src/main/java/monkstone/MathToolModule.java +1 -1
  51. data/src/main/java/monkstone/PicrateLibrary.java +8 -8
  52. data/src/main/java/monkstone/complex/JComplex.java +252 -0
  53. data/src/main/java/monkstone/fastmath/Deglut.java +16 -16
  54. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  55. data/src/main/java/monkstone/noise/SimplexNoise.java +3 -3
  56. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
  57. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  58. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +12 -12
  59. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
  60. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  61. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  62. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  63. data/src/main/java/monkstone/vecmath/package-info.java +1 -1
  64. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
  65. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
  66. data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
  67. data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
  68. data/src/main/java/monkstone/videoevent/package-info.java +1 -1
  69. data/src/main/java/processing/awt/PGraphicsJava2D.java +33 -36
  70. data/src/main/java/processing/awt/PImageAWT.java +377 -0
  71. data/src/main/java/processing/awt/PSurfaceAWT.java +0 -20
  72. data/src/main/java/processing/awt/ShimAWT.java +545 -0
  73. data/src/main/java/processing/core/PApplet.java +699 -1523
  74. data/src/main/java/processing/core/PConstants.java +180 -180
  75. data/src/main/java/processing/core/PFont.java +2 -2
  76. data/src/main/java/processing/core/PGraphics.java +190 -176
  77. data/src/main/java/processing/core/PImage.java +1536 -1721
  78. data/src/main/java/processing/core/PMatrix.java +39 -39
  79. data/src/main/java/processing/core/PSurface.java +69 -103
  80. data/src/main/java/processing/core/PSurfaceNone.java +29 -0
  81. data/src/main/java/processing/core/PVector.java +2 -2
  82. data/src/main/java/processing/data/FloatDict.java +251 -284
  83. data/src/main/java/processing/data/TableRow.java +32 -32
  84. data/src/main/java/processing/dxf/RawDXF.java +3 -3
  85. data/src/main/java/processing/net/Client.java +1 -1
  86. data/src/main/java/processing/opengl/PGL.java +1016 -4132
  87. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +232 -176
  88. data/src/main/java/processing/opengl/PJOGL.java +374 -1526
  89. data/src/main/java/processing/opengl/PShapeOpenGL.java +5 -6
  90. data/src/main/java/processing/opengl/PSurfaceJOGL.java +262 -147
  91. data/test/color_group_test.rb +4 -4
  92. data/test/deglut_spec_test.rb +2 -0
  93. data/test/helper_methods_test.rb +41 -13
  94. data/test/math_tool_test.rb +46 -37
  95. data/test/respond_to_test.rb +5 -3
  96. data/test/sketches/key_event.rb +2 -2
  97. data/test/sketches/library/my_library/my_library.rb +3 -0
  98. data/test/test_helper.rb +2 -0
  99. data/test/vecmath_spec_test.rb +30 -19
  100. data/vendors/Rakefile +33 -21
  101. data/vendors/{picrate_sketches.geany → geany.rb} +32 -7
  102. metadata +27 -46
  103. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
  104. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
  105. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
  106. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -0,0 +1,252 @@
1
+ package monkstone.complex;
2
+
3
+ import java.util.Objects;
4
+
5
+ /**
6
+ * The purpose of this class is to to make Complex operations more efficient
7
+ * than JRuby RubyComplex, by having a simpler interface, only modest
8
+ * improvements were obtained (but this is better than nothing on RaspberryPI).
9
+ */
10
+ public final class JComplex {
11
+
12
+ private final double re; // the real part
13
+ private final double im; // the imaginary part
14
+ private final static JComplex ZERO = new JComplex(0, 0);
15
+ private final static JComplex NAN = new JComplex(Double.NaN, Double.NaN);
16
+
17
+ /**
18
+ * create a new object with the given real and imaginary parts
19
+ *
20
+ * @param real
21
+ * @param imag
22
+ */
23
+ public JComplex(double real, double imag) {
24
+ re = real;
25
+ im = imag;
26
+ }
27
+
28
+ /**
29
+ * @return a string representation of the invoking Complex object
30
+ */
31
+ @Override
32
+ public String toString() {
33
+ return "JComplex(" + re + ", " + im + "i)";
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @return abs/modulus/magnitude
39
+ */
40
+ public final double abs() {
41
+ return Math.hypot(re, im);
42
+ }
43
+
44
+ /**
45
+ *
46
+ * @return square of abs/modulus/magnitude
47
+ */
48
+ public final double abs2() {
49
+ return re * re + im * im;
50
+ }
51
+
52
+ /**
53
+ *
54
+ * @return angle/phase/argument, normalized to be between -pi and pi
55
+ */
56
+ public final double phase() {
57
+ return Math.atan2(im, re);
58
+ }
59
+
60
+ /**
61
+ *
62
+ * @param b
63
+ * @return a new Complex object whose value is (this + b)
64
+ */
65
+ public final JComplex add(JComplex b) {
66
+ JComplex a = this; // invoking object
67
+ double real = a.re + b.re;
68
+ double imag = a.im + b.im;
69
+ return new JComplex(real, imag);
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @param scalar
75
+ * @return a new Complex object whose value is (this + scalar)
76
+ */
77
+ public final JComplex add(double scalar) {
78
+ return new JComplex(re + scalar, im);
79
+ }
80
+
81
+ public final boolean zero() {
82
+ return this.equals(ZERO);
83
+ }
84
+
85
+ /**
86
+ *
87
+ * @param b
88
+ * @return a new Complex object whose value is (this - b)
89
+ */
90
+ public final JComplex sub(JComplex b) {
91
+ JComplex a = this;
92
+ double real = a.re - b.re;
93
+ double imag = a.im - b.im;
94
+ return new JComplex(real, imag);
95
+ }
96
+
97
+ /**
98
+ *
99
+ * @param scalar
100
+ * @return a new Complex object whose value is (this - scalar)
101
+ */
102
+ public final JComplex sub(double scalar) {
103
+ return new JComplex(re - scalar, im);
104
+ }
105
+
106
+ /**
107
+ *
108
+ * @param b
109
+ * @return a new Complex object whose value is (this * b)
110
+ */
111
+ public final JComplex mul(JComplex b) {
112
+ JComplex a = this;
113
+ double real = a.re * b.re - a.im * b.im;
114
+ double imag = a.re * b.im + a.im * b.re;
115
+ return new JComplex(real, imag);
116
+ }
117
+
118
+ /**
119
+ * Also known as scale
120
+ *
121
+ * @param b
122
+ * @return a new Complex object whose value is (this * b)
123
+ */
124
+ public final JComplex mul(double b) {
125
+ return new JComplex(re * b, im * b);
126
+ }
127
+
128
+ /**
129
+ *
130
+ * @return a new Complex object whose value is the conjugate of this
131
+ */
132
+ public final JComplex conjugate() {
133
+ return new JComplex(re, -im);
134
+ }
135
+
136
+ /**
137
+ *
138
+ * @return a new Complex object whose value is the reciprocal of this
139
+ */
140
+ private JComplex reciprocal() {
141
+ double scale = re * re + im * im; // self dot product
142
+ return new JComplex(re / scale, -im / scale);
143
+ }
144
+
145
+ /**
146
+ *
147
+ * @param other
148
+ * @return this^other
149
+ */
150
+ public final JComplex pow(JComplex other) {
151
+ if (this.zero()) {
152
+ if (other.zero()) {
153
+ return ZERO;
154
+ }
155
+ return NAN;
156
+ }
157
+ return (this).log().mul(other).exp();
158
+ }
159
+
160
+ /**
161
+ *
162
+ * @param scalar
163
+ * @return this^scalar
164
+ */
165
+ public final JComplex pow(double scalar) {
166
+ if (this.zero()) {
167
+ if (scalar == 0) {
168
+ return ZERO;
169
+ }
170
+ return NAN;
171
+ }
172
+ return (this).log().mul(scalar).exp();
173
+ }
174
+
175
+ /**
176
+ *
177
+ * @return log
178
+ */
179
+ private JComplex log() {
180
+ return new JComplex(Math.log(abs()), Math.atan2(im, re));
181
+ }
182
+
183
+ /**
184
+ *
185
+ * @return real part
186
+ */
187
+ public final double re() {
188
+ return re;
189
+ }
190
+
191
+ /**
192
+ *
193
+ * @return imaginary part
194
+ */
195
+ public final double im() {
196
+ return im;
197
+ }
198
+
199
+ /**
200
+ *
201
+ * @param b
202
+ * @return a / b
203
+ */
204
+ public final JComplex div(JComplex b) {
205
+ JComplex a = this;
206
+ return a.mul(b.reciprocal());
207
+ }
208
+
209
+ /**
210
+ *
211
+ * @param b
212
+ * @return a / b
213
+ */
214
+ public final JComplex div(double b) {
215
+ if (b == 0) {
216
+ return NAN;
217
+ }
218
+ return new JComplex(re / b, im / b);
219
+ }
220
+
221
+ /**
222
+ *
223
+ * @return a new Complex object whose value is the complex exponential of
224
+ * this
225
+ */
226
+ public final JComplex exp() {
227
+ return new JComplex(Math.exp(re) * Math.cos(im), Math.exp(re) * Math.sin(im));
228
+ }
229
+
230
+ @Override
231
+ public final int hashCode() {
232
+ return Objects.hash(re, im);
233
+ }
234
+
235
+ @Override
236
+ public final boolean equals(Object obj) {
237
+ if (this == obj) {
238
+ return true;
239
+ }
240
+ if (obj == null) {
241
+ return false;
242
+ }
243
+ if (getClass() != obj.getClass()) {
244
+ return false;
245
+ }
246
+ final JComplex other = (JComplex) obj;
247
+ if (Double.doubleToLongBits(this.re) != Double.doubleToLongBits(other.re)) {
248
+ return false;
249
+ }
250
+ return Double.doubleToLongBits(this.im) == Double.doubleToLongBits(other.im);
251
+ }
252
+ }
@@ -1,18 +1,18 @@
1
- /*
2
- * Copyright (c) 2018-19 Martin Prout
3
- *
1
+ /*
2
+ * Copyright (c) 2018-20 Martin Prout
3
+ *
4
4
  * This library is free software; you can redistribute it and/or
5
5
  * modify it under the terms of the GNU General Public
6
6
  * License as published by the Free Software Foundation; either
7
7
  * version 3.0 of the License, or (at your option) any later version.
8
- *
8
+ *
9
9
  * http://creativecommons.org/licenses/LGPL/2.1/
10
- *
10
+ *
11
11
  * This library is distributed in the hope that it will be useful,
12
12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
14
  * Lesser General Public License for more details.
15
- *
15
+ *
16
16
  * You should have received a copy of the GNU General Public
17
17
  * License along with this library; if not, write to the Free Software
18
18
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -35,7 +35,7 @@ import org.jruby.runtime.builtin.IRubyObject;
35
35
  */
36
36
  @JRubyModule(name = "DegLut")
37
37
  public class Deglut {
38
-
38
+
39
39
  /**
40
40
  * Lookup table for degree cosine/sine, has a fixed precision 1.0
41
41
  * degrees Quite accurate but imprecise
@@ -49,11 +49,11 @@ public class Deglut {
49
49
  *
50
50
  */
51
51
  private static boolean initialized = false;
52
-
52
+
53
53
  private final static int NINETY = 90;
54
54
  private final static int FULL = 360;
55
55
  private static final long serialVersionUID = -1466528933765940101L;
56
-
56
+
57
57
  /**
58
58
  * Initialize sin table with values (first quadrant only)
59
59
  */
@@ -65,19 +65,19 @@ public class Deglut {
65
65
  initialized = true;
66
66
  }
67
67
  }
68
-
68
+
69
69
  /**
70
70
  *
71
71
  * @param runtime Ruby
72
72
  */
73
-
73
+
74
74
  public static void createDeglut(final Ruby runtime){
75
75
  RubyModule deglutModule = runtime.defineModule("DegLut");
76
76
  deglutModule.defineAnnotatedMethods(Deglut.class);
77
77
  Deglut.initTable();
78
78
  }
79
-
80
-
79
+
80
+
81
81
  /**
82
82
  *
83
83
  * @param context ThreadContext
@@ -86,7 +86,7 @@ public class Deglut {
86
86
  * @return sin IRubyObject
87
87
  */
88
88
  @JRubyMethod(name = "sin", module = true)
89
-
89
+
90
90
  public static IRubyObject sin(ThreadContext context, IRubyObject recv, IRubyObject other) {
91
91
  int thet = (int) ((RubyInteger)other).getLongValue();
92
92
  while (thet < 0) {
@@ -99,7 +99,7 @@ public class Deglut {
99
99
  ? -SIN_DEG_LUT[y] : -SIN_DEG_LUT[NINETY - y];
100
100
  return context.runtime.newFloat(result);
101
101
  }
102
-
102
+
103
103
  /**
104
104
  *
105
105
  * @param context ThreadContext
@@ -119,5 +119,5 @@ public class Deglut {
119
119
  ? -SIN_DEG_LUT[y] : (theta < 270)
120
120
  ? -SIN_DEG_LUT[NINETY - y] : SIN_DEG_LUT[y];
121
121
  return context.runtime.newFloat(result);
122
- }
122
+ }
123
123
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-18 Martin Prout
2
+ * Copyright (c) 2016-20 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 General Public
@@ -36,7 +36,7 @@ public class SimplexNoise { // Simplex noise in 2D, 3D and 4D
36
36
  new Grad(1, 1, 1, 0), new Grad(1, 1, -1, 0), new Grad(1, -1, 1, 0), new Grad(1, -1, -1, 0),
37
37
  new Grad(-1, 1, 1, 0), new Grad(-1, 1, -1, 0), new Grad(-1, -1, 1, 0), new Grad(-1, -1, -1, 0)};
38
38
 
39
- private static short p[] = {151, 160, 137, 91, 90, 15,
39
+ private final static short PERMS[] = {151, 160, 137, 91, 90, 15,
40
40
  131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,
41
41
  190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,
42
42
  88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,
@@ -51,11 +51,11 @@ public class SimplexNoise { // Simplex noise in 2D, 3D and 4D
51
51
  138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180};
52
52
  // To remove the need for index wrapping, double the permutation table length
53
53
  static final short[] PERM = new short[512];
54
- static short[] PERM_MOD_12 = new short[512];
54
+ static final short[] PERM_MOD_12 = new short[512];
55
55
 
56
56
  static {
57
57
  for (int i = 0; i < 512; i++) {
58
- PERM[i] = p[i & 255];
58
+ PERM[i] = PERMS[i & 255];
59
59
  PERM_MOD_12[i] = (short) (PERM[i] % 12);
60
60
  }
61
61
  }
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-18 Martin Prout
2
+ * Copyright (c) 2016-20 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 General Public
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2016-18 Martin Prout
2
+ * Copyright (c) 2016-20 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 General Public
@@ -1,18 +1,18 @@
1
- /*
2
- * Copyright (c) 2016-18 Martin Prout
3
- *
1
+ /*
2
+ * Copyright (c) 2016-20 Martin Prout
3
+ *
4
4
  * This library is free software; you can redistribute it and/or
5
5
  * modify it under the terms of the GNU General Public
6
6
  * License as published by the Free Software Foundation; either
7
7
  * version 3.0 of the License, or (at your option) any later version.
8
- *
8
+ *
9
9
  * http://creativecommons.org/licenses/LGPL/2.1/
10
- *
10
+ *
11
11
  * This library is distributed in the hope that it will be useful,
12
12
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
14
  * Lesser General Public License for more details.
15
- *
15
+ *
16
16
  * You should have received a copy of the GNU General Public
17
17
  * License along with this library; if not, write to the Free Software
18
18
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
@@ -27,10 +27,10 @@ import processing.core.PConstants;
27
27
  * @author Martin Prout
28
28
  */
29
29
  public class SimpleHorizontalSlider extends SimpleSlider {
30
-
30
+
31
31
  final int SPACING = 20;
32
32
  final int LEFT_SPC = SPACING * 2;
33
- final int RIGHT_SPC = SPACING * 4;
33
+ final int RIGHT_SPC = SPACING * 4;
34
34
 
35
35
  /**
36
36
  *
@@ -62,7 +62,7 @@ public class SimpleHorizontalSlider extends SimpleSlider {
62
62
  applet.registerMethod("dispose", this);
63
63
  applet.registerMethod("draw", this);
64
64
  } else {
65
- applet.unregisterMethod("draw", this);
65
+ applet.unregisterMethod("draw", this);
66
66
  }
67
67
  }
68
68
 
@@ -84,7 +84,7 @@ public class SimpleHorizontalSlider extends SimpleSlider {
84
84
  applet.text(String.format(lFormat, (int) vMax), pX + pW, pY );
85
85
  }
86
86
  }
87
-
87
+
88
88
  @Override
89
89
  void drawGui() {
90
90
  if (backgroundVisible) {
@@ -94,7 +94,7 @@ public class SimpleHorizontalSlider extends SimpleSlider {
94
94
  applet.noStroke();
95
95
  applet.fill(255);
96
96
  applet.ellipse(pX + pScaled, pY + pH / 2, 10, 10);
97
- }
97
+ }
98
98
 
99
99
  /**
100
100
  *
@@ -136,7 +136,7 @@ public class SimpleHorizontalSlider extends SimpleSlider {
136
136
  pScaled = map(pValue, vMin, vMax, 0, pW);
137
137
  }
138
138
  }
139
-
139
+
140
140
  /**
141
141
  *
142
142
  * @return