picrate 2.4.1-java → 2.5.2-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  3. data/CHANGELOG.md +9 -1
  4. data/Gemfile +1 -1
  5. data/README.md +2 -2
  6. data/Rakefile +1 -1
  7. data/docs/.gitignore +1 -0
  8. data/docs/_classes/{app_render → gfx_render}/app_render.md +5 -5
  9. data/docs/_classes/vec2d/vec2d.md +2 -2
  10. data/docs/_methods/{noise_mode.md → noise_modes.md} +9 -21
  11. data/docs/_posts/2018-05-06-install_jruby.md +5 -5
  12. data/docs/_posts/2019-11-11-getting_started_buster.md +2 -2
  13. data/docs/_posts/2020-05-11-getting_started_manjaro.md +13 -4
  14. data/docs/about.md +1 -1
  15. data/lib/picrate/app.rb +2 -8
  16. data/lib/picrate/helper_methods.rb +6 -6
  17. data/lib/picrate/version.rb +1 -1
  18. data/lib/picrate-2.5.2.jar +0 -0
  19. data/picrate.gemspec +1 -1
  20. data/pom.rb +4 -4
  21. data/pom.xml +6 -9
  22. data/src/main/java/monkstone/vecmath/GfxRender.java +10 -11
  23. data/src/main/java/monkstone/vecmath/JRender.java +7 -7
  24. data/src/main/java/monkstone/vecmath/ShapeRender.java +3 -4
  25. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +40 -43
  26. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +30 -45
  27. data/src/main/java/processing/awt/PImageAWT.java +1 -1
  28. data/src/main/java/processing/awt/ShimAWT.java +1 -1
  29. data/src/main/java/processing/core/PApplet.java +1 -1
  30. data/src/main/java/processing/core/PImage.java +14 -14
  31. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -13
  32. data/src/main/java/processing/opengl/PShader.java +0 -6
  33. data/src/main/java/processing/opengl/PSurfaceJOGL.java +4 -4
  34. data/src/main/{java/processing/opengl → resources}/cursors/arrow.png +0 -0
  35. data/src/main/{java/processing/opengl → resources}/cursors/cross.png +0 -0
  36. data/src/main/{java/processing/opengl → resources}/cursors/hand.png +0 -0
  37. data/src/main/{java/processing/opengl → resources}/cursors/license.txt +0 -0
  38. data/src/main/{java/processing/opengl → resources}/cursors/move.png +0 -0
  39. data/src/main/{java/processing/opengl → resources}/cursors/text.png +0 -0
  40. data/src/main/{java/processing/opengl → resources}/cursors/wait.png +0 -0
  41. data/src/main/{java/processing/opengl → resources}/shaders/ColorFrag.glsl +0 -0
  42. data/src/main/{java/processing/opengl → resources}/shaders/ColorVert.glsl +0 -0
  43. data/src/main/{java/processing/opengl → resources}/shaders/LightFrag.glsl +0 -0
  44. data/src/main/{java/processing/opengl → resources}/shaders/LightVert.glsl +0 -0
  45. data/src/main/{java/processing/opengl → resources}/shaders/LineFrag.glsl +0 -0
  46. data/src/main/{java/processing/opengl → resources}/shaders/LineVert.glsl +0 -0
  47. data/src/main/{java/processing/opengl → resources}/shaders/MaskFrag.glsl +0 -0
  48. data/src/main/{java/processing/opengl → resources}/shaders/PointFrag.glsl +0 -0
  49. data/src/main/{java/processing/opengl → resources}/shaders/PointVert.glsl +0 -0
  50. data/src/main/{java/processing/opengl → resources}/shaders/TexFrag.glsl +0 -0
  51. data/src/main/{java/processing/opengl → resources}/shaders/TexLightFrag.glsl +0 -0
  52. data/src/main/{java/processing/opengl → resources}/shaders/TexLightVert.glsl +0 -0
  53. data/src/main/{java/processing/opengl → resources}/shaders/TexVert.glsl +0 -0
  54. data/test/noise_test.rb +17 -0
  55. data/test/test_helper.rb +1 -1
  56. data/test/vecmath_spec_test.rb +3 -3
  57. data/vendors/Rakefile +1 -1
  58. metadata +30 -41
  59. data/lib/picrate-2.4.1.jar +0 -0
  60. data/src/main/java/japplemenubar/JAppleMenuBar.java +0 -96
  61. data/src/main/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  62. data/src/main/java/monkstone/complex/JComplex.java +0 -252
  63. data/src/main/java/monkstone/vecmath/AppRender.java +0 -88
  64. data/src/main/java/monkstone/vecmath/package-info.java +0 -20
  65. data/src/main/java/monkstone/vecmath/vec2/package-info.java +0 -6
  66. data/src/main/java/monkstone/vecmath/vec3/package-info.java +0 -6
@@ -20,7 +20,8 @@ package monkstone.vecmath.vec2;
20
20
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
21
  *
22
22
  * fastAtan2 algorithm from https://github.com/libgdx/libgdx (Apache 2.0 license)
23
- */
23
+ */
24
+ import java.util.logging.Logger;
24
25
  import org.jruby.Ruby;
25
26
  import org.jruby.RubyArray;
26
27
  import org.jruby.RubyClass;
@@ -40,7 +41,7 @@ import monkstone.vecmath.JRender;
40
41
  * @author Martin Prout
41
42
  */
42
43
  @JRubyClass(name = "Vec2D")
43
- public class Vec2 extends RubyObject {
44
+ public final class Vec2 extends RubyObject {
44
45
 
45
46
  static final double EPSILON = 9.999999747378752e-05; // matches processing.org EPSILON
46
47
  private static final long serialVersionUID = -2950154560223211646L;
@@ -57,18 +58,10 @@ public class Vec2 extends RubyObject {
57
58
  vec2Cls.defineAnnotatedMethods(Vec2.class);
58
59
  }
59
60
 
60
- /**
61
- *
62
- * @return x value :double
63
- */
64
61
  public double javax() {
65
62
  return jx;
66
63
  }
67
64
 
68
- /**
69
- *
70
- * @return y value :double
71
- */
72
65
  public double javay() {
73
66
  return jy;
74
67
  }
@@ -81,7 +74,7 @@ public class Vec2 extends RubyObject {
81
74
  * @return new Vec2 object (ruby)
82
75
  */
83
76
  @JRubyMethod(name = "new", meta = true, rest = true)
84
- public static final IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject... args) {
77
+ public static IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject... args) {
85
78
  Vec2 vec2 = (Vec2) ((RubyClass) klazz).allocate();
86
79
  vec2.init(context, args);
87
80
  return vec2;
@@ -99,16 +92,16 @@ public class Vec2 extends RubyObject {
99
92
  void init(ThreadContext context, IRubyObject... args) {
100
93
  int count = args.length;
101
94
  if (count == 2) {
102
- jx = (args[0] instanceof RubyFloat) ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
103
- jy = (args[1] instanceof RubyFloat) ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
95
+ jx = args[0] instanceof RubyFloat ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
96
+ jy = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
104
97
  } // allow ruby ducktyping in constructor
105
98
  if (count == 1) {
106
99
  if (!(args[0].respondsTo("x"))) {
107
100
  throw context.runtime.newTypeError(args[0].getType() + " doesn't respond_to :x & :y");
108
101
  }
109
- jx = ((args[0].callMethod(context, "x")) instanceof RubyFloat)
102
+ jx = args[0].callMethod(context, "x") instanceof RubyFloat
110
103
  ? ((RubyFloat) args[0].callMethod(context, "x")).getValue() : ((RubyFixnum) args[0].callMethod(context, "x")).getDoubleValue();
111
- jy = ((args[0].callMethod(context, "y")) instanceof RubyFloat)
104
+ jy = args[0].callMethod(context, "y") instanceof RubyFloat
112
105
  ? ((RubyFloat) args[0].callMethod(context, "y")).getValue() : ((RubyFixnum) args[0].callMethod(context, "y")).getDoubleValue();
113
106
  }
114
107
  }
@@ -170,10 +163,10 @@ public class Vec2 extends RubyObject {
170
163
  Ruby runtime = context.runtime;
171
164
  if (key instanceof RubySymbol) {
172
165
  if (key == RubySymbol.newSymbol(runtime, "x")) {
173
- jx = (value instanceof RubyFloat)
166
+ jx = value instanceof RubyFloat
174
167
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
175
168
  } else if (key == RubySymbol.newSymbol(runtime, "y")) {
176
- jy = (value instanceof RubyFloat)
169
+ jy = value instanceof RubyFloat
177
170
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
178
171
  }
179
172
  } else {
@@ -232,23 +225,31 @@ public class Vec2 extends RubyObject {
232
225
  } else {
233
226
  throw runtime.newTypeError("argument should be Vec2D");
234
227
  }
235
- double result = Math.hypot((jx - b.jx), (jy - b.jy));
228
+ double result = Math.hypot(jx - b.jx, jy - b.jy);
236
229
  return runtime.newFloat(result);
237
230
  }
238
231
 
232
+ @Deprecated
233
+ @JRubyMethod(name = "cross", required = 1)
234
+ public IRubyObject cross(ThreadContext context, IRubyObject other) {
235
+ Logger log = Logger.getGlobal();
236
+ log.warning("prefer ^ operator");
237
+ return op_wedge(context, other);
238
+ }
239
+
239
240
  /**
240
241
  *
241
242
  * @param context ThreadContext
242
243
  * @param other IRubyObject
243
- * @return cross product IRubyObject
244
+ * @return wedge product IRubyObject
244
245
  */
245
- @JRubyMethod(name = "cross", required = 1)
246
+ @JRubyMethod(name = "^", required = 1)
246
247
 
247
- public IRubyObject cross(ThreadContext context, IRubyObject other) {
248
+ public IRubyObject op_wedge(ThreadContext context, IRubyObject other) {
248
249
  Vec2 b = null;
249
250
  Ruby runtime = context.runtime;
250
251
  if (other instanceof Vec2) {
251
- b = (Vec2) other.toJava(Vec2.class);
252
+ b = other.toJava(Vec2.class);
252
253
  } else {
253
254
  throw runtime.newTypeError("argument should be Vec2D");
254
255
  }
@@ -326,7 +327,7 @@ public class Vec2 extends RubyObject {
326
327
 
327
328
  public IRubyObject op_mul(ThreadContext context, IRubyObject other) {
328
329
  Ruby runtime = context.runtime;
329
- double scalar = (other instanceof RubyFloat)
330
+ double scalar = other instanceof RubyFloat
330
331
  ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
331
332
  return Vec2.rbNew(context, this.getMetaClass(),
332
333
  new IRubyObject[]{runtime.newFloat(jx * scalar),
@@ -343,7 +344,7 @@ public class Vec2 extends RubyObject {
343
344
 
344
345
  public IRubyObject op_div(ThreadContext context, IRubyObject other) {
345
346
  Ruby runtime = context.runtime;
346
- double scalar = (other instanceof RubyFloat)
347
+ double scalar = other instanceof RubyFloat
347
348
  ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
348
349
  if (Math.abs(scalar) < Vec2.EPSILON) {
349
350
  return this;
@@ -408,10 +409,8 @@ public class Vec2 extends RubyObject {
408
409
 
409
410
  public IRubyObject set_mag(ThreadContext context, IRubyObject scalar, Block block) {
410
411
  double new_mag = scalar.toJava(Double.class);
411
- if (block.isGiven()) {
412
- if (!(boolean) block.yield(context, scalar).toJava(Boolean.class)) {
413
- return this;
414
- }
412
+ if (block.isGiven() && !block.yield(context, scalar).toJava(Boolean.class)) {
413
+ return this;
415
414
  }
416
415
  double current = 0;
417
416
  if (Math.abs(jx) > EPSILON && Math.abs(jy) > EPSILON) {
@@ -497,7 +496,7 @@ public class Vec2 extends RubyObject {
497
496
  @JRubyMethod(name = "from_angle", meta = true)
498
497
  public static IRubyObject from_angle(ThreadContext context, IRubyObject klazz, IRubyObject scalar) {
499
498
  Ruby runtime = context.runtime;
500
- double angle = (scalar instanceof RubyFloat)
499
+ double angle = scalar instanceof RubyFloat
501
500
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
502
501
  return Vec2.rbNew(context, klazz, new IRubyObject[]{
503
502
  runtime.newFloat(Math.cos(angle)),
@@ -528,10 +527,10 @@ public class Vec2 extends RubyObject {
528
527
  */
529
528
  @JRubyMethod(name = "rotate!")
530
529
  public IRubyObject rotate_bang(ThreadContext context, IRubyObject scalar) {
531
- double theta = (scalar instanceof RubyFloat)
530
+ double theta = scalar instanceof RubyFloat
532
531
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
533
- double x = (jx * Math.cos(theta) - jy * Math.sin(theta));
534
- double y = (jx * Math.sin(theta) + jy * Math.cos(theta));
532
+ double x = jx * Math.cos(theta) - jy * Math.sin(theta);
533
+ double y = jx * Math.sin(theta) + jy * Math.cos(theta);
535
534
  jx = x;
536
535
  jy = y;
537
536
  return this;
@@ -546,7 +545,7 @@ public class Vec2 extends RubyObject {
546
545
  @JRubyMethod(name = "rotate")
547
546
  public IRubyObject rotate(ThreadContext context, IRubyObject scalar) {
548
547
  Ruby runtime = context.runtime;
549
- double theta = (scalar instanceof RubyFloat)
548
+ double theta = scalar instanceof RubyFloat
550
549
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
551
550
  IRubyObject[] ary = new IRubyObject[]{
552
551
  runtime.newFloat(jx * Math.cos(theta) - jy * Math.sin(theta)),
@@ -567,9 +566,9 @@ public class Vec2 extends RubyObject {
567
566
  throw runtime.newSyntaxError("Check syntax");
568
567
  }
569
568
  Vec2 vec = (Vec2) args[0].toJava(Vec2.class);
570
- double scalar = (args[1] instanceof RubyFloat)
569
+ double scalar = args[1] instanceof RubyFloat
571
570
  ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
572
- assert (scalar >= 0 && scalar < 1.0) :
571
+ assert scalar >= 0 && scalar < 1.0 :
573
572
  "Lerp value " + scalar + " out of range 0..1.0";
574
573
  return Vec2.rbNew(context, this.getMetaClass(), new IRubyObject[]{
575
574
  runtime.newFloat(jx + (vec.jx - jx) * scalar),
@@ -589,9 +588,9 @@ public class Vec2 extends RubyObject {
589
588
  throw runtime.newSyntaxError("Check syntax");
590
589
  }
591
590
  Vec2 vec = (Vec2) args[0].toJava(Vec2.class);
592
- double scalar = (args[1] instanceof RubyFloat)
591
+ double scalar = args[1] instanceof RubyFloat
593
592
  ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
594
- assert (scalar >= 0 && scalar < 1.0) :
593
+ assert scalar >= 0 && scalar < 1.0 :
595
594
  "Lerp value " + scalar + " out of range 0..1.0";
596
595
  jx += (vec.jx - jx) * scalar;
597
596
  jy += (vec.jy - jy) * scalar;
@@ -752,10 +751,8 @@ public class Vec2 extends RubyObject {
752
751
  }
753
752
  if (obj instanceof Vec2) {
754
753
  final Vec2 other = (Vec2) obj;
755
- if ((Double.compare(jx, (Double) other.jx) == 0)
756
- && (Double.compare(jy, (Double) other.jy) == 0)) {
757
- return true;
758
- }
754
+ return Double.compare(jx, (Double) other.jx) == 0
755
+ && Double.compare(jy, (Double) other.jy) == 0;
759
756
  }
760
757
  return false;
761
758
  }
@@ -774,8 +771,8 @@ public class Vec2 extends RubyObject {
774
771
  }
775
772
  if (other instanceof Vec2) {
776
773
  Vec2 v = (Vec2) other.toJava(Vec2.class);
777
- if ((Double.compare(jx, (Double) v.jx) == 0)
778
- && (Double.compare(jy, (Double) v.jy) == 0)) {
774
+ if (Double.compare(jx, (Double) v.jx) == 0
775
+ && Double.compare(jy, (Double) v.jy) == 0) {
779
776
  return runtime.newBoolean(true);
780
777
  }
781
778
  }
@@ -1,12 +1,12 @@
1
1
  package monkstone.vecmath.vec3;
2
2
 
3
3
  /*
4
- * Copyright (c) 2018-21 Martin Prout
4
+ * Copyright (c) 2015-20 Martin Prout
5
5
  *
6
6
  * This library is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public
7
+ * modify it under the terms of the GNU Lesser General Public
8
8
  * License as published by the Free Software Foundation; either
9
- * version 3.0 of the License, or (at your option) any later version.
9
+ * version 2.1 of the License, or (at your option) any later version.
10
10
  *
11
11
  * http://creativecommons.org/licenses/LGPL/2.1/
12
12
  *
@@ -15,7 +15,7 @@ package monkstone.vecmath.vec3;
15
15
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
16
  * Lesser General Public License for more details.
17
17
  *
18
- * You should have received a copy of the GNU General Public
18
+ * You should have received a copy of the GNU Lesser General Public
19
19
  * License along with this library; if not, write to the Free Software
20
20
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
21
  */
@@ -35,7 +35,6 @@ import monkstone.vecmath.JRender;
35
35
  import monkstone.vecmath.vec2.Vec2;
36
36
 
37
37
  /**
38
- *
39
38
  *
40
39
  * @author Martin Prout
41
40
  */
@@ -66,7 +65,7 @@ public final class Vec3 extends RubyObject {
66
65
  * @return new Vec3 object (ruby)
67
66
  */
68
67
  @JRubyMethod(name = "new", meta = true, rest = true)
69
- public final static IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject... args) {
68
+ public static IRubyObject rbNew(ThreadContext context, IRubyObject klazz, IRubyObject... args) {
70
69
  Vec3 vec = (Vec3) ((RubyClass) klazz).allocate();
71
70
  vec.init(context, args);
72
71
  return vec;
@@ -84,27 +83,27 @@ public final class Vec3 extends RubyObject {
84
83
  void init(ThreadContext context, IRubyObject... args) {
85
84
  int count = args.length;
86
85
  if (count >= 2) {
87
- jx = (args[0] instanceof RubyFloat)
86
+ jx = args[0] instanceof RubyFloat
88
87
  ? ((RubyFloat) args[0]).getValue() : ((RubyFixnum) args[0]).getDoubleValue();
89
- jy = (args[1] instanceof RubyFloat)
88
+ jy = args[1] instanceof RubyFloat
90
89
  ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
91
90
  }
92
91
  if (count == 3) {
93
- jz = (args[2] instanceof RubyFloat)
92
+ jz = args[2] instanceof RubyFloat
94
93
  ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
95
94
  } // allow ruby ducktyping in constructor
96
95
  if (count == 1) {
97
96
  if (!(args[0].respondsTo("x"))) {
98
97
  throw context.runtime.newTypeError(args[0].getType() + " doesn't respond_to :x & :y");
99
98
  }
100
- jx = ((args[0].callMethod(context, "x")) instanceof RubyFloat)
99
+ jx = (args[0].callMethod(context, "x")) instanceof RubyFloat
101
100
  ? ((RubyFloat) args[0].callMethod(context, "x")).getValue() : ((RubyFixnum) args[0].callMethod(context, "x")).getDoubleValue();
102
- jy = ((args[0].callMethod(context, "y")) instanceof RubyFloat)
101
+ jy = (args[0].callMethod(context, "y")) instanceof RubyFloat
103
102
  ? ((RubyFloat) args[0].callMethod(context, "y")).getValue() : ((RubyFixnum) args[0].callMethod(context, "y")).getDoubleValue();
104
103
  if (!(args[0].respondsTo("z"))) {
105
104
  return;
106
105
  } // allow promotion from 2D to 3D, sets jz = 0
107
- jz = ((args[0].callMethod(context, "z")) instanceof RubyFloat) ? ((RubyFloat) args[0].callMethod(context, "z")).getValue() : ((RubyFixnum) args[0].callMethod(context, "z")).getDoubleValue();
106
+ jz = (args[0].callMethod(context, "z")) instanceof RubyFloat ? ((RubyFloat) args[0].callMethod(context, "z")).getValue() : ((RubyFixnum) args[0].callMethod(context, "z")).getDoubleValue();
108
107
  }
109
108
  }
110
109
 
@@ -148,11 +147,7 @@ public final class Vec3 extends RubyObject {
148
147
  */
149
148
  @JRubyMethod(name = "x=")
150
149
  public IRubyObject setX(ThreadContext context, IRubyObject other) {
151
- if (other instanceof RubyFloat) {
152
- jx = ((RubyFloat) other).getValue();
153
- } else {
154
- jx = ((RubyFixnum) other).getDoubleValue();
155
- }
150
+ jx = other instanceof RubyFloat ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
156
151
  return other;
157
152
  }
158
153
 
@@ -164,11 +159,7 @@ public final class Vec3 extends RubyObject {
164
159
  */
165
160
  @JRubyMethod(name = "y=")
166
161
  public IRubyObject setY(ThreadContext context, IRubyObject other) {
167
- if (other instanceof RubyFloat) {
168
- jy = ((RubyFloat) other).getValue();
169
- } else {
170
- jy = ((RubyFixnum) other).getDoubleValue();
171
- }
162
+ jy = other instanceof RubyFloat ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
172
163
  return other;
173
164
  }
174
165
 
@@ -180,11 +171,7 @@ public final class Vec3 extends RubyObject {
180
171
  */
181
172
  @JRubyMethod(name = "z=")
182
173
  public IRubyObject setZ(ThreadContext context, IRubyObject other) {
183
- if (other instanceof RubyFloat) {
184
- jz = ((RubyFloat) other).getValue();
185
- } else {
186
- jz = ((RubyFixnum) other).getDoubleValue();
187
- }
174
+ jz = other instanceof RubyFloat ? ((RubyFloat) other).getValue() : ((RubyFixnum) other).getDoubleValue();
188
175
  return other;
189
176
  }
190
177
 
@@ -223,13 +210,13 @@ public final class Vec3 extends RubyObject {
223
210
  Ruby runtime = context.runtime;
224
211
  if (key instanceof RubySymbol) {
225
212
  if (key == RubySymbol.newSymbol(runtime, "x")) {
226
- jx = (value instanceof RubyFloat)
213
+ jx = value instanceof RubyFloat
227
214
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
228
215
  } else if (key == RubySymbol.newSymbol(runtime, "y")) {
229
- jy = (value instanceof RubyFloat)
216
+ jy = value instanceof RubyFloat
230
217
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
231
218
  } else if (key == RubySymbol.newSymbol(runtime, "z")) {
232
- jz = (value instanceof RubyFloat)
219
+ jz = value instanceof RubyFloat
233
220
  ? ((RubyFloat) value).getValue() : ((RubyFixnum) value).getDoubleValue();
234
221
  } else {
235
222
  throw runtime.newIndexError("invalid key");
@@ -369,7 +356,7 @@ public final class Vec3 extends RubyObject {
369
356
  @JRubyMethod(name = "*", required = 1)
370
357
  public IRubyObject op_mul(ThreadContext context, IRubyObject scalar) {
371
358
  Ruby runtime = context.runtime;
372
- double multi = (scalar instanceof RubyFloat)
359
+ double multi = scalar instanceof RubyFloat
373
360
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
374
361
  return Vec3.rbNew(context, this.getMetaClass(), new IRubyObject[]{
375
362
  runtime.newFloat(jx * multi),
@@ -386,7 +373,7 @@ public final class Vec3 extends RubyObject {
386
373
  @JRubyMethod(name = "/", required = 1)
387
374
  public IRubyObject op_div(ThreadContext context, IRubyObject scalar) {
388
375
  Ruby runtime = context.runtime;
389
- double divisor = (scalar instanceof RubyFloat)
376
+ double divisor = scalar instanceof RubyFloat
390
377
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
391
378
  if (Math.abs(divisor) < Vec3.EPSILON) {
392
379
  return this;
@@ -428,12 +415,10 @@ public final class Vec3 extends RubyObject {
428
415
  */
429
416
  @JRubyMethod(name = "set_mag")
430
417
  public IRubyObject set_mag(ThreadContext context, IRubyObject scalar, Block block) {
431
- if (block.isGiven()) {
432
- if (!(boolean) block.yield(context, scalar).toJava(Boolean.class)) {
433
- return this;
434
- }
418
+ if (block.isGiven() && !block.yield(context, scalar).toJava(Boolean.class)) {
419
+ return this;
435
420
  }
436
- double new_mag = (scalar instanceof RubyFloat)
421
+ double new_mag = scalar instanceof RubyFloat
437
422
  ? ((RubyFloat) scalar).getValue() : ((RubyFixnum) scalar).getDoubleValue();
438
423
  double current = Math.sqrt(jx * jx + jy * jy + jz * jz);
439
424
  if (current > EPSILON) {
@@ -599,9 +584,9 @@ public final class Vec3 extends RubyObject {
599
584
  double u = 0;
600
585
  double v = 0;
601
586
  if (count == 3) {
602
- u = (args[1] instanceof RubyFloat)
587
+ u = args[1] instanceof RubyFloat
603
588
  ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
604
- v = (args[2] instanceof RubyFloat)
589
+ v = args[2] instanceof RubyFloat
605
590
  ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
606
591
  }
607
592
  if (count == 2) {
@@ -663,9 +648,9 @@ public final class Vec3 extends RubyObject {
663
648
  }
664
649
  if (obj instanceof Vec3) {
665
650
  final Vec3 other = (Vec3) obj;
666
- if ((Double.compare(jx, (Double) other.jx) == 0)
667
- && (Double.compare(jy, (Double) other.jy) == 0)
668
- && (Double.compare(jz, (Double) other.jz) == 0)) {
651
+ if (Double.compare(jx, (Double) other.jx) == 0
652
+ && Double.compare(jy, (Double) other.jy) == 0
653
+ && Double.compare(jz, (Double) other.jz) == 0) {
669
654
  return true;
670
655
  }
671
656
 
@@ -687,9 +672,9 @@ public final class Vec3 extends RubyObject {
687
672
  }
688
673
  if (other instanceof Vec3) {
689
674
  Vec3 v = (Vec3) other.toJava(Vec3.class);
690
- if ((Double.compare(jx, (Double) v.jx) == 0)
691
- && (Double.compare(jy, (Double) v.jy) == 0)
692
- && (Double.compare(jz, (Double) v.jz) == 0)) {
675
+ if (Double.compare(jx, (Double) v.jx) == 0
676
+ && Double.compare(jy, (Double) v.jy) == 0
677
+ && Double.compare(jz, (Double) v.jz) == 0) {
693
678
  return runtime.newBoolean(true);
694
679
  }
695
680
 
@@ -262,7 +262,7 @@ public class PImageAWT extends PImage {
262
262
  * Use ImageIO functions from Java 1.4 and later to handle image save.
263
263
  * Various formats are supported, typically jpeg, png, bmp, and wbmp.
264
264
  * To get a list of the supported formats for writing, use: <BR>
265
- * <TT>println(javax.imageio.ImageIO.getReaderFormatNames())</TT>
265
+ * <code>println(javax.imageio.ImageIO.getReaderFormatNames())</code>
266
266
  *
267
267
  * @path The path to which the file should be written.
268
268
  */
@@ -354,7 +354,7 @@ public class ShimAWT implements PConstants {
354
354
  * Use ImageIO functions from Java 1.4 and later to handle image save.
355
355
  * Various formats are supported, typically jpeg, png, bmp, and wbmp.
356
356
  * To get a list of the supported formats for writing, use: <BR>
357
- * <TT>println(javax.imageio.ImageIO.getReaderFormatNames())</TT>
357
+ * <code>println(javax.imageio.ImageIO.getReaderFormatNames())</code>
358
358
  */
359
359
  static protected boolean saveImageIO(PImage image, String path) throws IOException {
360
360
  try {
@@ -167,8 +167,8 @@ public class PApplet implements PConstants {
167
167
  * that people use the sketchPath() method and it's inited properly. Call
168
168
  * sketchPath() once to set the default.
169
169
  */
170
+
170
171
  private String sketchPath;
171
- // public String sketchPath;
172
172
 
173
173
  static final boolean DEBUG = false;
174
174
  // static final boolean DEBUG = true;
@@ -1523,24 +1523,24 @@ public class PImage implements PConstants, Cloneable {
1523
1523
  * Sometimes called "Normal" or "Copy" in other software.
1524
1524
  *
1525
1525
  * <LI>BLEND - linear interpolation of colours:
1526
- * <TT>C = A*factor + B</TT>
1526
+ * <code>C = A*factor + B</code>
1527
1527
  *
1528
1528
  * <LI>ADD - additive blending with white clip:
1529
- * <TT>C = min(A*factor + B, 255)</TT>.
1529
+ * <code>C = min(A*factor + B, 255)</code>.
1530
1530
  * Clipped to 0..255, Photoshop calls this "Linear Burn",
1531
1531
  * and Director calls it "Add Pin".
1532
1532
  *
1533
1533
  * <LI>SUBTRACT - subtractive blend with black clip:
1534
- * <TT>C = max(B - A*factor, 0)</TT>.
1534
+ * <code>C = max(B - A*factor, 0)</code>.
1535
1535
  * Clipped to 0..255, Photoshop calls this "Linear Dodge",
1536
1536
  * and Director calls it "Subtract Pin".
1537
1537
  *
1538
1538
  * <LI>DARKEST - only the darkest colour succeeds:
1539
- * <TT>C = min(A*factor, B)</TT>.
1539
+ * <code>C = min(A*factor, B)</code>.
1540
1540
  * Illustrator calls this "Darken".
1541
1541
  *
1542
1542
  * <LI>LIGHTEST - only the lightest colour succeeds:
1543
- * <TT>C = max(A*factor, B)</TT>.
1543
+ * <code>C = max(A*factor, B)</code>.
1544
1544
  * Illustrator calls this "Lighten".
1545
1545
  *
1546
1546
  * <LI>DIFFERENCE - subtract colors from underlying image.
@@ -1571,12 +1571,12 @@ public class PImage implements PConstants, Cloneable {
1571
1571
  * <P>It is important to note that Processing uses "fast" code, not
1572
1572
  * necessarily "correct" code. No biggie, most software does. A nitpicker
1573
1573
  * can find numerous "off by 1 division" problems in the blend code where
1574
- * <TT>&gt;&gt;8</TT> or <TT>&gt;&gt;7</TT> is used when strictly speaking
1575
- * <TT>/255.0</T> or <TT>/127.0</TT> should have been used.</P>
1574
+ * <code>&gt;&gt;8</code> or <code>&gt;&gt;7</code> is used when strictly speaking
1575
+ * <code>/255.0</T> or <code>/127.0</code> should have been used.</P>
1576
1576
  * <P>For instance, exclusion (not intended for real-time use) reads
1577
- * <TT>r1 + r2 - ((2 * r1 * r2) / 255)</TT> because <TT>255 == 1.0</TT>
1578
- * not <TT>256 == 1.0</TT>. In other words, <TT>(255*255)>>8</TT> is not
1579
- * the same as <TT>(255*255)/255</TT>. But for real-time use the shifts
1577
+ * <code>r1 + r2 - ((2 * r1 * r2) / 255)</code> because <code>255 == 1.0</code>
1578
+ * not <code>256 == 1.0</code>. In other words, <code>(255*255)>>8</code> is not
1579
+ * the same as <code>(255*255)/255</code>. But for real-time use the shifts
1580
1580
  * are preferable, and the difference is insignificant for applications
1581
1581
  * built with Processing.</P>
1582
1582
  *
@@ -3104,9 +3104,9 @@ int testFunction(int dst, int src) {
3104
3104
  * </p>
3105
3105
  * Starting with revision 0092, the format setting is taken into account:
3106
3106
  * <UL>
3107
- * <LI><TT>ALPHA</TT> images written as 8bit grayscale (uses lowest byte)
3108
- * <LI><TT>RGB</TT> &rarr; 24 bits
3109
- * <LI><TT>ARGB</TT> &rarr; 32 bits
3107
+ * <LI><code>ALPHA</code> images written as 8bit grayscale (uses lowest byte)
3108
+ * <LI><code>RGB</code> &rarr; 24 bits
3109
+ * <LI><code>ARGB</code> &rarr; 32 bits
3110
3110
  * </UL>
3111
3111
  * All versions are RLE compressed.
3112
3112
  * </p>
@@ -3278,7 +3278,7 @@ int testFunction(int dst, int src) {
3278
3278
  * and the extension used is supported (usually png, jpg, jpeg, bmp,
3279
3279
  * and tiff), then those methods will be used to write the image.
3280
3280
  * To get a list of the supported formats for writing, use: <BR>
3281
- * <TT>println(javax.imageio.ImageIO.getReaderFormatNames())</TT>
3281
+ * <code>println(javax.imageio.ImageIO.getReaderFormatNames())</code>
3282
3282
  * <p>
3283
3283
  * To use the original built-in image writers, use .tga or .tif as the
3284
3284
  * extension, or don't include an extension. When no extension is used,
@@ -181,32 +181,32 @@ public class PGraphicsOpenGL extends PGraphics {
181
181
  // Shaders
182
182
 
183
183
  static protected URL defColorShaderVertURL =
184
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/ColorVert.glsl");
184
+ PGraphicsOpenGL.class.getResource("/shaders/ColorVert.glsl");
185
185
  static protected URL defTextureShaderVertURL =
186
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/TexVert.glsl");
186
+ PGraphicsOpenGL.class.getResource("/shaders/TexVert.glsl");
187
187
  static protected URL defLightShaderVertURL =
188
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/LightVert.glsl");
188
+ PGraphicsOpenGL.class.getResource("/shaders/LightVert.glsl");
189
189
  static protected URL defTexlightShaderVertURL =
190
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/TexLightVert.glsl");
190
+ PGraphicsOpenGL.class.getResource("/shaders/TexLightVert.glsl");
191
191
  static protected URL defColorShaderFragURL =
192
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/ColorFrag.glsl");
192
+ PGraphicsOpenGL.class.getResource("/shaders/ColorFrag.glsl");
193
193
  static protected URL defTextureShaderFragURL =
194
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/TexFrag.glsl");
194
+ PGraphicsOpenGL.class.getResource("/shaders/TexFrag.glsl");
195
195
  static protected URL defLightShaderFragURL =
196
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/LightFrag.glsl");
196
+ PGraphicsOpenGL.class.getResource("/shaders/LightFrag.glsl");
197
197
  static protected URL defTexlightShaderFragURL =
198
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/TexLightFrag.glsl");
198
+ PGraphicsOpenGL.class.getResource("/shaders/TexLightFrag.glsl");
199
199
 
200
200
  static protected URL defLineShaderVertURL =
201
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/LineVert.glsl");
201
+ PGraphicsOpenGL.class.getResource("/shaders/LineVert.glsl");
202
202
  static protected URL defLineShaderFragURL =
203
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/LineFrag.glsl");
203
+ PGraphicsOpenGL.class.getResource("/shaders/LineFrag.glsl");
204
204
  static protected URL defPointShaderVertURL =
205
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/PointVert.glsl");
205
+ PGraphicsOpenGL.class.getResource("/shaders/PointVert.glsl");
206
206
  static protected URL defPointShaderFragURL =
207
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/PointFrag.glsl");
207
+ PGraphicsOpenGL.class.getResource("/shaders/PointFrag.glsl");
208
208
  static protected URL maskShaderFragURL =
209
- PGraphicsOpenGL.class.getResource("/processing/opengl/shaders/MaskFrag.glsl");
209
+ PGraphicsOpenGL.class.getResource("/shaders/MaskFrag.glsl");
210
210
 
211
211
  protected PShader defColorShader;
212
212
  protected PShader defTextureShader;
@@ -1757,16 +1757,10 @@ public class PShader implements PConstants {
1757
1757
  colorLoc = getAttributeLoc("color");
1758
1758
  texCoordLoc = getAttributeLoc("texCoord");
1759
1759
  normalLoc = getAttributeLoc("normal");
1760
-
1761
1760
  ambientLoc = getAttributeLoc("ambient");
1762
1761
  specularLoc = getAttributeLoc("specular");
1763
1762
  emissiveLoc = getAttributeLoc("emissive");
1764
1763
  shininessLoc = getAttributeLoc("shininess");
1765
-
1766
- directionLoc = getAttributeLoc("direction");
1767
-
1768
- offsetLoc = getAttributeLoc("offset");
1769
-
1770
1764
  directionLoc = getAttributeLoc("direction");
1771
1765
  offsetLoc = getAttributeLoc("offset");
1772
1766
 
@@ -944,10 +944,10 @@ public class PSurfaceJOGL implements PSurface {
944
944
  boolean hide = (sketch != null) &&
945
945
  (PApplet.platform == PConstants.WINDOWS);
946
946
  if (hide) setVisible(false);
947
-
947
+
948
948
  ShimAWT.selectFolderImpl(prompt, callbackMethod, file,
949
949
  callbackObject, null);
950
-
950
+
951
951
  if (hide) setVisible(true);
952
952
  });
953
953
  }
@@ -963,7 +963,7 @@ public class PSurfaceJOGL implements PSurface {
963
963
  String name = cursorNames.get(kind);
964
964
  if (name != null) {
965
965
  ImageIcon icon =
966
- new ImageIcon(getClass().getResource("cursors/" + name + ".png"));
966
+ new ImageIcon(getClass().getResource("/cursors/" + name + ".png"));
967
967
  PImage img = new PImageAWT(icon.getImage());
968
968
  // Most cursors just use the center as the hotspot...
969
969
  int x = img.width / 2;
@@ -1538,7 +1538,7 @@ public class PSurfaceJOGL implements PSurface {
1538
1538
  // String name = cursorNames.get(kind);
1539
1539
  // if (name != null) {
1540
1540
  // ImageIcon icon
1541
- // = new ImageIcon(getClass().getResource("cursors/" + name + ".png"));
1541
+ // = new ImageIcon(getClass().getResource("/cursors/" + name + ".png"));
1542
1542
  // PImage img = new PImage(icon.getImage());
1543
1543
  // // Most cursors just use the center as the hotspot...
1544
1544
  // int x = img.width / 2;