propane 3.4.0-java → 3.4.1-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.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -2
- data/.travis.yml +2 -2
- data/CHANGELOG.md +2 -0
- data/README.md +12 -7
- data/Rakefile +2 -2
- data/lib/propane.rb +2 -2
- data/lib/propane/app.rb +18 -9
- data/lib/propane/helper_methods.rb +1 -1
- data/lib/propane/runner.rb +1 -1
- data/lib/propane/version.rb +1 -1
- data/library/color_group/color_group.rb +26 -0
- data/library/dxf/dxf.rb +4 -0
- data/library/net/net.rb +5 -0
- data/library/video_event/video_event.rb +2 -1
- data/pom.rb +3 -3
- data/pom.xml +3 -3
- data/propane.gemspec +1 -1
- data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
- data/src/main/java/monkstone/ColorUtil.java +14 -0
- data/src/main/java/monkstone/MathToolModule.java +243 -194
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -0
- data/src/main/java/monkstone/slider/WheelHandler.java +6 -5
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +3 -2
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
- data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +10 -26
- data/src/main/java/processing/awt/PSurfaceAWT.java +1 -1
- data/src/main/java/processing/core/PApplet.java +1236 -599
- data/src/main/java/processing/core/PGraphics.java +59 -59
- data/src/main/java/processing/core/PImage.java +528 -129
- data/src/main/java/processing/core/PShape.java +10 -10
- data/src/main/java/processing/core/PVector.java +2 -2
- data/src/main/java/processing/core/ThinkDifferent.java +5 -7
- data/src/main/java/processing/dxf/RawDXF.java +404 -0
- data/src/main/java/processing/net/Client.java +744 -0
- data/src/main/java/processing/net/Server.java +388 -0
- data/src/main/java/processing/opengl/FontTexture.java +19 -20
- data/src/main/java/processing/opengl/FrameBuffer.java +27 -17
- data/src/main/java/processing/opengl/LinePath.java +512 -508
- data/src/main/java/processing/opengl/PGL.java +3106 -3066
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +4 -4
- data/src/main/java/processing/opengl/PShader.java +1442 -1341
- data/vendors/Rakefile +3 -27
- metadata +12 -25
- data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
- data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
- data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
- data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
- data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
- data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
- data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
- data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
- data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
- data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
- data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
- data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
- data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
- data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
- data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
- data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
- data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
- data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
- data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
- data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
@@ -248,9 +248,7 @@ public class FrameBuffer implements PConstants {
|
|
248
248
|
+ "buffers.");
|
249
249
|
}
|
250
250
|
|
251
|
-
|
252
|
-
colorBufferTex[i] = textures[i];
|
253
|
-
}
|
251
|
+
System.arraycopy(textures, 0, colorBufferTex, 0, numColorBuffers);
|
254
252
|
|
255
253
|
pg.pushFramebuffer();
|
256
254
|
pg.setFramebuffer(this);
|
@@ -428,13 +426,19 @@ public class FrameBuffer implements PConstants {
|
|
428
426
|
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glDepth);
|
429
427
|
|
430
428
|
int glConst = PGL.DEPTH_COMPONENT16;
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
429
|
+
switch (depthBits) {
|
430
|
+
case 16:
|
431
|
+
glConst = PGL.DEPTH_COMPONENT16;
|
432
|
+
break;
|
433
|
+
case 24:
|
434
|
+
glConst = PGL.DEPTH_COMPONENT24;
|
435
|
+
break;
|
436
|
+
case 32:
|
437
|
+
glConst = PGL.DEPTH_COMPONENT32;
|
438
|
+
break;
|
439
|
+
default:
|
440
|
+
break;
|
441
|
+
}
|
438
442
|
|
439
443
|
if (multisample) {
|
440
444
|
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
|
@@ -464,13 +468,19 @@ public class FrameBuffer implements PConstants {
|
|
464
468
|
pgl.bindRenderbuffer(PGL.RENDERBUFFER, glStencil);
|
465
469
|
|
466
470
|
int glConst = PGL.STENCIL_INDEX1;
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
471
|
+
switch (stencilBits) {
|
472
|
+
case 1:
|
473
|
+
glConst = PGL.STENCIL_INDEX1;
|
474
|
+
break;
|
475
|
+
case 4:
|
476
|
+
glConst = PGL.STENCIL_INDEX4;
|
477
|
+
break;
|
478
|
+
case 8:
|
479
|
+
glConst = PGL.STENCIL_INDEX8;
|
480
|
+
break;
|
481
|
+
default:
|
482
|
+
break;
|
483
|
+
}
|
474
484
|
if (multisample) {
|
475
485
|
pgl.renderbufferStorageMultisample(PGL.RENDERBUFFER, nsamples, glConst,
|
476
486
|
width, height);
|
@@ -35,546 +35,550 @@ import processing.core.PMatrix2D;
|
|
35
35
|
*/
|
36
36
|
public class LinePath {
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
38
|
+
/**
|
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.
|
43
|
+
*/
|
44
|
+
public static final int WIND_EVEN_ODD = 0;
|
45
|
+
|
46
|
+
/**
|
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.
|
52
|
+
*/
|
53
|
+
public static final int WIND_NON_ZERO = 1;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Starts segment at a given position.
|
57
|
+
*/
|
58
|
+
public static final byte SEG_MOVETO = 0;
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Extends segment by adding a line to a given position.
|
62
|
+
*/
|
63
|
+
public static final byte SEG_LINETO = 1;
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Closes segment at current position.
|
67
|
+
*/
|
68
|
+
public static final byte SEG_CLOSE = 2;
|
69
|
+
|
70
|
+
/**
|
71
|
+
* Joins path segments by extending their outside edges until they meet.
|
72
|
+
*/
|
73
|
+
public final static int JOIN_MITER = 0;
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Joins path segments by rounding off the corner at a radius of half the line
|
77
|
+
* width.
|
78
|
+
*/
|
79
|
+
public final static int JOIN_ROUND = 1;
|
80
|
+
|
81
|
+
/**
|
82
|
+
* Joins path segments by connecting the outer corners of their wide outlines
|
83
|
+
* with a straight segment.
|
84
|
+
*/
|
85
|
+
public final static int JOIN_BEVEL = 2;
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Ends unclosed subpaths and dash segments with no added decoration.
|
89
|
+
*/
|
90
|
+
public final static int CAP_BUTT = 0;
|
91
|
+
|
92
|
+
/**
|
93
|
+
* Ends unclosed subpaths and dash segments with a round decoration that has a
|
94
|
+
* radius equal to half of the width of the pen.
|
95
|
+
*/
|
96
|
+
public final static int CAP_ROUND = 1;
|
97
|
+
|
98
|
+
/**
|
99
|
+
* Ends unclosed subpaths and dash segments with a square projection that
|
100
|
+
* extends beyond the end of the segment to a distance equal to half of the
|
101
|
+
* line width.
|
102
|
+
*/
|
103
|
+
public final static int CAP_SQUARE = 2;
|
104
|
+
|
105
|
+
private static PMatrix2D identity = new PMatrix2D();
|
106
|
+
|
107
|
+
private static float defaultMiterlimit = 10.0f;
|
108
|
+
|
109
|
+
static final int INIT_SIZE = 20;
|
110
|
+
|
111
|
+
static final int EXPAND_MAX = 500;
|
112
|
+
|
113
|
+
protected byte[] pointTypes;
|
114
|
+
|
115
|
+
protected float[] floatCoords;
|
116
|
+
|
117
|
+
protected int[] pointColors;
|
118
|
+
|
119
|
+
protected int numTypes;
|
120
|
+
|
121
|
+
protected int numCoords;
|
122
|
+
|
123
|
+
protected int windingRule;
|
124
|
+
|
125
|
+
/**
|
126
|
+
* Constructs a new empty single precision {@code LinePath} object with a
|
127
|
+
* default winding rule of {@link #WIND_NON_ZERO}.
|
128
|
+
*/
|
129
|
+
public LinePath() {
|
130
|
+
this(WIND_NON_ZERO, INIT_SIZE);
|
131
|
+
}
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Constructs a new empty single precision {@code LinePath} object with the
|
135
|
+
* specified winding rule to control operations that require the interior of
|
136
|
+
* the path to be defined.
|
137
|
+
*
|
138
|
+
* @param rule the winding rule
|
139
|
+
* @see #WIND_EVEN_ODD
|
140
|
+
* @see #WIND_NON_ZERO
|
141
|
+
*/
|
142
|
+
public LinePath(int rule) {
|
143
|
+
this(rule, INIT_SIZE);
|
144
|
+
}
|
145
|
+
|
146
|
+
/**
|
147
|
+
* Constructs a new {@code LinePath} object from the given specified initial
|
148
|
+
* values. This method is only intended for internal use and should not be
|
149
|
+
* made public if the other constructors for this class are ever exposed.
|
150
|
+
*
|
151
|
+
* @param rule the winding rule
|
152
|
+
* @param initialCapacity the size to make the initial array to store the path
|
153
|
+
* segment types
|
154
|
+
*/
|
155
|
+
public LinePath(int rule, int initialCapacity) {
|
156
|
+
setWindingRule(rule);
|
157
|
+
this.pointTypes = new byte[initialCapacity];
|
158
|
+
floatCoords = new float[initialCapacity * 2];
|
159
|
+
pointColors = new int[initialCapacity];
|
160
|
+
}
|
161
|
+
|
162
|
+
void needRoom(boolean needMove, int newPoints) {
|
163
|
+
if (needMove && numTypes == 0) {
|
164
|
+
throw new RuntimeException("missing initial moveto "
|
165
|
+
+ "in path definition");
|
131
166
|
}
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
* @see #WIND_EVEN_ODD
|
140
|
-
* @see #WIND_NON_ZERO
|
141
|
-
*/
|
142
|
-
public LinePath(int rule) {
|
143
|
-
this(rule, INIT_SIZE);
|
167
|
+
int size = pointTypes.length;
|
168
|
+
if (numTypes >= size) {
|
169
|
+
int grow = size;
|
170
|
+
if (grow > EXPAND_MAX) {
|
171
|
+
grow = EXPAND_MAX;
|
172
|
+
}
|
173
|
+
pointTypes = copyOf(pointTypes, size + grow);
|
144
174
|
}
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
public LinePath(int rule, int initialCapacity) {
|
156
|
-
setWindingRule(rule);
|
157
|
-
this.pointTypes = new byte[initialCapacity];
|
158
|
-
floatCoords = new float[initialCapacity * 2];
|
159
|
-
pointColors = new int[initialCapacity];
|
175
|
+
size = floatCoords.length;
|
176
|
+
if (numCoords + newPoints * 2 > size) {
|
177
|
+
int grow = size;
|
178
|
+
if (grow > EXPAND_MAX * 2) {
|
179
|
+
grow = EXPAND_MAX * 2;
|
180
|
+
}
|
181
|
+
if (grow < newPoints * 2) {
|
182
|
+
grow = newPoints * 2;
|
183
|
+
}
|
184
|
+
floatCoords = copyOf(floatCoords, size + grow);
|
160
185
|
}
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
grow = EXPAND_MAX;
|
172
|
-
}
|
173
|
-
pointTypes = copyOf(pointTypes, size + grow);
|
174
|
-
}
|
175
|
-
size = floatCoords.length;
|
176
|
-
if (numCoords + newPoints * 2 > size) {
|
177
|
-
int grow = size;
|
178
|
-
if (grow > EXPAND_MAX * 2) {
|
179
|
-
grow = EXPAND_MAX * 2;
|
180
|
-
}
|
181
|
-
if (grow < newPoints * 2) {
|
182
|
-
grow = newPoints * 2;
|
183
|
-
}
|
184
|
-
floatCoords = copyOf(floatCoords, size + grow);
|
185
|
-
}
|
186
|
-
size = pointColors.length;
|
187
|
-
if (numCoords / 2 + newPoints > size) {
|
188
|
-
int grow = size;
|
189
|
-
if (grow > EXPAND_MAX) {
|
190
|
-
grow = EXPAND_MAX;
|
191
|
-
}
|
192
|
-
if (grow < newPoints) {
|
193
|
-
grow = newPoints;
|
194
|
-
}
|
195
|
-
pointColors = copyOf(pointColors, size + grow);
|
196
|
-
}
|
186
|
+
size = pointColors.length;
|
187
|
+
if (numCoords / 2 + newPoints > size) {
|
188
|
+
int grow = size;
|
189
|
+
if (grow > EXPAND_MAX) {
|
190
|
+
grow = EXPAND_MAX;
|
191
|
+
}
|
192
|
+
if (grow < newPoints) {
|
193
|
+
grow = newPoints;
|
194
|
+
}
|
195
|
+
pointColors = copyOf(pointColors, size + grow);
|
197
196
|
}
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
197
|
+
}
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Adds a point to the path by moving to the specified coordinates specified
|
201
|
+
* in float precision.
|
202
|
+
* <p>
|
203
|
+
* This method provides a single precision variant of the double precision
|
204
|
+
* {@code moveTo()} method on the base {@code LinePath} class.
|
205
|
+
*
|
206
|
+
* @param x the specified X coordinate
|
207
|
+
* @param y the specified Y coordinate
|
208
|
+
* @param c
|
209
|
+
* @see LinePath#moveTo
|
210
|
+
*/
|
211
|
+
public final void moveTo(float x, float y, int c) {
|
212
|
+
if (numTypes > 0 && pointTypes[numTypes - 1] == SEG_MOVETO) {
|
213
|
+
floatCoords[numCoords - 2] = x;
|
214
|
+
floatCoords[numCoords - 1] = y;
|
215
|
+
pointColors[numCoords / 2 - 1] = c;
|
216
|
+
} else {
|
217
|
+
needRoom(false, 1);
|
218
|
+
pointTypes[numTypes++] = SEG_MOVETO;
|
219
|
+
floatCoords[numCoords++] = x;
|
220
|
+
floatCoords[numCoords++] = y;
|
221
|
+
pointColors[numCoords / 2 - 1] = c;
|
222
222
|
}
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
223
|
+
}
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Adds a point to the path by drawing a straight line from the current
|
227
|
+
* coordinates to the new specified coordinates specified in float precision.
|
228
|
+
* <p>
|
229
|
+
* This method provides a single precision variant of the double precision
|
230
|
+
* {@code lineTo()} method on the base {@code LinePath} class.
|
231
|
+
*
|
232
|
+
* @param x the specified X coordinate
|
233
|
+
* @param y the specified Y coordinate
|
234
|
+
* @param c
|
235
|
+
* @see LinePath#lineTo
|
236
|
+
*/
|
237
|
+
public final void lineTo(float x, float y, int c) {
|
238
|
+
needRoom(true, 1);
|
239
|
+
pointTypes[numTypes++] = SEG_LINETO;
|
240
|
+
floatCoords[numCoords++] = x;
|
241
|
+
floatCoords[numCoords++] = y;
|
242
|
+
pointColors[numCoords / 2 - 1] = c;
|
243
|
+
}
|
244
|
+
|
245
|
+
/**
|
246
|
+
* The iterator for this class is not multi-threaded safe, which means that
|
247
|
+
* 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
|
252
|
+
*/
|
253
|
+
public PathIterator getPathIterator() {
|
254
|
+
return new PathIterator(this);
|
255
|
+
}
|
256
|
+
|
257
|
+
/**
|
258
|
+
* Closes the current subpath by drawing a straight line back to the
|
259
|
+
* coordinates of the last {@code moveTo}. If the path is already closed then
|
260
|
+
* this method has no effect.
|
261
|
+
*/
|
262
|
+
public final void closePath() {
|
263
|
+
if (numTypes == 0 || pointTypes[numTypes - 1] != SEG_CLOSE) {
|
264
|
+
needRoom(false, 0);
|
265
|
+
pointTypes[numTypes++] = SEG_CLOSE;
|
242
266
|
}
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
267
|
+
}
|
268
|
+
|
269
|
+
/**
|
270
|
+
* Returns the fill style winding rule.
|
271
|
+
*
|
272
|
+
* @return an integer representing the current winding rule.
|
273
|
+
* @see #WIND_EVEN_ODD
|
274
|
+
* @see #WIND_NON_ZERO
|
275
|
+
* @see #setWindingRule
|
276
|
+
*/
|
277
|
+
public final int getWindingRule() {
|
278
|
+
return windingRule;
|
279
|
+
}
|
280
|
+
|
281
|
+
/**
|
282
|
+
* Sets the winding rule for this path to the specified value.
|
283
|
+
*
|
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}
|
287
|
+
* @see #getWindingRule
|
288
|
+
*/
|
289
|
+
public final void setWindingRule(int rule) {
|
290
|
+
if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) {
|
291
|
+
throw new IllegalArgumentException("winding rule must be "
|
292
|
+
+ "WIND_EVEN_ODD or " + "WIND_NON_ZERO");
|
252
293
|
}
|
294
|
+
windingRule = rule;
|
295
|
+
}
|
253
296
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
needRoom(false, 0);
|
262
|
-
pointTypes[numTypes++] = SEG_CLOSE;
|
263
|
-
}
|
264
|
-
}
|
265
|
-
|
266
|
-
/**
|
267
|
-
* Returns the fill style winding rule.
|
268
|
-
*
|
269
|
-
* @return an integer representing the current winding rule.
|
270
|
-
* @see #WIND_EVEN_ODD
|
271
|
-
* @see #WIND_NON_ZERO
|
272
|
-
* @see #setWindingRule
|
273
|
-
*/
|
274
|
-
public final int getWindingRule() {
|
275
|
-
return windingRule;
|
276
|
-
}
|
277
|
-
|
278
|
-
/**
|
279
|
-
* Sets the winding rule for this path to the specified value.
|
280
|
-
*
|
281
|
-
* @param rule an integer representing the specified winding rule
|
282
|
-
* @exception IllegalArgumentException if {@code rule} is not either
|
283
|
-
* {@link #WIND_EVEN_ODD} or {@link #WIND_NON_ZERO}
|
284
|
-
* @see #getWindingRule
|
285
|
-
*/
|
286
|
-
public final void setWindingRule(int rule) {
|
287
|
-
if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) {
|
288
|
-
throw new IllegalArgumentException("winding rule must be "
|
289
|
-
+ "WIND_EVEN_ODD or " + "WIND_NON_ZERO");
|
290
|
-
}
|
291
|
-
windingRule = rule;
|
292
|
-
}
|
293
|
-
|
294
|
-
/**
|
295
|
-
* Resets the path to empty. The append position is set back to the
|
296
|
-
* beginning of the path and all coordinates and point types are forgotten.
|
297
|
-
*/
|
298
|
-
public final void reset() {
|
299
|
-
numTypes = numCoords = 0;
|
300
|
-
}
|
301
|
-
|
302
|
-
static public class PathIterator {
|
303
|
-
|
304
|
-
float floatCoords[];
|
305
|
-
|
306
|
-
int typeIdx;
|
307
|
-
|
308
|
-
int pointIdx;
|
309
|
-
|
310
|
-
int colorIdx;
|
297
|
+
/**
|
298
|
+
* Resets the path to empty. The append position is set back to the beginning
|
299
|
+
* of the path and all coordinates and point types are forgotten.
|
300
|
+
*/
|
301
|
+
public final void reset() {
|
302
|
+
numTypes = numCoords = 0;
|
303
|
+
}
|
311
304
|
|
312
|
-
|
305
|
+
static public class PathIterator {
|
313
306
|
|
314
|
-
|
307
|
+
float floatCoords[];
|
315
308
|
|
316
|
-
|
317
|
-
this.path = p2df;
|
318
|
-
this.floatCoords = p2df.floatCoords;
|
319
|
-
pointIdx = 0;
|
320
|
-
colorIdx = 0;
|
321
|
-
}
|
309
|
+
int typeIdx;
|
322
310
|
|
323
|
-
|
324
|
-
int type = path.pointTypes[typeIdx];
|
325
|
-
int numCoords = curvecoords[type];
|
326
|
-
if (numCoords > 0) {
|
327
|
-
System.arraycopy(floatCoords, pointIdx, coords, 0, numCoords);
|
328
|
-
int color = path.pointColors[colorIdx];
|
329
|
-
coords[numCoords + 0] = (color >> 24) & 0xFF;
|
330
|
-
coords[numCoords + 1] = (color >> 16) & 0xFF;
|
331
|
-
coords[numCoords + 2] = (color >> 8) & 0xFF;
|
332
|
-
coords[numCoords + 3] = (color >> 0) & 0xFF;
|
333
|
-
}
|
334
|
-
return type;
|
335
|
-
}
|
311
|
+
int pointIdx;
|
336
312
|
|
337
|
-
|
338
|
-
int type = path.pointTypes[typeIdx];
|
339
|
-
int numCoords = curvecoords[type];
|
340
|
-
if (numCoords > 0) {
|
341
|
-
for (int i = 0; i < numCoords; i++) {
|
342
|
-
coords[i] = floatCoords[pointIdx + i];
|
343
|
-
}
|
344
|
-
int color = path.pointColors[colorIdx];
|
345
|
-
coords[numCoords + 0] = (color >> 24) & 0xFF;
|
346
|
-
coords[numCoords + 1] = (color >> 16) & 0xFF;
|
347
|
-
coords[numCoords + 2] = (color >> 8) & 0xFF;
|
348
|
-
coords[numCoords + 3] = (color >> 0) & 0xFF;
|
349
|
-
}
|
350
|
-
return type;
|
351
|
-
}
|
313
|
+
int colorIdx;
|
352
314
|
|
353
|
-
|
354
|
-
return path.getWindingRule();
|
355
|
-
}
|
315
|
+
LinePath path;
|
356
316
|
|
357
|
-
|
358
|
-
return (typeIdx >= path.numTypes);
|
359
|
-
}
|
317
|
+
static final int[] CURVE_COORDS = {2, 2, 0};
|
360
318
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
}
|
367
|
-
}
|
319
|
+
PathIterator(LinePath p2df) {
|
320
|
+
this.path = p2df;
|
321
|
+
this.floatCoords = p2df.floatCoords;
|
322
|
+
pointIdx = 0;
|
323
|
+
colorIdx = 0;
|
368
324
|
}
|
369
325
|
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
/**
|
384
|
-
* Constructs a solid <code>LinePath</code> with the specified attributes.
|
385
|
-
*
|
386
|
-
* @param src the original path to be stroked
|
387
|
-
* @param weight the weight of the stroked path
|
388
|
-
* @param caps the decoration of the ends of the segments in the path
|
389
|
-
* @param join the decoration applied where path segments meet
|
390
|
-
* @param miterlimit
|
391
|
-
* @param transform
|
392
|
-
*
|
393
|
-
*/
|
394
|
-
static public LinePath createStrokedPath(LinePath src, float weight,
|
395
|
-
int caps, int join,
|
396
|
-
float miterlimit, PMatrix2D transform) {
|
397
|
-
final LinePath dest = new LinePath();
|
398
|
-
|
399
|
-
strokeTo(src, weight, caps, join, miterlimit, transform, new LineStroker() {
|
400
|
-
@Override
|
401
|
-
public void moveTo(int x0, int y0, int c0) {
|
402
|
-
dest.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0), c0);
|
403
|
-
}
|
404
|
-
|
405
|
-
@Override
|
406
|
-
public void lineJoin() {
|
407
|
-
}
|
408
|
-
|
409
|
-
@Override
|
410
|
-
public void lineTo(int x1, int y1, int c1) {
|
411
|
-
dest.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1), c1);
|
412
|
-
}
|
413
|
-
|
414
|
-
@Override
|
415
|
-
public void close() {
|
416
|
-
dest.closePath();
|
417
|
-
}
|
418
|
-
|
419
|
-
@Override
|
420
|
-
public void end() {
|
421
|
-
}
|
422
|
-
});
|
423
|
-
|
424
|
-
return dest;
|
425
|
-
}
|
426
|
-
|
427
|
-
private static void strokeTo(LinePath src, float width, int caps, int join,
|
428
|
-
float miterlimit, PMatrix2D transform,
|
429
|
-
LineStroker lsink) {
|
430
|
-
lsink = new LineStroker(lsink, FloatToS15_16(width), caps, join,
|
431
|
-
FloatToS15_16(miterlimit),
|
432
|
-
transform == null ? identity : transform);
|
433
|
-
|
434
|
-
PathIterator pi = src.getPathIterator();
|
435
|
-
pathTo(pi, lsink);
|
326
|
+
public int currentSegment(float[] coords) {
|
327
|
+
int type = path.pointTypes[typeIdx];
|
328
|
+
int numCoords = CURVE_COORDS[type];
|
329
|
+
if (numCoords > 0) {
|
330
|
+
System.arraycopy(floatCoords, pointIdx, coords, 0, numCoords);
|
331
|
+
int color = path.pointColors[colorIdx];
|
332
|
+
coords[numCoords + 0] = (color >> 24) & 0xFF;
|
333
|
+
coords[numCoords + 1] = (color >> 16) & 0xFF;
|
334
|
+
coords[numCoords + 2] = (color >> 8) & 0xFF;
|
335
|
+
coords[numCoords + 3] = (color) & 0xFF;
|
336
|
+
}
|
337
|
+
return type;
|
436
338
|
}
|
437
339
|
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
color = ((int) coords[2] << 24)
|
445
|
-
| ((int) coords[3] << 16)
|
446
|
-
| ((int) coords[4] << 8)
|
447
|
-
| (int) coords[5];
|
448
|
-
lsink.moveTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
|
449
|
-
break;
|
450
|
-
case SEG_LINETO:
|
451
|
-
color = ((int) coords[2] << 24)
|
452
|
-
| ((int) coords[3] << 16)
|
453
|
-
| ((int) coords[4] << 8)
|
454
|
-
| (int) coords[5];
|
455
|
-
lsink.lineJoin();
|
456
|
-
lsink.lineTo(FloatToS15_16(coords[0]), FloatToS15_16(coords[1]), color);
|
457
|
-
break;
|
458
|
-
case SEG_CLOSE:
|
459
|
-
lsink.lineJoin();
|
460
|
-
lsink.close();
|
461
|
-
break;
|
462
|
-
default:
|
463
|
-
throw new InternalError("unknown flattened segment type");
|
464
|
-
}
|
465
|
-
pi.next();
|
340
|
+
public int currentSegment(double[] coords) {
|
341
|
+
int type = path.pointTypes[typeIdx];
|
342
|
+
int numCoords = CURVE_COORDS[type];
|
343
|
+
if (numCoords > 0) {
|
344
|
+
for (int i = 0; i < numCoords; i++) {
|
345
|
+
coords[i] = floatCoords[pointIdx + i];
|
466
346
|
}
|
467
|
-
|
347
|
+
int color = path.pointColors[colorIdx];
|
348
|
+
coords[numCoords + 0] = (color >> 24) & 0xFF;
|
349
|
+
coords[numCoords + 1] = (color >> 16) & 0xFF;
|
350
|
+
coords[numCoords + 2] = (color >> 8) & 0xFF;
|
351
|
+
coords[numCoords + 3] = (color) & 0xFF;
|
352
|
+
}
|
353
|
+
return type;
|
468
354
|
}
|
469
355
|
|
470
|
-
|
471
|
-
|
472
|
-
// Utility methods
|
473
|
-
public static float[] copyOf(float[] source, int length) {
|
474
|
-
float[] target = new float[length];
|
475
|
-
for (int i = 0; i < target.length; i++) {
|
476
|
-
if (i > source.length - 1) {
|
477
|
-
target[i] = 0f;
|
478
|
-
} else {
|
479
|
-
target[i] = source[i];
|
480
|
-
}
|
481
|
-
}
|
482
|
-
return target;
|
483
|
-
}
|
484
|
-
|
485
|
-
public static byte[] copyOf(byte[] source, int length) {
|
486
|
-
byte[] target = new byte[length];
|
487
|
-
for (int i = 0; i < target.length; i++) {
|
488
|
-
if (i > source.length - 1) {
|
489
|
-
target[i] = 0;
|
490
|
-
} else {
|
491
|
-
target[i] = source[i];
|
492
|
-
}
|
493
|
-
}
|
494
|
-
return target;
|
356
|
+
public int getWindingRule() {
|
357
|
+
return path.getWindingRule();
|
495
358
|
}
|
496
359
|
|
497
|
-
public
|
498
|
-
|
499
|
-
for (int i = 0; i < target.length; i++) {
|
500
|
-
if (i > source.length - 1) {
|
501
|
-
target[i] = 0;
|
502
|
-
} else {
|
503
|
-
target[i] = source[i];
|
504
|
-
}
|
505
|
-
}
|
506
|
-
return target;
|
360
|
+
public boolean isDone() {
|
361
|
+
return (typeIdx >= path.numTypes);
|
507
362
|
}
|
508
363
|
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
int remLo = x;
|
516
|
-
int count = 15 + fracbits / 2;
|
517
|
-
|
518
|
-
do {
|
519
|
-
remHi = (remHi << 2) | (remLo >>> 30); // N.B. - unsigned shift R
|
520
|
-
remLo <<= 2;
|
521
|
-
root <<= 1;
|
522
|
-
int testdiv = (root << 1) + 1;
|
523
|
-
if (remHi >= testdiv) {
|
524
|
-
remHi -= testdiv;
|
525
|
-
root++;
|
526
|
-
}
|
527
|
-
} while (count-- != 0);
|
528
|
-
|
529
|
-
return root;
|
364
|
+
public void next() {
|
365
|
+
int type = path.pointTypes[typeIdx++];
|
366
|
+
if (0 < CURVE_COORDS[type]) {
|
367
|
+
pointIdx += CURVE_COORDS[type];
|
368
|
+
colorIdx++;
|
369
|
+
}
|
530
370
|
}
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
371
|
+
}
|
372
|
+
|
373
|
+
/////////////////////////////////////////////////////////////////////////////
|
374
|
+
//
|
375
|
+
// Stroked path methods
|
376
|
+
static public LinePath createStrokedPath(LinePath src, float weight,
|
377
|
+
int caps, int join) {
|
378
|
+
return createStrokedPath(src, weight, caps, join, defaultMiterlimit, null);
|
379
|
+
}
|
380
|
+
|
381
|
+
static public LinePath createStrokedPath(LinePath src, float weight,
|
382
|
+
int caps, int join, float miterlimit) {
|
383
|
+
return createStrokedPath(src, weight, caps, join, miterlimit, null);
|
384
|
+
}
|
385
|
+
|
386
|
+
/**
|
387
|
+
* Constructs a solid <code>LinePath</code> with the specified attributes.
|
388
|
+
*
|
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
|
393
|
+
* @param miterlimit
|
394
|
+
* @param transform
|
395
|
+
* @return
|
396
|
+
*
|
397
|
+
*/
|
398
|
+
static public LinePath createStrokedPath(LinePath src, float weight,
|
399
|
+
int caps, int join,
|
400
|
+
float miterlimit, PMatrix2D transform) {
|
401
|
+
final LinePath dest = new LinePath();
|
402
|
+
|
403
|
+
strokeTo(src, weight, caps, join, miterlimit, transform, new LineStroker() {
|
404
|
+
@Override
|
405
|
+
public void moveTo(int x0, int y0, int c0) {
|
406
|
+
dest.moveTo(S15_16ToFloat(x0), S15_16ToFloat(y0), c0);
|
407
|
+
}
|
408
|
+
|
409
|
+
@Override
|
410
|
+
public void lineJoin() {
|
411
|
+
}
|
412
|
+
|
413
|
+
@Override
|
414
|
+
public void lineTo(int x1, int y1, int c1) {
|
415
|
+
dest.lineTo(S15_16ToFloat(x1), S15_16ToFloat(y1), c1);
|
416
|
+
}
|
417
|
+
|
418
|
+
@Override
|
419
|
+
public void close() {
|
420
|
+
dest.closePath();
|
421
|
+
}
|
422
|
+
|
423
|
+
@Override
|
424
|
+
public void end() {
|
425
|
+
}
|
426
|
+
});
|
427
|
+
|
428
|
+
return dest;
|
429
|
+
}
|
430
|
+
|
431
|
+
private static void strokeTo(LinePath src, float width, int caps, int join,
|
432
|
+
float miterlimit, PMatrix2D transform,
|
433
|
+
LineStroker lsink) {
|
434
|
+
lsink = new LineStroker(lsink, FloatToS15_16(width), caps, join,
|
435
|
+
FloatToS15_16(miterlimit),
|
436
|
+
transform == null ? identity : transform);
|
437
|
+
|
438
|
+
PathIterator pi = src.getPathIterator();
|
439
|
+
pathTo(pi, lsink);
|
440
|
+
}
|
441
|
+
|
442
|
+
private static void pathTo(PathIterator pi, LineStroker lsink) {
|
443
|
+
float coords[] = new float[6];
|
444
|
+
while (!pi.isDone()) {
|
445
|
+
int color;
|
446
|
+
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");
|
468
|
+
}
|
469
|
+
pi.next();
|
552
470
|
}
|
553
|
-
|
554
|
-
|
555
|
-
|
471
|
+
lsink.end();
|
472
|
+
}
|
473
|
+
|
474
|
+
/////////////////////////////////////////////////////////////////////////////
|
475
|
+
//
|
476
|
+
// Utility methods
|
477
|
+
public static float[] copyOf(float[] source, int length) {
|
478
|
+
float[] target = new float[length];
|
479
|
+
for (int i = 0; i < target.length; i++) {
|
480
|
+
if (i > source.length - 1) {
|
481
|
+
target[i] = 0f;
|
482
|
+
} else {
|
483
|
+
target[i] = source[i];
|
484
|
+
}
|
556
485
|
}
|
557
|
-
|
558
|
-
|
559
|
-
|
486
|
+
return target;
|
487
|
+
}
|
488
|
+
|
489
|
+
public static byte[] copyOf(byte[] source, int length) {
|
490
|
+
byte[] target = new byte[length];
|
491
|
+
for (int i = 0; i < target.length; i++) {
|
492
|
+
if (i > source.length - 1) {
|
493
|
+
target[i] = 0;
|
494
|
+
} else {
|
495
|
+
target[i] = source[i];
|
496
|
+
}
|
560
497
|
}
|
561
|
-
|
562
|
-
|
563
|
-
|
498
|
+
return target;
|
499
|
+
}
|
500
|
+
|
501
|
+
public static int[] copyOf(int[] source, int length) {
|
502
|
+
int[] target = new int[length];
|
503
|
+
for (int i = 0; i < target.length; i++) {
|
504
|
+
if (i > source.length - 1) {
|
505
|
+
target[i] = 0;
|
506
|
+
} else {
|
507
|
+
target[i] = source[i];
|
508
|
+
}
|
564
509
|
}
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
510
|
+
return target;
|
511
|
+
}
|
512
|
+
|
513
|
+
// From Ken Turkowski, _Fixed-Point Square Root_, In Graphics Gems V
|
514
|
+
public static int isqrt(int x) {
|
515
|
+
int fracbits = 16;
|
516
|
+
|
517
|
+
int root = 0;
|
518
|
+
int remHi = 0;
|
519
|
+
int remLo = x;
|
520
|
+
int count = 15 + fracbits / 2;
|
521
|
+
|
522
|
+
do {
|
523
|
+
remHi = (remHi << 2) | (remLo >>> 30); // N.B. - unsigned shift R
|
524
|
+
remLo <<= 2;
|
525
|
+
root <<= 1;
|
526
|
+
int testdiv = (root << 1) + 1;
|
527
|
+
if (remHi >= testdiv) {
|
528
|
+
remHi -= testdiv;
|
529
|
+
root++;
|
530
|
+
}
|
531
|
+
} while (count-- != 0);
|
532
|
+
|
533
|
+
return root;
|
534
|
+
}
|
535
|
+
|
536
|
+
public static long lsqrt(long x) {
|
537
|
+
int fracbits = 16;
|
538
|
+
|
539
|
+
long root = 0;
|
540
|
+
long remHi = 0;
|
541
|
+
long remLo = x;
|
542
|
+
int count = 31 + fracbits / 2;
|
543
|
+
|
544
|
+
do {
|
545
|
+
remHi = (remHi << 2) | (remLo >>> 62); // N.B. - unsigned shift R
|
546
|
+
remLo <<= 2;
|
547
|
+
root <<= 1;
|
548
|
+
long testDiv = (root << 1) + 1;
|
549
|
+
if (remHi >= testDiv) {
|
550
|
+
remHi -= testDiv;
|
551
|
+
root++;
|
552
|
+
}
|
553
|
+
} while (count-- != 0);
|
554
|
+
|
555
|
+
return root;
|
556
|
+
}
|
557
|
+
|
558
|
+
public static double hypot(double x, double y) {
|
559
|
+
return Math.sqrt(x * x + y * y);
|
560
|
+
}
|
561
|
+
|
562
|
+
public static int hypot(int x, int y) {
|
563
|
+
return (int) ((lsqrt((long) x * x + (long) y * y) + 128) >> 8);
|
564
|
+
}
|
565
|
+
|
566
|
+
public static long hypot(long x, long y) {
|
567
|
+
return (lsqrt(x * x + y * y) + 128) >> 8;
|
568
|
+
}
|
569
|
+
|
570
|
+
static int FloatToS15_16(float flt) {
|
571
|
+
flt = flt * 65536f + 0.5f;
|
572
|
+
if (flt <= -(65536f * 65536f)) {
|
573
|
+
return Integer.MIN_VALUE;
|
574
|
+
} else if (flt >= (65536f * 65536f)) {
|
575
|
+
return Integer.MAX_VALUE;
|
576
|
+
} else {
|
577
|
+
return (int) Math.floor(flt);
|
575
578
|
}
|
579
|
+
}
|
576
580
|
|
577
|
-
|
578
|
-
|
579
|
-
|
581
|
+
static float S15_16ToFloat(int fix) {
|
582
|
+
return (fix / 65536f);
|
583
|
+
}
|
580
584
|
}
|