propane 3.10.0-java → 3.11.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  3. data/CHANGELOG.md +2 -0
  4. data/README.md +7 -7
  5. data/lib/propane/app.rb +2 -5
  6. data/lib/propane/helper_methods.rb +6 -6
  7. data/lib/propane/version.rb +1 -1
  8. data/lib/{propane-3.10.0.jar → propane-3.11.0.jar} +0 -0
  9. data/pom.rb +6 -6
  10. data/pom.xml +6 -6
  11. data/propane.gemspec +3 -3
  12. data/src/main/java/monkstone/noise/OpenSimplex2F.java +838 -737
  13. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -13
  14. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +14 -28
  15. data/src/main/java/processing/awt/PImageAWT.java +6 -4
  16. data/src/main/java/processing/core/PApplet.java +71 -59
  17. data/src/main/java/processing/core/PImage.java +14 -14
  18. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -13
  19. data/src/main/java/processing/opengl/PShader.java +1 -6
  20. data/src/main/java/processing/opengl/PSurfaceJOGL.java +6 -6
  21. data/{lib/java/processing/opengl → src/main/resources}/cursors/arrow.png +0 -0
  22. data/{lib/java/processing/opengl → src/main/resources}/cursors/cross.png +0 -0
  23. data/{lib/java/processing/opengl → src/main/resources}/cursors/hand.png +0 -0
  24. data/{lib/java/processing/opengl → src/main/resources}/cursors/license.txt +0 -0
  25. data/{lib/java/processing/opengl → src/main/resources}/cursors/move.png +0 -0
  26. data/{lib/java/processing/opengl → src/main/resources}/cursors/text.png +0 -0
  27. data/{lib/java/processing/opengl → src/main/resources}/cursors/wait.png +0 -0
  28. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorFrag.glsl +0 -0
  29. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorVert.glsl +0 -0
  30. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightFrag.glsl +0 -0
  31. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightVert.glsl +0 -0
  32. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineFrag.glsl +0 -0
  33. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineVert.glsl +0 -0
  34. data/{lib/java/processing/opengl → src/main/resources}/shaders/MaskFrag.glsl +0 -0
  35. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointFrag.glsl +0 -0
  36. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointVert.glsl +0 -0
  37. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexFrag.glsl +0 -0
  38. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightFrag.glsl +0 -0
  39. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightVert.glsl +0 -0
  40. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexVert.glsl +0 -0
  41. data/test/test_helper.rb +1 -0
  42. data/vendors/Rakefile +1 -1
  43. metadata +29 -155
  44. data/lib/java/japplemenubar/JAppleMenuBar.java +0 -88
  45. data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  46. data/lib/java/monkstone/ColorUtil.java +0 -127
  47. data/lib/java/monkstone/MathToolModule.java +0 -287
  48. data/lib/java/monkstone/PropaneLibrary.java +0 -46
  49. data/lib/java/monkstone/core/LibraryProxy.java +0 -136
  50. data/lib/java/monkstone/fastmath/DegLutTables.java +0 -111
  51. data/lib/java/monkstone/fastmath/Deglut.java +0 -71
  52. data/lib/java/monkstone/fastmath/package-info.java +0 -6
  53. data/lib/java/monkstone/filechooser/Chooser.java +0 -39
  54. data/lib/java/monkstone/noise/FastTerrain.java +0 -874
  55. data/lib/java/monkstone/noise/Noise.java +0 -90
  56. data/lib/java/monkstone/noise/NoiseGenerator.java +0 -75
  57. data/lib/java/monkstone/noise/NoiseMode.java +0 -28
  58. data/lib/java/monkstone/noise/OpenSimplex2F.java +0 -881
  59. data/lib/java/monkstone/noise/OpenSimplex2S.java +0 -1106
  60. data/lib/java/monkstone/noise/SmoothTerrain.java +0 -1099
  61. data/lib/java/monkstone/slider/CustomHorizontalSlider.java +0 -164
  62. data/lib/java/monkstone/slider/CustomVerticalSlider.java +0 -178
  63. data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +0 -145
  64. data/lib/java/monkstone/slider/SimpleSlider.java +0 -166
  65. data/lib/java/monkstone/slider/SimpleVerticalSlider.java +0 -157
  66. data/lib/java/monkstone/slider/Slider.java +0 -61
  67. data/lib/java/monkstone/slider/SliderBar.java +0 -245
  68. data/lib/java/monkstone/slider/SliderGroup.java +0 -56
  69. data/lib/java/monkstone/slider/WheelHandler.java +0 -35
  70. data/lib/java/monkstone/vecmath/GfxRender.java +0 -86
  71. data/lib/java/monkstone/vecmath/JRender.java +0 -56
  72. data/lib/java/monkstone/vecmath/ShapeRender.java +0 -87
  73. data/lib/java/monkstone/vecmath/package-info.java +0 -20
  74. data/lib/java/monkstone/vecmath/vec2/Vec2.java +0 -802
  75. data/lib/java/monkstone/vecmath/vec2/package-info.java +0 -6
  76. data/lib/java/monkstone/vecmath/vec3/Vec3.java +0 -727
  77. data/lib/java/monkstone/vecmath/vec3/package-info.java +0 -6
  78. data/lib/java/monkstone/videoevent/CaptureEvent.java +0 -27
  79. data/lib/java/monkstone/videoevent/MovieEvent.java +0 -32
  80. data/lib/java/monkstone/videoevent/package-info.java +0 -20
  81. data/lib/java/processing/awt/PGraphicsJava2D.java +0 -3040
  82. data/lib/java/processing/awt/PImageAWT.java +0 -377
  83. data/lib/java/processing/awt/PShapeJava2D.java +0 -387
  84. data/lib/java/processing/awt/PSurfaceAWT.java +0 -1581
  85. data/lib/java/processing/awt/ShimAWT.java +0 -581
  86. data/lib/java/processing/core/PApplet.java +0 -15156
  87. data/lib/java/processing/core/PConstants.java +0 -523
  88. data/lib/java/processing/core/PFont.java +0 -1126
  89. data/lib/java/processing/core/PGraphics.java +0 -8600
  90. data/lib/java/processing/core/PImage.java +0 -3377
  91. data/lib/java/processing/core/PMatrix.java +0 -208
  92. data/lib/java/processing/core/PMatrix2D.java +0 -562
  93. data/lib/java/processing/core/PMatrix3D.java +0 -890
  94. data/lib/java/processing/core/PShape.java +0 -3561
  95. data/lib/java/processing/core/PShapeOBJ.java +0 -483
  96. data/lib/java/processing/core/PShapeSVG.java +0 -2016
  97. data/lib/java/processing/core/PStyle.java +0 -63
  98. data/lib/java/processing/core/PSurface.java +0 -198
  99. data/lib/java/processing/core/PSurfaceNone.java +0 -431
  100. data/lib/java/processing/core/PVector.java +0 -1066
  101. data/lib/java/processing/core/ThinkDifferent.java +0 -115
  102. data/lib/java/processing/data/DoubleDict.java +0 -850
  103. data/lib/java/processing/data/DoubleList.java +0 -928
  104. data/lib/java/processing/data/FloatDict.java +0 -847
  105. data/lib/java/processing/data/FloatList.java +0 -936
  106. data/lib/java/processing/data/IntDict.java +0 -807
  107. data/lib/java/processing/data/IntList.java +0 -936
  108. data/lib/java/processing/data/JSONArray.java +0 -1260
  109. data/lib/java/processing/data/JSONObject.java +0 -2282
  110. data/lib/java/processing/data/JSONTokener.java +0 -435
  111. data/lib/java/processing/data/LongDict.java +0 -802
  112. data/lib/java/processing/data/LongList.java +0 -937
  113. data/lib/java/processing/data/Sort.java +0 -46
  114. data/lib/java/processing/data/StringDict.java +0 -613
  115. data/lib/java/processing/data/StringList.java +0 -800
  116. data/lib/java/processing/data/Table.java +0 -4936
  117. data/lib/java/processing/data/TableRow.java +0 -198
  118. data/lib/java/processing/data/XML.java +0 -1156
  119. data/lib/java/processing/dxf/RawDXF.java +0 -404
  120. data/lib/java/processing/event/Event.java +0 -125
  121. data/lib/java/processing/event/KeyEvent.java +0 -70
  122. data/lib/java/processing/event/MouseEvent.java +0 -114
  123. data/lib/java/processing/event/TouchEvent.java +0 -57
  124. data/lib/java/processing/javafx/PGraphicsFX2D.java +0 -32
  125. data/lib/java/processing/javafx/PSurfaceFX.java +0 -173
  126. data/lib/java/processing/net/Client.java +0 -744
  127. data/lib/java/processing/net/Server.java +0 -388
  128. data/lib/java/processing/opengl/FontTexture.java +0 -378
  129. data/lib/java/processing/opengl/FrameBuffer.java +0 -513
  130. data/lib/java/processing/opengl/LinePath.java +0 -627
  131. data/lib/java/processing/opengl/LineStroker.java +0 -681
  132. data/lib/java/processing/opengl/PGL.java +0 -3483
  133. data/lib/java/processing/opengl/PGraphics2D.java +0 -615
  134. data/lib/java/processing/opengl/PGraphics3D.java +0 -281
  135. data/lib/java/processing/opengl/PGraphicsOpenGL.java +0 -13753
  136. data/lib/java/processing/opengl/PJOGL.java +0 -2008
  137. data/lib/java/processing/opengl/PShader.java +0 -1484
  138. data/lib/java/processing/opengl/PShapeOpenGL.java +0 -5269
  139. data/lib/java/processing/opengl/PSurfaceJOGL.java +0 -1385
  140. data/lib/java/processing/opengl/Texture.java +0 -1696
  141. data/lib/java/processing/opengl/VertexBuffer.java +0 -88
  142. data/lib/java/processing/pdf/PGraphicsPDF.java +0 -581
  143. data/lib/java/processing/svg/PGraphicsSVG.java +0 -378
  144. data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
  145. data/src/main/java/processing/opengl/cursors/cross.png +0 -0
  146. data/src/main/java/processing/opengl/cursors/hand.png +0 -0
  147. data/src/main/java/processing/opengl/cursors/license.txt +0 -27
  148. data/src/main/java/processing/opengl/cursors/move.png +0 -0
  149. data/src/main/java/processing/opengl/cursors/text.png +0 -0
  150. data/src/main/java/processing/opengl/cursors/wait.png +0 -0
  151. data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +0 -32
  152. data/src/main/java/processing/opengl/shaders/ColorVert.glsl +0 -34
  153. data/src/main/java/processing/opengl/shaders/LightFrag.glsl +0 -33
  154. data/src/main/java/processing/opengl/shaders/LightVert.glsl +0 -151
  155. data/src/main/java/processing/opengl/shaders/LineFrag.glsl +0 -32
  156. data/src/main/java/processing/opengl/shaders/LineVert.glsl +0 -100
  157. data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +0 -40
  158. data/src/main/java/processing/opengl/shaders/PointFrag.glsl +0 -32
  159. data/src/main/java/processing/opengl/shaders/PointVert.glsl +0 -56
  160. data/src/main/java/processing/opengl/shaders/TexFrag.glsl +0 -37
  161. data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +0 -37
  162. data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +0 -157
  163. data/src/main/java/processing/opengl/shaders/TexVert.glsl +0 -38
@@ -1,627 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
5
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
- *
7
- * This code is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License version 2 only, as
9
- * published by the Free Software Foundation. Sun designates this
10
- * particular file as subject to the "Classpath" exception as provided
11
- * by Sun in the LICENSE file that accompanied this code.
12
- *
13
- * This code is distributed in the hope that it will be useful, but WITHOUT
14
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16
- * version 2 for more details (a copy is included in the LICENSE file that
17
- * accompanied this code).
18
- *
19
- * You should have received a copy of the GNU General Public License version
20
- * 2 along with this work; if not, write to the Free Software Foundation,
21
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22
- *
23
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24
- * CA 95054 USA or visit www.sun.com if you need additional information or
25
- * have any questions.
26
- */
27
-
28
- package processing.opengl;
29
-
30
- import processing.core.PMatrix2D;
31
-
32
- /**
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
37
- *
38
- */
39
- public class LinePath {
40
- /**
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.
46
- */
47
- public static final int WIND_EVEN_ODD = 0;
48
-
49
- /**
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.
57
- */
58
- public static final int WIND_NON_ZERO = 1;
59
-
60
- /**
61
- * Starts segment at a given position.
62
- */
63
- public static final byte SEG_MOVETO = 0;
64
-
65
- /**
66
- * Extends segment by adding a line to a given position.
67
- */
68
- public static final byte SEG_LINETO = 1;
69
-
70
- /**
71
- * Closes segment at current position.
72
- */
73
- public static final byte SEG_CLOSE = 2;
74
-
75
- /**
76
- * Joins path segments by extending their outside edges until they meet.
77
- */
78
- public final static int JOIN_MITER = 0;
79
-
80
- /**
81
- * Joins path segments by rounding off the corner at a radius of half the line
82
- * width.
83
- */
84
- public final static int JOIN_ROUND = 1;
85
-
86
- /**
87
- * Joins path segments by connecting the outer corners of their wide outlines
88
- * with a straight segment.
89
- */
90
- public final static int JOIN_BEVEL = 2;
91
-
92
- /**
93
- * Ends unclosed subpaths and dash segments with no added decoration.
94
- */
95
- public final static int CAP_BUTT = 0;
96
-
97
- /**
98
- * Ends unclosed subpaths and dash segments with a round decoration that has a
99
- * radius equal to half of the width of the pen.
100
- */
101
- public final static int CAP_ROUND = 1;
102
-
103
- /**
104
- * Ends unclosed subpaths and dash segments with a square projection that
105
- * extends beyond the end of the segment to a distance equal to half of the
106
- * line width.
107
- */
108
- public final static int CAP_SQUARE = 2;
109
-
110
- private static PMatrix2D identity = new PMatrix2D();
111
-
112
- private static float defaultMiterlimit = 10.0f;
113
-
114
- static final int INIT_SIZE = 20;
115
-
116
- static final int EXPAND_MAX = 500;
117
-
118
- protected byte[] pointTypes;
119
-
120
- protected float[] floatCoords;
121
-
122
- protected int[] pointColors;
123
-
124
- protected int numTypes;
125
-
126
- protected int numCoords;
127
-
128
- protected int windingRule;
129
-
130
-
131
- /**
132
- * Constructs a new empty single precision {@code LinePath} object with a
133
- * default winding rule of {@link #WIND_NON_ZERO}.
134
- */
135
- public LinePath() {
136
- this(WIND_NON_ZERO, INIT_SIZE);
137
- }
138
-
139
-
140
- /**
141
- * Constructs a new empty single precision {@code LinePath} object with the
142
- * specified winding rule to control operations that require the interior of
143
- * the path to be defined.
144
- *
145
- * @param rule
146
- * the winding rule
147
- * @see #WIND_EVEN_ODD
148
- * @see #WIND_NON_ZERO
149
- */
150
- public LinePath(int rule) {
151
- this(rule, INIT_SIZE);
152
- }
153
-
154
-
155
- /**
156
- * Constructs a new {@code LinePath} object from the given specified initial
157
- * values. This method is only intended for internal use and should not be
158
- * made public if the other constructors for this class are ever exposed.
159
- *
160
- * @param rule
161
- * the winding rule
162
- * @param initialCapacity
163
- * the size to make the initial array to store the path segment types
164
- */
165
- public LinePath(int rule, int initialCapacity) {
166
- setWindingRule(rule);
167
- this.pointTypes = new byte[initialCapacity];
168
- floatCoords = new float[initialCapacity * 2];
169
- pointColors = new int[initialCapacity];
170
- }
171
-
172
-
173
- void needRoom(boolean needMove, int newPoints) {
174
- if (needMove && numTypes == 0) {
175
- throw new RuntimeException("missing initial moveto "
176
- + "in path definition");
177
- }
178
- int size = pointTypes.length;
179
- if (numTypes >= size) {
180
- int grow = size;
181
- if (grow > EXPAND_MAX) {
182
- grow = EXPAND_MAX;
183
- }
184
- pointTypes = copyOf(pointTypes, size + grow);
185
- }
186
- size = floatCoords.length;
187
- if (numCoords + newPoints * 2 > size) {
188
- int grow = size;
189
- if (grow > EXPAND_MAX * 2) {
190
- grow = EXPAND_MAX * 2;
191
- }
192
- if (grow < newPoints * 2) {
193
- grow = newPoints * 2;
194
- }
195
- floatCoords = copyOf(floatCoords, size + grow);
196
- }
197
- size = pointColors.length;
198
- if (numCoords/2 + newPoints > size) {
199
- int grow = size;
200
- if (grow > EXPAND_MAX) {
201
- grow = EXPAND_MAX;
202
- }
203
- if (grow < newPoints) {
204
- grow = newPoints;
205
- }
206
- pointColors = copyOf(pointColors, size + grow);
207
- }
208
- }
209
-
210
-
211
- /**
212
- * Adds a point to the path by moving to the specified coordinates specified
213
- * in float precision.
214
- * <p>
215
- * This method provides a single precision variant of the double precision
216
- * {@code moveTo()} method on the base {@code LinePath} class.
217
- *
218
- * @param x
219
- * the specified X coordinate
220
- * @param y
221
- * the specified Y coordinate
222
- * @param c
223
- * @see LinePath#moveTo
224
- */
225
- public final void moveTo(float x, float y, int c) {
226
- if (numTypes > 0 && pointTypes[numTypes - 1] == SEG_MOVETO) {
227
- floatCoords[numCoords - 2] = x;
228
- floatCoords[numCoords - 1] = y;
229
- pointColors[numCoords/2-1] = c;
230
- } else {
231
- needRoom(false, 1);
232
- pointTypes[numTypes++] = SEG_MOVETO;
233
- floatCoords[numCoords++] = x;
234
- floatCoords[numCoords++] = y;
235
- pointColors[numCoords/2-1] = c;
236
- }
237
- }
238
-
239
-
240
- /**
241
- * Adds a point to the path by drawing a straight line from the current
242
- * coordinates to the new specified coordinates specified in float precision.
243
- * <p>
244
- * This method provides a single precision variant of the double precision
245
- * {@code lineTo()} method on the base {@code LinePath} class.
246
- *
247
- * @param x
248
- * the specified X coordinate
249
- * @param y
250
- * the specified Y coordinate
251
- * @param c
252
- * @see LinePath#lineTo
253
- */
254
- public final void lineTo(float x, float y, int c) {
255
- needRoom(true, 1);
256
- pointTypes[numTypes++] = SEG_LINETO;
257
- floatCoords[numCoords++] = x;
258
- floatCoords[numCoords++] = y;
259
- pointColors[numCoords/2-1] = c;
260
- }
261
-
262
-
263
- /**
264
- * The iterator for this class is not multi-threaded safe, which means that
265
- * the {@code LinePath} class does not guarantee that modifications to the
266
- * geometry of this {@code LinePath} object do not affect any iterations of that
267
- * geometry that are already in process.
268
- * @return
269
- */
270
- public PathIterator getPathIterator() {
271
- return new PathIterator(this);
272
- }
273
-
274
-
275
- /**
276
- * Closes the current subpath by drawing a straight line back to the
277
- * coordinates of the last {@code moveTo}. If the path is already closed then
278
- * this method has no effect.
279
- */
280
- public final void closePath() {
281
- if (numTypes == 0 || pointTypes[numTypes - 1] != SEG_CLOSE) {
282
- needRoom(false, 0);
283
- pointTypes[numTypes++] = SEG_CLOSE;
284
- }
285
- }
286
-
287
-
288
- /**
289
- * Returns the fill style winding rule.
290
- *
291
- * @return an integer representing the current winding rule.
292
- * @see #WIND_EVEN_ODD
293
- * @see #WIND_NON_ZERO
294
- * @see #setWindingRule
295
- */
296
- public final int getWindingRule() {
297
- return windingRule;
298
- }
299
-
300
-
301
- /**
302
- * Sets the winding rule for this path to the specified value.
303
- *
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}
309
- * @see #getWindingRule
310
- */
311
- public final void setWindingRule(int rule) {
312
- if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) {
313
- throw new IllegalArgumentException("winding rule must be "
314
- + "WIND_EVEN_ODD or " + "WIND_NON_ZERO");
315
- }
316
- windingRule = rule;
317
- }
318
-
319
-
320
- /**
321
- * Resets the path to empty. The append position is set back to the beginning
322
- * of the path and all coordinates and point types are forgotten.
323
- */
324
- public final void reset() {
325
- numTypes = numCoords = 0;
326
- }
327
-
328
-
329
- static public class PathIterator {
330
- float[] floatCoords;
331
-
332
- int typeIdx;
333
-
334
- int pointIdx;
335
-
336
- int colorIdx;
337
-
338
- LinePath path;
339
-
340
- static final int[] curvecoords = { 2, 2, 0 };
341
-
342
- PathIterator(LinePath p2df) {
343
- this.path = p2df;
344
- this.floatCoords = p2df.floatCoords;
345
- pointIdx = 0;
346
- colorIdx = 0;
347
- }
348
-
349
- public int currentSegment(float[] coords) {
350
- int type = path.pointTypes[typeIdx];
351
- int numCoords = curvecoords[type];
352
- if (numCoords > 0) {
353
- System.arraycopy(floatCoords, pointIdx, coords, 0, numCoords);
354
- int color = path.pointColors[colorIdx];
355
- coords[numCoords + 0] = (color >> 24) & 0xFF;
356
- coords[numCoords + 1] = (color >> 16) & 0xFF;
357
- coords[numCoords + 2] = (color >> 8) & 0xFF;
358
- coords[numCoords + 3] = (color) & 0xFF;
359
- }
360
- return type;
361
- }
362
-
363
- public int currentSegment(double[] coords) {
364
- int type = path.pointTypes[typeIdx];
365
- int numCoords = curvecoords[type];
366
- if (numCoords > 0) {
367
- for (int i = 0; i < numCoords; i++) {
368
- coords[i] = floatCoords[pointIdx + i];
369
- }
370
- int color = path.pointColors[colorIdx];
371
- coords[numCoords + 0] = (color >> 24) & 0xFF;
372
- coords[numCoords + 1] = (color >> 16) & 0xFF;
373
- coords[numCoords + 2] = (color >> 8) & 0xFF;
374
- coords[numCoords + 3] = (color) & 0xFF;
375
- }
376
- return type;
377
- }
378
-
379
- public int getWindingRule() {
380
- return path.getWindingRule();
381
- }
382
-
383
- public boolean isDone() {
384
- return (typeIdx >= path.numTypes);
385
- }
386
-
387
- public void next() {
388
- int type = path.pointTypes[typeIdx++];
389
- if (0 < curvecoords[type]) {
390
- pointIdx += curvecoords[type];
391
- colorIdx++;
392
- }
393
- }
394
- }
395
-
396
-
397
- /////////////////////////////////////////////////////////////////////////////
398
- //
399
- // Stroked path methods
400
-
401
-
402
- static public LinePath createStrokedPath(LinePath src, float weight,
403
- int caps, int join) {
404
- return createStrokedPath(src, weight, caps, join, defaultMiterlimit, null);
405
- }
406
-
407
-
408
- static public LinePath createStrokedPath(LinePath src, float weight,
409
- int caps, int join, float miterlimit) {
410
- return createStrokedPath(src, weight, caps, join, miterlimit, null);
411
- }
412
-
413
-
414
- /**
415
- * Constructs a solid <code>LinePath</code> with the specified attributes.
416
- *
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
425
- * @param miterlimit
426
- * @param transform
427
- * @return
428
- *
429
- */
430
- static public LinePath createStrokedPath(LinePath src, float weight,
431
- int caps, int join,
432
- float miterlimit, PMatrix2D transform) {
433
- final LinePath dest = new LinePath();
434
-
435
- strokeTo(src, weight, caps, join, miterlimit, transform, new LineStroker() {
436
- @Override
437
- public void moveTo(int x0, int y0, int c0) {
438
- dest.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0), c0);
439
- }
440
-
441
- @Override
442
- public void lineJoin() {
443
- }
444
-
445
- @Override
446
- public void lineTo(int x1, int y1, int c1) {
447
- dest.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1), c1);
448
- }
449
-
450
- @Override
451
- public void close() {
452
- dest.closePath();
453
- }
454
-
455
- @Override
456
- public void end() {
457
- }
458
- });
459
-
460
- return dest;
461
- }
462
-
463
-
464
- private static void strokeTo(LinePath src, float width, int caps, int join,
465
- float miterlimit, PMatrix2D transform,
466
- LineStroker lsink) {
467
- lsink = new LineStroker(lsink, FloatToS15_16(width), caps, join,
468
- FloatToS15_16(miterlimit),
469
- transform == null ? identity : transform);
470
-
471
- PathIterator pi = src.getPathIterator();
472
- pathTo(pi, lsink);
473
- }
474
-
475
-
476
- private static void pathTo(PathIterator pi, LineStroker lsink) {
477
- float[] coords = new float[6];
478
- while (!pi.isDone()) {
479
- int color;
480
- switch (pi.currentSegment(coords)) {
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");
502
- }
503
- pi.next();
504
- }
505
- lsink.end();
506
- }
507
-
508
-
509
- /////////////////////////////////////////////////////////////////////////////
510
- //
511
- // Utility methods
512
-
513
-
514
- public static float[] copyOf(float[] source, int length) {
515
- float[] target = new float[length];
516
- for (int i = 0; i < target.length; i++) {
517
- if (i > source.length - 1)
518
- target[i] = 0f;
519
- else
520
- target[i] = source[i];
521
- }
522
- return target;
523
- }
524
-
525
-
526
- public static byte[] copyOf(byte[] source, int length) {
527
- byte[] target = new byte[length];
528
- for (int i = 0; i < target.length; i++) {
529
- if (i > source.length - 1)
530
- target[i] = 0;
531
- else
532
- target[i] = source[i];
533
- }
534
- return target;
535
- }
536
-
537
-
538
- public static int[] copyOf(int[] source, int length) {
539
- int[] target = new int[length];
540
- for (int i = 0; i < target.length; i++) {
541
- if (i > source.length - 1)
542
- target[i] = 0;
543
- else
544
- target[i] = source[i];
545
- }
546
- return target;
547
- }
548
-
549
-
550
- // From Ken Turkowski, _Fixed-Point Square Root_, In Graphics Gems V
551
- public static int isqrt(int x) {
552
- int fracbits = 16;
553
-
554
- int root = 0;
555
- int remHi = 0;
556
- int remLo = x;
557
- int count = 15 + fracbits / 2;
558
-
559
- do {
560
- remHi = (remHi << 2) | (remLo >>> 30); // N.B. - unsigned shift R
561
- remLo <<= 2;
562
- root <<= 1;
563
- int testdiv = (root << 1) + 1;
564
- if (remHi >= testdiv) {
565
- remHi -= testdiv;
566
- root++;
567
- }
568
- } while (count-- != 0);
569
-
570
- return root;
571
- }
572
-
573
-
574
- public static long lsqrt(long x) {
575
- int fracbits = 16;
576
-
577
- long root = 0;
578
- long remHi = 0;
579
- long remLo = x;
580
- int count = 31 + fracbits / 2;
581
-
582
- do {
583
- remHi = (remHi << 2) | (remLo >>> 62); // N.B. - unsigned shift R
584
- remLo <<= 2;
585
- root <<= 1;
586
- long testDiv = (root << 1) + 1;
587
- if (remHi >= testDiv) {
588
- remHi -= testDiv;
589
- root++;
590
- }
591
- } while (count-- != 0);
592
-
593
- return root;
594
- }
595
-
596
-
597
- public static double hypot(double x, double y) {
598
- return Math.sqrt(x * x + y * y);
599
- }
600
-
601
-
602
- public static int hypot(int x, int y) {
603
- return (int) ((lsqrt((long) x * x + (long) y * y) + 128) >> 8);
604
- }
605
-
606
-
607
- public static long hypot(long x, long y) {
608
- return (lsqrt(x * x + y * y) + 128) >> 8;
609
- }
610
-
611
-
612
- static int FloatToS15_16(float flt) {
613
- flt = flt * 65536f + 0.5f;
614
- if (flt <= -(65536f * 65536f)) {
615
- return Integer.MIN_VALUE;
616
- } else if (flt >= (65536f * 65536f)) {
617
- return Integer.MAX_VALUE;
618
- } else {
619
- return (int) Math.floor(flt);
620
- }
621
- }
622
-
623
-
624
- static float S15_16ToFloat(int fix) {
625
- return (fix / 65536f);
626
- }
627
- }