propane 3.4.2-java → 3.8.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -1
  3. data/.mvn/wrapper/MavenWrapperDownloader.java +2 -2
  4. data/.mvn/wrapper/maven-wrapper.properties +2 -2
  5. data/.travis.yml +1 -1
  6. data/CHANGELOG.md +9 -1
  7. data/Gemfile +2 -0
  8. data/README.md +7 -10
  9. data/Rakefile +10 -11
  10. data/bin/propane +3 -1
  11. data/lib/propane.rb +4 -2
  12. data/lib/propane/app.rb +5 -1
  13. data/lib/propane/creators/sketch_class.rb +7 -1
  14. data/lib/propane/creators/sketch_factory.rb +4 -2
  15. data/lib/propane/creators/sketch_writer.rb +1 -0
  16. data/lib/propane/helper_methods.rb +22 -23
  17. data/lib/propane/helpers/numeric.rb +2 -0
  18. data/lib/propane/helpers/version_error.rb +1 -0
  19. data/lib/propane/library.rb +5 -1
  20. data/lib/propane/library_loader.rb +2 -0
  21. data/lib/propane/native_folder.rb +10 -9
  22. data/lib/propane/native_loader.rb +3 -0
  23. data/lib/propane/runner.rb +20 -14
  24. data/lib/propane/version.rb +2 -1
  25. data/library/boids/boids.rb +21 -11
  26. data/library/color_group/color_group.rb +2 -0
  27. data/library/control_panel/control_panel.rb +8 -5
  28. data/library/dxf/dxf.rb +2 -0
  29. data/library/file_chooser/chooser.rb +10 -9
  30. data/library/file_chooser/file_chooser.rb +10 -9
  31. data/library/library_proxy/library_proxy.rb +2 -0
  32. data/library/net/net.rb +2 -0
  33. data/library/slider/slider.rb +23 -22
  34. data/library/vector_utils/vector_utils.rb +4 -0
  35. data/library/video_event/video_event.rb +2 -0
  36. data/pom.rb +37 -36
  37. data/pom.xml +7 -7
  38. data/propane.gemspec +13 -9
  39. data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
  40. data/src/main/java/monkstone/ColorUtil.java +1 -3
  41. data/src/main/java/monkstone/MathToolModule.java +1 -1
  42. data/src/main/java/monkstone/PropaneLibrary.java +2 -2
  43. data/src/main/java/monkstone/fastmath/DegLutTables.java +111 -0
  44. data/src/main/java/monkstone/fastmath/Deglut.java +6 -56
  45. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  46. data/src/main/java/monkstone/noise/Noise.java +116 -0
  47. data/src/main/java/monkstone/noise/NoiseGenerator.java +63 -0
  48. data/src/main/java/monkstone/noise/NoiseMode.java +15 -0
  49. data/src/main/java/monkstone/noise/SimplexNoise.java +137 -103
  50. data/src/main/java/monkstone/noise/ValueNoise.java +170 -0
  51. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
  52. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  53. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
  54. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
  55. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  56. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  57. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  58. data/src/main/java/monkstone/vecmath/package-info.java +1 -1
  59. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
  60. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -2
  61. data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
  62. data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
  63. data/src/main/java/monkstone/videoevent/package-info.java +1 -1
  64. data/src/main/java/processing/awt/PGraphicsJava2D.java +781 -285
  65. data/src/main/java/processing/awt/PImageAWT.java +377 -0
  66. data/src/main/java/processing/awt/PShapeJava2D.java +56 -52
  67. data/src/main/java/processing/awt/PSurfaceAWT.java +308 -208
  68. data/src/main/java/processing/awt/ShimAWT.java +581 -0
  69. data/src/main/java/processing/core/PApplet.java +13142 -13883
  70. data/src/main/java/processing/core/PConstants.java +477 -447
  71. data/src/main/java/processing/core/PFont.java +914 -880
  72. data/src/main/java/processing/core/PGraphics.java +152 -136
  73. data/src/main/java/processing/core/PImage.java +275 -372
  74. data/src/main/java/processing/core/PMatrix.java +172 -159
  75. data/src/main/java/processing/core/PMatrix2D.java +478 -415
  76. data/src/main/java/processing/core/PMatrix3D.java +762 -735
  77. data/src/main/java/processing/core/PShape.java +2887 -2651
  78. data/src/main/java/processing/core/PShapeOBJ.java +97 -92
  79. data/src/main/java/processing/core/PShapeSVG.java +1705 -1490
  80. data/src/main/java/processing/core/PStyle.java +40 -37
  81. data/src/main/java/processing/core/PSurface.java +139 -97
  82. data/src/main/java/processing/core/PSurfaceNone.java +296 -218
  83. data/src/main/java/processing/core/PVector.java +995 -963
  84. data/src/main/java/processing/core/ThinkDifferent.java +12 -8
  85. data/src/main/java/processing/data/DoubleDict.java +756 -710
  86. data/src/main/java/processing/data/DoubleList.java +749 -696
  87. data/src/main/java/processing/data/FloatDict.java +748 -702
  88. data/src/main/java/processing/data/FloatList.java +751 -697
  89. data/src/main/java/processing/data/IntDict.java +720 -673
  90. data/src/main/java/processing/data/IntList.java +699 -633
  91. data/src/main/java/processing/data/JSONArray.java +931 -873
  92. data/src/main/java/processing/data/JSONObject.java +1262 -1165
  93. data/src/main/java/processing/data/JSONTokener.java +351 -341
  94. data/src/main/java/processing/data/LongDict.java +710 -663
  95. data/src/main/java/processing/data/LongList.java +701 -635
  96. data/src/main/java/processing/data/Sort.java +37 -41
  97. data/src/main/java/processing/data/StringDict.java +525 -486
  98. data/src/main/java/processing/data/StringList.java +626 -580
  99. data/src/main/java/processing/data/Table.java +3690 -3510
  100. data/src/main/java/processing/data/TableRow.java +182 -183
  101. data/src/main/java/processing/data/XML.java +957 -883
  102. data/src/main/java/processing/event/Event.java +87 -67
  103. data/src/main/java/processing/event/KeyEvent.java +48 -41
  104. data/src/main/java/processing/event/MouseEvent.java +88 -113
  105. data/src/main/java/processing/event/TouchEvent.java +10 -6
  106. data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
  107. data/src/main/java/processing/javafx/PSurfaceFX.java +149 -121
  108. data/src/main/java/processing/net/Client.java +20 -20
  109. data/src/main/java/processing/net/Server.java +9 -9
  110. data/src/main/java/processing/opengl/FontTexture.java +286 -266
  111. data/src/main/java/processing/opengl/FrameBuffer.java +389 -377
  112. data/src/main/java/processing/opengl/LinePath.java +132 -89
  113. data/src/main/java/processing/opengl/LineStroker.java +588 -581
  114. data/src/main/java/processing/opengl/PGL.java +660 -567
  115. data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
  116. data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
  117. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12378 -12075
  118. data/src/main/java/processing/opengl/PJOGL.java +1753 -1670
  119. data/src/main/java/processing/opengl/PShader.java +369 -461
  120. data/src/main/java/processing/opengl/PShapeOpenGL.java +4678 -4580
  121. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1114 -1027
  122. data/src/main/java/processing/opengl/Texture.java +1492 -1401
  123. data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
  124. data/test/create_test.rb +21 -20
  125. data/test/deglut_spec_test.rb +4 -2
  126. data/test/helper_methods_test.rb +49 -20
  127. data/test/math_tool_test.rb +39 -32
  128. data/test/native_folder.rb +47 -0
  129. data/test/respond_to_test.rb +3 -2
  130. data/test/sketches/key_event.rb +2 -2
  131. data/test/sketches/library/my_library/my_library.rb +3 -0
  132. data/test/test_helper.rb +2 -0
  133. data/test/vecmath_spec_test.rb +35 -22
  134. data/vendors/Rakefile +35 -40
  135. metadata +47 -23
  136. data/library/simplex_noise/simplex_noise.rb +0 -3
  137. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
  138. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
  139. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
  140. data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
@@ -1,3 +1,5 @@
1
+ /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
+
1
3
  /*
2
4
  * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
3
5
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -22,40 +24,43 @@
22
24
  * CA 95054 USA or visit www.sun.com if you need additional information or
23
25
  * have any questions.
24
26
  */
27
+
25
28
  package processing.opengl;
26
29
 
27
30
  import processing.core.PMatrix2D;
28
31
 
29
32
  /**
30
- * The {@code LinePath} class allows to represent polygonal paths, potentially
31
- * composed by several disjoint polygonal segments. It can be iterated by the
32
- * {@link PathIterator} class including all of its segment types and winding
33
- * rules
33
+ * The {@code LinePath} class allows to represent polygonal paths,
34
+ * potentially composed by several disjoint polygonal segments.
35
+ * It can be iterated by the {@link PathIterator} class including all
36
+ * of its segment types and winding rules
34
37
  *
35
38
  */
36
39
  public class LinePath {
37
-
38
40
  /**
39
- * The winding rule constant for specifying an even-odd rule for determining
40
- * the interior of a path. The even-odd rule specifies that a point lies
41
- * inside the path if a ray drawn in any direction from that point to infinity
42
- * is crossed by path segments an odd number of times.
41
+ * The winding rule constant for specifying an even-odd rule
42
+ * for determining the interior of a path.
43
+ * The even-odd rule specifies that a point lies inside the
44
+ * path if a ray drawn in any direction from that point to
45
+ * infinity is crossed by path segments an odd number of times.
43
46
  */
44
- public static final int WIND_EVEN_ODD = 0;
47
+ public static final int WIND_EVEN_ODD = 0;
45
48
 
46
49
  /**
47
- * The winding rule constant for specifying a non-zero rule for determining
48
- * the interior of a path. The non-zero rule specifies that a point lies
49
- * inside the path if a ray drawn in any direction from that point to infinity
50
- * is crossed by path segments a different number of times in the
51
- * counter-clockwise direction than the clockwise direction.
50
+ * The winding rule constant for specifying a non-zero rule
51
+ * for determining the interior of a path.
52
+ * The non-zero rule specifies that a point lies inside the
53
+ * path if a ray drawn in any direction from that point to
54
+ * infinity is crossed by path segments a different number
55
+ * of times in the counter-clockwise direction than the
56
+ * clockwise direction.
52
57
  */
53
- public static final int WIND_NON_ZERO = 1;
58
+ public static final int WIND_NON_ZERO = 1;
54
59
 
55
60
  /**
56
61
  * Starts segment at a given position.
57
62
  */
58
- public static final byte SEG_MOVETO = 0;
63
+ public static final byte SEG_MOVETO = 0;
59
64
 
60
65
  /**
61
66
  * Extends segment by adding a line to a given position.
@@ -122,6 +127,7 @@ public class LinePath {
122
127
 
123
128
  protected int windingRule;
124
129
 
130
+
125
131
  /**
126
132
  * Constructs a new empty single precision {@code LinePath} object with a
127
133
  * default winding rule of {@link #WIND_NON_ZERO}.
@@ -130,12 +136,14 @@ public class LinePath {
130
136
  this(WIND_NON_ZERO, INIT_SIZE);
131
137
  }
132
138
 
139
+
133
140
  /**
134
141
  * Constructs a new empty single precision {@code LinePath} object with the
135
142
  * specified winding rule to control operations that require the interior of
136
143
  * the path to be defined.
137
144
  *
138
- * @param rule the winding rule
145
+ * @param rule
146
+ * the winding rule
139
147
  * @see #WIND_EVEN_ODD
140
148
  * @see #WIND_NON_ZERO
141
149
  */
@@ -143,14 +151,16 @@ public class LinePath {
143
151
  this(rule, INIT_SIZE);
144
152
  }
145
153
 
154
+
146
155
  /**
147
156
  * Constructs a new {@code LinePath} object from the given specified initial
148
157
  * values. This method is only intended for internal use and should not be
149
158
  * made public if the other constructors for this class are ever exposed.
150
159
  *
151
- * @param rule the winding rule
152
- * @param initialCapacity the size to make the initial array to store the path
153
- * segment types
160
+ * @param rule
161
+ * the winding rule
162
+ * @param initialCapacity
163
+ * the size to make the initial array to store the path segment types
154
164
  */
155
165
  public LinePath(int rule, int initialCapacity) {
156
166
  setWindingRule(rule);
@@ -159,6 +169,7 @@ public class LinePath {
159
169
  pointColors = new int[initialCapacity];
160
170
  }
161
171
 
172
+
162
173
  void needRoom(boolean needMove, int newPoints) {
163
174
  if (needMove && numTypes == 0) {
164
175
  throw new RuntimeException("missing initial moveto "
@@ -184,7 +195,7 @@ public class LinePath {
184
195
  floatCoords = copyOf(floatCoords, size + grow);
185
196
  }
186
197
  size = pointColors.length;
187
- if (numCoords / 2 + newPoints > size) {
198
+ if (numCoords/2 + newPoints > size) {
188
199
  int grow = size;
189
200
  if (grow > EXPAND_MAX) {
190
201
  grow = EXPAND_MAX;
@@ -196,6 +207,7 @@ public class LinePath {
196
207
  }
197
208
  }
198
209
 
210
+
199
211
  /**
200
212
  * Adds a point to the path by moving to the specified coordinates specified
201
213
  * in float precision.
@@ -203,8 +215,10 @@ public class LinePath {
203
215
  * This method provides a single precision variant of the double precision
204
216
  * {@code moveTo()} method on the base {@code LinePath} class.
205
217
  *
206
- * @param x the specified X coordinate
207
- * @param y the specified Y coordinate
218
+ * @param x
219
+ * the specified X coordinate
220
+ * @param y
221
+ * the specified Y coordinate
208
222
  * @param c
209
223
  * @see LinePath#moveTo
210
224
  */
@@ -212,16 +226,17 @@ public class LinePath {
212
226
  if (numTypes > 0 && pointTypes[numTypes - 1] == SEG_MOVETO) {
213
227
  floatCoords[numCoords - 2] = x;
214
228
  floatCoords[numCoords - 1] = y;
215
- pointColors[numCoords / 2 - 1] = c;
229
+ pointColors[numCoords/2-1] = c;
216
230
  } else {
217
231
  needRoom(false, 1);
218
232
  pointTypes[numTypes++] = SEG_MOVETO;
219
233
  floatCoords[numCoords++] = x;
220
234
  floatCoords[numCoords++] = y;
221
- pointColors[numCoords / 2 - 1] = c;
235
+ pointColors[numCoords/2-1] = c;
222
236
  }
223
237
  }
224
238
 
239
+
225
240
  /**
226
241
  * Adds a point to the path by drawing a straight line from the current
227
242
  * coordinates to the new specified coordinates specified in float precision.
@@ -229,8 +244,10 @@ public class LinePath {
229
244
  * This method provides a single precision variant of the double precision
230
245
  * {@code lineTo()} method on the base {@code LinePath} class.
231
246
  *
232
- * @param x the specified X coordinate
233
- * @param y the specified Y coordinate
247
+ * @param x
248
+ * the specified X coordinate
249
+ * @param y
250
+ * the specified Y coordinate
234
251
  * @param c
235
252
  * @see LinePath#lineTo
236
253
  */
@@ -239,21 +256,22 @@ public class LinePath {
239
256
  pointTypes[numTypes++] = SEG_LINETO;
240
257
  floatCoords[numCoords++] = x;
241
258
  floatCoords[numCoords++] = y;
242
- pointColors[numCoords / 2 - 1] = c;
259
+ pointColors[numCoords/2-1] = c;
243
260
  }
244
261
 
262
+
245
263
  /**
246
264
  * The iterator for this class is not multi-threaded safe, which means that
247
265
  * the {@code LinePath} class does not guarantee that modifications to the
248
- * geometry of this {@code LinePath} object do not affect any iterations of
249
- * that geometry that are already in process.
250
- *
251
- * @return
266
+ * geometry of this {@code LinePath} object do not affect any iterations of that
267
+ * geometry that are already in process.
268
+ * @return
252
269
  */
253
270
  public PathIterator getPathIterator() {
254
271
  return new PathIterator(this);
255
272
  }
256
273
 
274
+
257
275
  /**
258
276
  * Closes the current subpath by drawing a straight line back to the
259
277
  * coordinates of the last {@code moveTo}. If the path is already closed then
@@ -266,6 +284,7 @@ public class LinePath {
266
284
  }
267
285
  }
268
286
 
287
+
269
288
  /**
270
289
  * Returns the fill style winding rule.
271
290
  *
@@ -278,12 +297,15 @@ public class LinePath {
278
297
  return windingRule;
279
298
  }
280
299
 
300
+
281
301
  /**
282
302
  * Sets the winding rule for this path to the specified value.
283
303
  *
284
- * @param rule an integer representing the specified winding rule
285
- * @exception IllegalArgumentException if {@code rule} is not either
286
- * {@link #WIND_EVEN_ODD} or {@link #WIND_NON_ZERO}
304
+ * @param rule
305
+ * an integer representing the specified winding rule
306
+ * @exception IllegalArgumentException
307
+ * if {@code rule} is not either {@link #WIND_EVEN_ODD} or
308
+ * {@link #WIND_NON_ZERO}
287
309
  * @see #getWindingRule
288
310
  */
289
311
  public final void setWindingRule(int rule) {
@@ -294,6 +316,7 @@ public class LinePath {
294
316
  windingRule = rule;
295
317
  }
296
318
 
319
+
297
320
  /**
298
321
  * Resets the path to empty. The append position is set back to the beginning
299
322
  * of the path and all coordinates and point types are forgotten.
@@ -302,9 +325,9 @@ public class LinePath {
302
325
  numTypes = numCoords = 0;
303
326
  }
304
327
 
305
- static public class PathIterator {
306
328
 
307
- float floatCoords[];
329
+ static public class PathIterator {
330
+ float[] floatCoords;
308
331
 
309
332
  int typeIdx;
310
333
 
@@ -314,7 +337,7 @@ public class LinePath {
314
337
 
315
338
  LinePath path;
316
339
 
317
- static final int[] CURVE_COORDS = {2, 2, 0};
340
+ static final int[] curvecoords = { 2, 2, 0 };
318
341
 
319
342
  PathIterator(LinePath p2df) {
320
343
  this.path = p2df;
@@ -325,13 +348,13 @@ public class LinePath {
325
348
 
326
349
  public int currentSegment(float[] coords) {
327
350
  int type = path.pointTypes[typeIdx];
328
- int numCoords = CURVE_COORDS[type];
351
+ int numCoords = curvecoords[type];
329
352
  if (numCoords > 0) {
330
353
  System.arraycopy(floatCoords, pointIdx, coords, 0, numCoords);
331
354
  int color = path.pointColors[colorIdx];
332
355
  coords[numCoords + 0] = (color >> 24) & 0xFF;
333
356
  coords[numCoords + 1] = (color >> 16) & 0xFF;
334
- coords[numCoords + 2] = (color >> 8) & 0xFF;
357
+ coords[numCoords + 2] = (color >> 8) & 0xFF;
335
358
  coords[numCoords + 3] = (color) & 0xFF;
336
359
  }
337
360
  return type;
@@ -339,7 +362,7 @@ public class LinePath {
339
362
 
340
363
  public int currentSegment(double[] coords) {
341
364
  int type = path.pointTypes[typeIdx];
342
- int numCoords = CURVE_COORDS[type];
365
+ int numCoords = curvecoords[type];
343
366
  if (numCoords > 0) {
344
367
  for (int i = 0; i < numCoords; i++) {
345
368
  coords[i] = floatCoords[pointIdx + i];
@@ -347,7 +370,7 @@ public class LinePath {
347
370
  int color = path.pointColors[colorIdx];
348
371
  coords[numCoords + 0] = (color >> 24) & 0xFF;
349
372
  coords[numCoords + 1] = (color >> 16) & 0xFF;
350
- coords[numCoords + 2] = (color >> 8) & 0xFF;
373
+ coords[numCoords + 2] = (color >> 8) & 0xFF;
351
374
  coords[numCoords + 3] = (color) & 0xFF;
352
375
  }
353
376
  return type;
@@ -363,41 +386,50 @@ public class LinePath {
363
386
 
364
387
  public void next() {
365
388
  int type = path.pointTypes[typeIdx++];
366
- if (0 < CURVE_COORDS[type]) {
367
- pointIdx += CURVE_COORDS[type];
389
+ if (0 < curvecoords[type]) {
390
+ pointIdx += curvecoords[type];
368
391
  colorIdx++;
369
392
  }
370
393
  }
371
394
  }
372
395
 
396
+
373
397
  /////////////////////////////////////////////////////////////////////////////
374
398
  //
375
399
  // Stroked path methods
400
+
401
+
376
402
  static public LinePath createStrokedPath(LinePath src, float weight,
377
- int caps, int join) {
403
+ int caps, int join) {
378
404
  return createStrokedPath(src, weight, caps, join, defaultMiterlimit, null);
379
405
  }
380
406
 
407
+
381
408
  static public LinePath createStrokedPath(LinePath src, float weight,
382
- int caps, int join, float miterlimit) {
409
+ int caps, int join, float miterlimit) {
383
410
  return createStrokedPath(src, weight, caps, join, miterlimit, null);
384
411
  }
385
412
 
413
+
386
414
  /**
387
415
  * Constructs a solid <code>LinePath</code> with the specified attributes.
388
416
  *
389
- * @param src the original path to be stroked
390
- * @param weight the weight of the stroked path
391
- * @param caps the decoration of the ends of the segments in the path
392
- * @param join the decoration applied where path segments meet
417
+ * @param src
418
+ * the original path to be stroked
419
+ * @param weight
420
+ * the weight of the stroked path
421
+ * @param caps
422
+ * the decoration of the ends of the segments in the path
423
+ * @param join
424
+ * the decoration applied where path segments meet
393
425
  * @param miterlimit
394
426
  * @param transform
395
- * @return
427
+ * @return
396
428
  *
397
429
  */
398
430
  static public LinePath createStrokedPath(LinePath src, float weight,
399
- int caps, int join,
400
- float miterlimit, PMatrix2D transform) {
431
+ int caps, int join,
432
+ float miterlimit, PMatrix2D transform) {
401
433
  final LinePath dest = new LinePath();
402
434
 
403
435
  strokeTo(src, weight, caps, join, miterlimit, transform, new LineStroker() {
@@ -428,88 +460,93 @@ public class LinePath {
428
460
  return dest;
429
461
  }
430
462
 
463
+
431
464
  private static void strokeTo(LinePath src, float width, int caps, int join,
432
- float miterlimit, PMatrix2D transform,
433
- LineStroker lsink) {
465
+ float miterlimit, PMatrix2D transform,
466
+ LineStroker lsink) {
434
467
  lsink = new LineStroker(lsink, FloatToS15_16(width), caps, join,
435
- FloatToS15_16(miterlimit),
436
- transform == null ? identity : transform);
468
+ FloatToS15_16(miterlimit),
469
+ transform == null ? identity : transform);
437
470
 
438
471
  PathIterator pi = src.getPathIterator();
439
472
  pathTo(pi, lsink);
440
473
  }
441
474
 
475
+
442
476
  private static void pathTo(PathIterator pi, LineStroker lsink) {
443
- float coords[] = new float[6];
477
+ float[] coords = new float[6];
444
478
  while (!pi.isDone()) {
445
479
  int color;
446
480
  switch (pi.currentSegment(coords)) {
447
- case SEG_MOVETO:
448
- color = ((int) coords[2] << 24)
449
- | ((int) coords[3] << 16)
450
- | ((int) coords[4] << 8)
451
- | (int) coords[5];
452
- lsink.moveTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
453
- break;
454
- case SEG_LINETO:
455
- color = ((int) coords[2] << 24)
456
- | ((int) coords[3] << 16)
457
- | ((int) coords[4] << 8)
458
- | (int) coords[5];
459
- lsink.lineJoin();
460
- lsink.lineTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
461
- break;
462
- case SEG_CLOSE:
463
- lsink.lineJoin();
464
- lsink.close();
465
- break;
466
- default:
467
- throw new InternalError("unknown flattened segment type");
481
+ case SEG_MOVETO:
482
+ color = ((int)coords[2]<<24) |
483
+ ((int)coords[3]<<16) |
484
+ ((int)coords[4]<< 8) |
485
+ (int)coords[5];
486
+ lsink.moveTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
487
+ break;
488
+ case SEG_LINETO:
489
+ color = ((int)coords[2]<<24) |
490
+ ((int)coords[3]<<16) |
491
+ ((int)coords[4]<< 8) |
492
+ (int)coords[5];
493
+ lsink.lineJoin();
494
+ lsink.lineTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
495
+ break;
496
+ case SEG_CLOSE:
497
+ lsink.lineJoin();
498
+ lsink.close();
499
+ break;
500
+ default:
501
+ throw new InternalError("unknown flattened segment type");
468
502
  }
469
503
  pi.next();
470
504
  }
471
505
  lsink.end();
472
506
  }
473
507
 
508
+
474
509
  /////////////////////////////////////////////////////////////////////////////
475
510
  //
476
511
  // Utility methods
512
+
513
+
477
514
  public static float[] copyOf(float[] source, int length) {
478
515
  float[] target = new float[length];
479
516
  for (int i = 0; i < target.length; i++) {
480
- if (i > source.length - 1) {
517
+ if (i > source.length - 1)
481
518
  target[i] = 0f;
482
- } else {
519
+ else
483
520
  target[i] = source[i];
484
- }
485
521
  }
486
522
  return target;
487
523
  }
488
524
 
525
+
489
526
  public static byte[] copyOf(byte[] source, int length) {
490
527
  byte[] target = new byte[length];
491
528
  for (int i = 0; i < target.length; i++) {
492
- if (i > source.length - 1) {
529
+ if (i > source.length - 1)
493
530
  target[i] = 0;
494
- } else {
531
+ else
495
532
  target[i] = source[i];
496
- }
497
533
  }
498
534
  return target;
499
535
  }
500
536
 
537
+
501
538
  public static int[] copyOf(int[] source, int length) {
502
539
  int[] target = new int[length];
503
540
  for (int i = 0; i < target.length; i++) {
504
- if (i > source.length - 1) {
541
+ if (i > source.length - 1)
505
542
  target[i] = 0;
506
- } else {
543
+ else
507
544
  target[i] = source[i];
508
- }
509
545
  }
510
546
  return target;
511
547
  }
512
548
 
549
+
513
550
  // From Ken Turkowski, _Fixed-Point Square Root_, In Graphics Gems V
514
551
  public static int isqrt(int x) {
515
552
  int fracbits = 16;
@@ -533,6 +570,7 @@ public class LinePath {
533
570
  return root;
534
571
  }
535
572
 
573
+
536
574
  public static long lsqrt(long x) {
537
575
  int fracbits = 16;
538
576
 
@@ -555,18 +593,22 @@ public class LinePath {
555
593
  return root;
556
594
  }
557
595
 
596
+
558
597
  public static double hypot(double x, double y) {
559
598
  return Math.sqrt(x * x + y * y);
560
599
  }
561
600
 
601
+
562
602
  public static int hypot(int x, int y) {
563
603
  return (int) ((lsqrt((long) x * x + (long) y * y) + 128) >> 8);
564
604
  }
565
605
 
606
+
566
607
  public static long hypot(long x, long y) {
567
608
  return (lsqrt(x * x + y * y) + 128) >> 8;
568
609
  }
569
610
 
611
+
570
612
  static int FloatToS15_16(float flt) {
571
613
  flt = flt * 65536f + 0.5f;
572
614
  if (flt <= -(65536f * 65536f)) {
@@ -578,6 +620,7 @@ public class LinePath {
578
620
  }
579
621
  }
580
622
 
623
+
581
624
  static float S15_16ToFloat(int fix) {
582
625
  return (fix / 65536f);
583
626
  }