propane 3.4.2-java → 3.5.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
  3. data/.travis.yml +1 -1
  4. data/CHANGELOG.md +5 -1
  5. data/Gemfile +2 -0
  6. data/README.md +15 -3
  7. data/Rakefile +9 -10
  8. data/bin/propane +3 -1
  9. data/lib/propane.rb +2 -1
  10. data/lib/propane/app.rb +2 -1
  11. data/lib/propane/creators/sketch_class.rb +7 -1
  12. data/lib/propane/creators/sketch_factory.rb +4 -2
  13. data/lib/propane/creators/sketch_writer.rb +1 -0
  14. data/lib/propane/helper_methods.rb +22 -22
  15. data/lib/propane/helpers/numeric.rb +2 -0
  16. data/lib/propane/helpers/version_error.rb +1 -0
  17. data/lib/propane/library.rb +5 -1
  18. data/lib/propane/library_loader.rb +2 -0
  19. data/lib/propane/native_folder.rb +10 -9
  20. data/lib/propane/native_loader.rb +3 -0
  21. data/lib/propane/runner.rb +11 -5
  22. data/lib/propane/version.rb +2 -1
  23. data/library/boids/boids.rb +21 -11
  24. data/library/color_group/color_group.rb +2 -0
  25. data/library/control_panel/control_panel.rb +8 -5
  26. data/library/dxf/dxf.rb +2 -0
  27. data/library/file_chooser/chooser.rb +10 -9
  28. data/library/file_chooser/file_chooser.rb +10 -9
  29. data/library/library_proxy/library_proxy.rb +2 -0
  30. data/library/net/net.rb +2 -0
  31. data/library/simplex_noise/simplex_noise.rb +2 -0
  32. data/library/slider/slider.rb +23 -22
  33. data/library/vector_utils/vector_utils.rb +4 -0
  34. data/library/video_event/video_event.rb +2 -0
  35. data/pom.rb +46 -45
  36. data/pom.xml +4 -4
  37. data/propane.gemspec +8 -7
  38. data/src/main/java/monkstone/ColorUtil.java +1 -3
  39. data/src/main/java/monkstone/MathToolModule.java +1 -1
  40. data/src/main/java/monkstone/PropaneLibrary.java +2 -2
  41. data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
  42. data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
  43. data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
  44. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
  45. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  46. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
  47. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
  48. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  49. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  50. data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
  51. data/src/main/java/monkstone/vecmath/package-info.java +1 -1
  52. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
  53. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -2
  54. data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
  55. data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
  56. data/src/main/java/monkstone/videoevent/package-info.java +1 -1
  57. data/src/main/java/processing/awt/PGraphicsJava2D.java +788 -283
  58. data/src/main/java/processing/awt/PImageAWT.java +260 -0
  59. data/src/main/java/processing/awt/PShapeJava2D.java +56 -53
  60. data/src/main/java/processing/awt/PSurfaceAWT.java +309 -211
  61. data/src/main/java/processing/awt/ShimAWT.java +580 -0
  62. data/src/main/java/processing/core/PApplet.java +2877 -2098
  63. data/src/main/java/processing/core/PConstants.java +477 -447
  64. data/src/main/java/processing/core/PFont.java +930 -884
  65. data/src/main/java/processing/core/PGraphics.java +337 -309
  66. data/src/main/java/processing/core/PImage.java +1689 -1689
  67. data/src/main/java/processing/core/PMatrix.java +172 -159
  68. data/src/main/java/processing/core/PMatrix2D.java +456 -410
  69. data/src/main/java/processing/core/PMatrix3D.java +755 -735
  70. data/src/main/java/processing/core/PShape.java +2910 -2656
  71. data/src/main/java/processing/core/PShapeOBJ.java +97 -94
  72. data/src/main/java/processing/core/PShapeSVG.java +1656 -1462
  73. data/src/main/java/processing/core/PStyle.java +40 -37
  74. data/src/main/java/processing/core/PSurface.java +134 -97
  75. data/src/main/java/processing/core/PSurfaceNone.java +292 -218
  76. data/src/main/java/processing/core/PVector.java +991 -966
  77. data/src/main/java/processing/core/ThinkDifferent.java +12 -8
  78. data/src/main/java/processing/data/DoubleDict.java +756 -710
  79. data/src/main/java/processing/data/DoubleList.java +749 -696
  80. data/src/main/java/processing/data/FloatDict.java +748 -702
  81. data/src/main/java/processing/data/FloatList.java +751 -697
  82. data/src/main/java/processing/data/IntDict.java +720 -673
  83. data/src/main/java/processing/data/IntList.java +699 -633
  84. data/src/main/java/processing/data/JSONArray.java +931 -873
  85. data/src/main/java/processing/data/JSONObject.java +1262 -1165
  86. data/src/main/java/processing/data/JSONTokener.java +351 -341
  87. data/src/main/java/processing/data/LongDict.java +710 -663
  88. data/src/main/java/processing/data/LongList.java +701 -635
  89. data/src/main/java/processing/data/Sort.java +37 -41
  90. data/src/main/java/processing/data/StringDict.java +525 -486
  91. data/src/main/java/processing/data/StringList.java +626 -580
  92. data/src/main/java/processing/data/Table.java +3693 -3513
  93. data/src/main/java/processing/data/TableRow.java +182 -183
  94. data/src/main/java/processing/data/XML.java +954 -880
  95. data/src/main/java/processing/event/Event.java +87 -67
  96. data/src/main/java/processing/event/KeyEvent.java +48 -41
  97. data/src/main/java/processing/event/MouseEvent.java +87 -113
  98. data/src/main/java/processing/event/TouchEvent.java +10 -6
  99. data/src/main/java/processing/javafx/PSurfaceFX.java +26 -0
  100. data/src/main/java/processing/net/Client.java +20 -20
  101. data/src/main/java/processing/net/Server.java +9 -9
  102. data/src/main/java/processing/opengl/FontTexture.java +286 -266
  103. data/src/main/java/processing/opengl/FrameBuffer.java +390 -376
  104. data/src/main/java/processing/opengl/LinePath.java +130 -91
  105. data/src/main/java/processing/opengl/LineStroker.java +593 -582
  106. data/src/main/java/processing/opengl/PGL.java +645 -579
  107. data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
  108. data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
  109. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12287 -12030
  110. data/src/main/java/processing/opengl/PJOGL.java +1743 -1672
  111. data/src/main/java/processing/opengl/PShader.java +345 -416
  112. data/src/main/java/processing/opengl/PShapeOpenGL.java +4601 -4543
  113. data/src/main/java/processing/opengl/PSurfaceJOGL.java +1113 -1029
  114. data/src/main/java/processing/opengl/Texture.java +1489 -1401
  115. data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
  116. data/test/create_test.rb +21 -20
  117. data/test/deglut_spec_test.rb +4 -2
  118. data/test/helper_methods_test.rb +49 -20
  119. data/test/math_tool_test.rb +39 -32
  120. data/test/native_folder.rb +47 -0
  121. data/test/respond_to_test.rb +3 -2
  122. data/test/sketches/key_event.rb +2 -2
  123. data/test/sketches/library/my_library/my_library.rb +3 -0
  124. data/test/test_helper.rb +2 -0
  125. data/test/vecmath_spec_test.rb +35 -22
  126. data/vendors/Rakefile +28 -22
  127. metadata +13 -13
  128. data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
  129. data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
  130. data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
  131. 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,25 +215,27 @@ 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
208
- * @param c
218
+ * @param x
219
+ * the specified X coordinate
220
+ * @param y
221
+ * the specified Y coordinate
209
222
  * @see LinePath#moveTo
210
223
  */
211
224
  public final void moveTo(float x, float y, int c) {
212
225
  if (numTypes > 0 && pointTypes[numTypes - 1] == SEG_MOVETO) {
213
226
  floatCoords[numCoords - 2] = x;
214
227
  floatCoords[numCoords - 1] = y;
215
- pointColors[numCoords / 2 - 1] = c;
228
+ pointColors[numCoords/2-1] = c;
216
229
  } else {
217
230
  needRoom(false, 1);
218
231
  pointTypes[numTypes++] = SEG_MOVETO;
219
232
  floatCoords[numCoords++] = x;
220
233
  floatCoords[numCoords++] = y;
221
- pointColors[numCoords / 2 - 1] = c;
234
+ pointColors[numCoords/2-1] = c;
222
235
  }
223
236
  }
224
237
 
238
+
225
239
  /**
226
240
  * Adds a point to the path by drawing a straight line from the current
227
241
  * coordinates to the new specified coordinates specified in float precision.
@@ -229,9 +243,10 @@ public class LinePath {
229
243
  * This method provides a single precision variant of the double precision
230
244
  * {@code lineTo()} method on the base {@code LinePath} class.
231
245
  *
232
- * @param x the specified X coordinate
233
- * @param y the specified Y coordinate
234
- * @param c
246
+ * @param x
247
+ * the specified X coordinate
248
+ * @param y
249
+ * the specified Y coordinate
235
250
  * @see LinePath#lineTo
236
251
  */
237
252
  public final void lineTo(float x, float y, int c) {
@@ -239,21 +254,21 @@ public class LinePath {
239
254
  pointTypes[numTypes++] = SEG_LINETO;
240
255
  floatCoords[numCoords++] = x;
241
256
  floatCoords[numCoords++] = y;
242
- pointColors[numCoords / 2 - 1] = c;
257
+ pointColors[numCoords/2-1] = c;
243
258
  }
244
259
 
260
+
245
261
  /**
246
262
  * The iterator for this class is not multi-threaded safe, which means that
247
263
  * 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
264
+ * geometry of this {@code LinePath} object do not affect any iterations of that
265
+ * geometry that are already in process.
252
266
  */
253
267
  public PathIterator getPathIterator() {
254
268
  return new PathIterator(this);
255
269
  }
256
270
 
271
+
257
272
  /**
258
273
  * Closes the current subpath by drawing a straight line back to the
259
274
  * coordinates of the last {@code moveTo}. If the path is already closed then
@@ -266,6 +281,7 @@ public class LinePath {
266
281
  }
267
282
  }
268
283
 
284
+
269
285
  /**
270
286
  * Returns the fill style winding rule.
271
287
  *
@@ -278,12 +294,15 @@ public class LinePath {
278
294
  return windingRule;
279
295
  }
280
296
 
297
+
281
298
  /**
282
299
  * Sets the winding rule for this path to the specified value.
283
300
  *
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}
301
+ * @param rule
302
+ * an integer representing the specified winding rule
303
+ * @exception IllegalArgumentException
304
+ * if {@code rule} is not either {@link #WIND_EVEN_ODD} or
305
+ * {@link #WIND_NON_ZERO}
287
306
  * @see #getWindingRule
288
307
  */
289
308
  public final void setWindingRule(int rule) {
@@ -294,6 +313,7 @@ public class LinePath {
294
313
  windingRule = rule;
295
314
  }
296
315
 
316
+
297
317
  /**
298
318
  * Resets the path to empty. The append position is set back to the beginning
299
319
  * of the path and all coordinates and point types are forgotten.
@@ -302,9 +322,9 @@ public class LinePath {
302
322
  numTypes = numCoords = 0;
303
323
  }
304
324
 
305
- static public class PathIterator {
306
325
 
307
- float floatCoords[];
326
+ static public class PathIterator {
327
+ float[] floatCoords;
308
328
 
309
329
  int typeIdx;
310
330
 
@@ -314,7 +334,7 @@ public class LinePath {
314
334
 
315
335
  LinePath path;
316
336
 
317
- static final int[] CURVE_COORDS = {2, 2, 0};
337
+ static final int[] curvecoords = { 2, 2, 0 };
318
338
 
319
339
  PathIterator(LinePath p2df) {
320
340
  this.path = p2df;
@@ -325,13 +345,13 @@ public class LinePath {
325
345
 
326
346
  public int currentSegment(float[] coords) {
327
347
  int type = path.pointTypes[typeIdx];
328
- int numCoords = CURVE_COORDS[type];
348
+ int numCoords = curvecoords[type];
329
349
  if (numCoords > 0) {
330
350
  System.arraycopy(floatCoords, pointIdx, coords, 0, numCoords);
331
351
  int color = path.pointColors[colorIdx];
332
352
  coords[numCoords + 0] = (color >> 24) & 0xFF;
333
353
  coords[numCoords + 1] = (color >> 16) & 0xFF;
334
- coords[numCoords + 2] = (color >> 8) & 0xFF;
354
+ coords[numCoords + 2] = (color >> 8) & 0xFF;
335
355
  coords[numCoords + 3] = (color) & 0xFF;
336
356
  }
337
357
  return type;
@@ -339,7 +359,7 @@ public class LinePath {
339
359
 
340
360
  public int currentSegment(double[] coords) {
341
361
  int type = path.pointTypes[typeIdx];
342
- int numCoords = CURVE_COORDS[type];
362
+ int numCoords = curvecoords[type];
343
363
  if (numCoords > 0) {
344
364
  for (int i = 0; i < numCoords; i++) {
345
365
  coords[i] = floatCoords[pointIdx + i];
@@ -347,7 +367,7 @@ public class LinePath {
347
367
  int color = path.pointColors[colorIdx];
348
368
  coords[numCoords + 0] = (color >> 24) & 0xFF;
349
369
  coords[numCoords + 1] = (color >> 16) & 0xFF;
350
- coords[numCoords + 2] = (color >> 8) & 0xFF;
370
+ coords[numCoords + 2] = (color >> 8) & 0xFF;
351
371
  coords[numCoords + 3] = (color) & 0xFF;
352
372
  }
353
373
  return type;
@@ -363,41 +383,49 @@ public class LinePath {
363
383
 
364
384
  public void next() {
365
385
  int type = path.pointTypes[typeIdx++];
366
- if (0 < CURVE_COORDS[type]) {
367
- pointIdx += CURVE_COORDS[type];
386
+ if (0 < curvecoords[type]) {
387
+ pointIdx += curvecoords[type];
368
388
  colorIdx++;
369
389
  }
370
390
  }
371
391
  }
372
392
 
393
+
373
394
  /////////////////////////////////////////////////////////////////////////////
374
395
  //
375
396
  // Stroked path methods
397
+
398
+
376
399
  static public LinePath createStrokedPath(LinePath src, float weight,
377
- int caps, int join) {
400
+ int caps, int join) {
378
401
  return createStrokedPath(src, weight, caps, join, defaultMiterlimit, null);
379
402
  }
380
403
 
404
+
381
405
  static public LinePath createStrokedPath(LinePath src, float weight,
382
- int caps, int join, float miterlimit) {
406
+ int caps, int join, float miterlimit) {
383
407
  return createStrokedPath(src, weight, caps, join, miterlimit, null);
384
408
  }
385
409
 
410
+
386
411
  /**
387
412
  * Constructs a solid <code>LinePath</code> with the specified attributes.
388
413
  *
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
414
+ * @param src
415
+ * the original path to be stroked
416
+ * @param weight
417
+ * the weight of the stroked path
418
+ * @param caps
419
+ * the decoration of the ends of the segments in the path
420
+ * @param join
421
+ * the decoration applied where path segments meet
393
422
  * @param miterlimit
394
423
  * @param transform
395
- * @return
396
424
  *
397
425
  */
398
426
  static public LinePath createStrokedPath(LinePath src, float weight,
399
- int caps, int join,
400
- float miterlimit, PMatrix2D transform) {
427
+ int caps, int join,
428
+ float miterlimit, PMatrix2D transform) {
401
429
  final LinePath dest = new LinePath();
402
430
 
403
431
  strokeTo(src, weight, caps, join, miterlimit, transform, new LineStroker() {
@@ -428,88 +456,93 @@ public class LinePath {
428
456
  return dest;
429
457
  }
430
458
 
459
+
431
460
  private static void strokeTo(LinePath src, float width, int caps, int join,
432
- float miterlimit, PMatrix2D transform,
433
- LineStroker lsink) {
461
+ float miterlimit, PMatrix2D transform,
462
+ LineStroker lsink) {
434
463
  lsink = new LineStroker(lsink, FloatToS15_16(width), caps, join,
435
- FloatToS15_16(miterlimit),
436
- transform == null ? identity : transform);
464
+ FloatToS15_16(miterlimit),
465
+ transform == null ? identity : transform);
437
466
 
438
467
  PathIterator pi = src.getPathIterator();
439
468
  pathTo(pi, lsink);
440
469
  }
441
470
 
471
+
442
472
  private static void pathTo(PathIterator pi, LineStroker lsink) {
443
- float coords[] = new float[6];
473
+ float[] coords = new float[6];
444
474
  while (!pi.isDone()) {
445
475
  int color;
446
476
  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");
477
+ case SEG_MOVETO:
478
+ color = ((int)coords[2]<<24) |
479
+ ((int)coords[3]<<16) |
480
+ ((int)coords[4]<< 8) |
481
+ (int)coords[5];
482
+ lsink.moveTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
483
+ break;
484
+ case SEG_LINETO:
485
+ color = ((int)coords[2]<<24) |
486
+ ((int)coords[3]<<16) |
487
+ ((int)coords[4]<< 8) |
488
+ (int)coords[5];
489
+ lsink.lineJoin();
490
+ lsink.lineTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
491
+ break;
492
+ case SEG_CLOSE:
493
+ lsink.lineJoin();
494
+ lsink.close();
495
+ break;
496
+ default:
497
+ throw new InternalError("unknown flattened segment type");
468
498
  }
469
499
  pi.next();
470
500
  }
471
501
  lsink.end();
472
502
  }
473
503
 
504
+
474
505
  /////////////////////////////////////////////////////////////////////////////
475
506
  //
476
507
  // Utility methods
508
+
509
+
477
510
  public static float[] copyOf(float[] source, int length) {
478
511
  float[] target = new float[length];
479
512
  for (int i = 0; i < target.length; i++) {
480
- if (i > source.length - 1) {
513
+ if (i > source.length - 1)
481
514
  target[i] = 0f;
482
- } else {
515
+ else
483
516
  target[i] = source[i];
484
- }
485
517
  }
486
518
  return target;
487
519
  }
488
520
 
521
+
489
522
  public static byte[] copyOf(byte[] source, int length) {
490
523
  byte[] target = new byte[length];
491
524
  for (int i = 0; i < target.length; i++) {
492
- if (i > source.length - 1) {
525
+ if (i > source.length - 1)
493
526
  target[i] = 0;
494
- } else {
527
+ else
495
528
  target[i] = source[i];
496
- }
497
529
  }
498
530
  return target;
499
531
  }
500
532
 
533
+
501
534
  public static int[] copyOf(int[] source, int length) {
502
535
  int[] target = new int[length];
503
536
  for (int i = 0; i < target.length; i++) {
504
- if (i > source.length - 1) {
537
+ if (i > source.length - 1)
505
538
  target[i] = 0;
506
- } else {
539
+ else
507
540
  target[i] = source[i];
508
- }
509
541
  }
510
542
  return target;
511
543
  }
512
544
 
545
+
513
546
  // From Ken Turkowski, _Fixed-Point Square Root_, In Graphics Gems V
514
547
  public static int isqrt(int x) {
515
548
  int fracbits = 16;
@@ -533,6 +566,7 @@ public class LinePath {
533
566
  return root;
534
567
  }
535
568
 
569
+
536
570
  public static long lsqrt(long x) {
537
571
  int fracbits = 16;
538
572
 
@@ -555,18 +589,22 @@ public class LinePath {
555
589
  return root;
556
590
  }
557
591
 
592
+
558
593
  public static double hypot(double x, double y) {
559
594
  return Math.sqrt(x * x + y * y);
560
595
  }
561
596
 
597
+
562
598
  public static int hypot(int x, int y) {
563
599
  return (int) ((lsqrt((long) x * x + (long) y * y) + 128) >> 8);
564
600
  }
565
601
 
602
+
566
603
  public static long hypot(long x, long y) {
567
604
  return (lsqrt(x * x + y * y) + 128) >> 8;
568
605
  }
569
606
 
607
+
570
608
  static int FloatToS15_16(float flt) {
571
609
  flt = flt * 65536f + 0.5f;
572
610
  if (flt <= -(65536f * 65536f)) {
@@ -578,6 +616,7 @@ public class LinePath {
578
616
  }
579
617
  }
580
618
 
619
+
581
620
  static float S15_16ToFloat(int fix) {
582
621
  return (fix / 65536f);
583
622
  }