propane 3.4.2-java → 3.5.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +2 -0
- data/README.md +15 -3
- data/Rakefile +9 -10
- data/bin/propane +3 -1
- data/lib/propane.rb +2 -1
- data/lib/propane/app.rb +2 -1
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +22 -22
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +10 -9
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +11 -5
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +2 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +2 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +2 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +2 -0
- data/pom.rb +46 -45
- data/pom.xml +4 -4
- data/propane.gemspec +8 -7
- data/src/main/java/monkstone/ColorUtil.java +1 -3
- data/src/main/java/monkstone/MathToolModule.java +1 -1
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -2
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +788 -283
- data/src/main/java/processing/awt/PImageAWT.java +260 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +56 -53
- data/src/main/java/processing/awt/PSurfaceAWT.java +309 -211
- data/src/main/java/processing/awt/ShimAWT.java +580 -0
- data/src/main/java/processing/core/PApplet.java +2877 -2098
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +930 -884
- data/src/main/java/processing/core/PGraphics.java +337 -309
- data/src/main/java/processing/core/PImage.java +1689 -1689
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +456 -410
- data/src/main/java/processing/core/PMatrix3D.java +755 -735
- data/src/main/java/processing/core/PShape.java +2910 -2656
- data/src/main/java/processing/core/PShapeOBJ.java +97 -94
- data/src/main/java/processing/core/PShapeSVG.java +1656 -1462
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +134 -97
- data/src/main/java/processing/core/PSurfaceNone.java +292 -218
- data/src/main/java/processing/core/PVector.java +991 -966
- data/src/main/java/processing/core/ThinkDifferent.java +12 -8
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3693 -3513
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +954 -880
- data/src/main/java/processing/event/Event.java +87 -67
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +87 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PSurfaceFX.java +26 -0
- data/src/main/java/processing/net/Client.java +20 -20
- data/src/main/java/processing/net/Server.java +9 -9
- data/src/main/java/processing/opengl/FontTexture.java +286 -266
- data/src/main/java/processing/opengl/FrameBuffer.java +390 -376
- data/src/main/java/processing/opengl/LinePath.java +130 -91
- data/src/main/java/processing/opengl/LineStroker.java +593 -582
- data/src/main/java/processing/opengl/PGL.java +645 -579
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12287 -12030
- data/src/main/java/processing/opengl/PJOGL.java +1743 -1672
- data/src/main/java/processing/opengl/PShader.java +345 -416
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4601 -4543
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1113 -1029
- data/src/main/java/processing/opengl/Texture.java +1489 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +35 -22
- data/vendors/Rakefile +28 -22
- metadata +13 -13
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- 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,
|
31
|
-
* composed by several disjoint polygonal segments.
|
32
|
-
* {@link PathIterator} class including all
|
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
|
40
|
-
* the interior of a path.
|
41
|
-
*
|
42
|
-
*
|
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
|
47
|
+
public static final int WIND_EVEN_ODD = 0;
|
45
48
|
|
46
49
|
/**
|
47
|
-
* The winding rule constant for specifying a non-zero rule
|
48
|
-
* the interior of a path.
|
49
|
-
*
|
50
|
-
*
|
51
|
-
*
|
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
|
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
|
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
|
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
|
152
|
-
*
|
153
|
-
*
|
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
|
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
|
207
|
-
*
|
208
|
-
* @param
|
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
|
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
|
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
|
233
|
-
*
|
234
|
-
* @param
|
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
|
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
|
-
*
|
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
|
285
|
-
*
|
286
|
-
*
|
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
|
-
|
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[]
|
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 =
|
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 >>
|
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 =
|
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 >>
|
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 <
|
367
|
-
pointIdx +=
|
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
|
-
|
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
|
-
|
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
|
390
|
-
*
|
391
|
-
* @param
|
392
|
-
*
|
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
|
-
|
400
|
-
|
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
|
-
|
433
|
-
|
461
|
+
float miterlimit, PMatrix2D transform,
|
462
|
+
LineStroker lsink) {
|
434
463
|
lsink = new LineStroker(lsink, FloatToS15_16(width), caps, join,
|
435
|
-
|
436
|
-
|
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
|
473
|
+
float[] coords = new float[6];
|
444
474
|
while (!pi.isDone()) {
|
445
475
|
int color;
|
446
476
|
switch (pi.currentSegment(coords)) {
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
}
|