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,681 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- * Copyright (c) 2007, Oracle and/or its affiliates. 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. Oracle designates this
10
- * particular file as subject to the "Classpath" exception as provided
11
- * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
24
- * or visit www.oracle.com if you need additional information or have any
25
- * questions.
26
- */
27
-
28
- package processing.opengl;
29
-
30
- import processing.core.PMatrix2D;
31
-
32
- public class LineStroker {
33
- private LineStroker output;
34
- private int capStyle;
35
- private int joinStyle;
36
- private int m00, m01;
37
- private int m10, m11;
38
- private int lineWidth2;
39
- private long scaledLineWidth2;
40
-
41
- // For any pen offset (pen_dx, pen_dy) that does not depend on
42
- // the line orientation, the pen should be transformed so that:
43
- //
44
- // pen_dx' = m00*pen_dx + m01*pen_dy
45
- // pen_dy' = m10*pen_dx + m11*pen_dy
46
- //
47
- // For a round pen, this means:
48
- //
49
- // pen_dx(r, theta) = r*cos(theta)
50
- // pen_dy(r, theta) = r*sin(theta)
51
- //
52
- // pen_dx'(r, theta) = r*(m00*cos(theta) + m01*sin(theta))
53
- // pen_dy'(r, theta) = r*(m10*cos(theta) + m11*sin(theta))
54
- private int numPenSegments;
55
- private int[] pen_dx;
56
- private int[] pen_dy;
57
-
58
- private boolean[] penIncluded;
59
- private int[] join;
60
- private int[] offset = new int[2];
61
- private int[] reverse = new int[100];
62
- private int[] miter = new int[2];
63
- private long miterLimitSq;
64
- private int prev;
65
- private int rindex;
66
- private boolean started;
67
- private boolean lineToOrigin;
68
- private boolean joinToOrigin;
69
- private int sx0, sy0, sx1, sy1, x0, y0;
70
- private int scolor0, pcolor0, color0;
71
- private int mx0, my0, omx, omy;
72
- private int px0, py0;
73
- private double m00_2_m01_2;
74
- private double m10_2_m11_2;
75
- private double m00_m10_m01_m11;
76
-
77
- /**
78
- * Empty constructor. <code>setOutput</code> and <code>setParameters</code>
79
- * must be called prior to calling any other methods.
80
- */
81
- public LineStroker() {
82
- }
83
-
84
- /**
85
- * Constructs a <code>LineStroker</code>.
86
- *
87
- * @param output
88
- * an output <code>LineStroker</code>.
89
- * @param lineWidth
90
- * the desired line width in pixels, in S15.16 format.
91
- * @param capStyle
92
- * the desired end cap style, one of <code>CAP_BUTT</code>,
93
- * <code>CAP_ROUND</code> or <code>CAP_SQUARE</code>.
94
- * @param joinStyle
95
- * the desired line join style, one of <code>JOIN_MITER</code>,
96
- * <code>JOIN_ROUND</code> or <code>JOIN_BEVEL</code>.
97
- * @param miterLimit
98
- * the desired miter limit, in S15.16 format.
99
- * @param transform
100
- * a <code>Transform4</code> object indicating the transform that has
101
- * been previously applied to all incoming coordinates. This is
102
- * required in order to produce consistently shaped end caps and
103
- * joins.
104
- */
105
- public LineStroker(LineStroker output, int lineWidth, int capStyle, int joinStyle,
106
- int miterLimit, PMatrix2D transform) {
107
- setOutput(output);
108
- setParameters(lineWidth, capStyle, joinStyle, miterLimit, transform);
109
- }
110
-
111
- /**
112
- * Sets the output <code>LineStroker</code> of this <code>LineStroker</code>.
113
- *
114
- * @param output
115
- * an output <code>LineStroker</code>.
116
- */
117
- public void setOutput(LineStroker output) {
118
- this.output = output;
119
- }
120
-
121
- /**
122
- * Sets the parameters of this <code>LineStroker</code>.
123
- *
124
- * @param lineWidth
125
- * the desired line width in pixels, in S15.16 format.
126
- * @param capStyle
127
- * the desired end cap style, one of <code>CAP_BUTT</code>,
128
- * <code>CAP_ROUND</code> or <code>CAP_SQUARE</code>.
129
- * @param joinStyle
130
- * the desired line join style, one of <code>JOIN_MITER</code>,
131
- * <code>JOIN_ROUND</code> or <code>JOIN_BEVEL</code>.
132
- * @param miterLimit
133
- * the desired miter limit, in S15.16 format.
134
- * @param transform
135
- * a <code>Transform4</code> object indicating the transform that has
136
- * been previously applied to all incoming coordinates. This is
137
- * required in order to produce consistently shaped end caps and
138
- * joins.
139
- */
140
- public void setParameters(int lineWidth, int capStyle, int joinStyle,
141
- int miterLimit, PMatrix2D transform) {
142
- this.m00 = LinePath.FloatToS15_16(transform.m00);
143
- this.m01 = LinePath.FloatToS15_16(transform.m01);
144
- this.m10 = LinePath.FloatToS15_16(transform.m10);
145
- this.m11 = LinePath.FloatToS15_16(transform.m11);
146
-
147
- this.lineWidth2 = lineWidth >> 1;
148
- this.scaledLineWidth2 = ((long) m00 * lineWidth2) >> 16;
149
- this.capStyle = capStyle;
150
- this.joinStyle = joinStyle;
151
-
152
- this.m00_2_m01_2 = (double) m00 * m00 + (double) m01 * m01;
153
- this.m10_2_m11_2 = (double) m10 * m10 + (double) m11 * m11;
154
- this.m00_m10_m01_m11 = (double) m00 * m10 + (double) m01 * m11;
155
-
156
- double dm00 = m00 / 65536.0;
157
- double dm01 = m01 / 65536.0;
158
- double dm10 = m10 / 65536.0;
159
- double dm11 = m11 / 65536.0;
160
- double determinant = dm00 * dm11 - dm01 * dm10;
161
-
162
- if (joinStyle == LinePath.JOIN_MITER) {
163
- double limit = (miterLimit / 65536.0) * (lineWidth2 / 65536.0)
164
- * determinant;
165
- double limitSq = limit * limit;
166
- this.miterLimitSq = (long) (limitSq * 65536.0 * 65536.0);
167
- }
168
-
169
- this.numPenSegments = (int) (3.14159f * lineWidth / 65536.0f);
170
- if (pen_dx == null || pen_dx.length < numPenSegments) {
171
- this.pen_dx = new int[numPenSegments];
172
- this.pen_dy = new int[numPenSegments];
173
- this.penIncluded = new boolean[numPenSegments];
174
- this.join = new int[2 * numPenSegments];
175
- }
176
-
177
- for (int i = 0; i < numPenSegments; i++) {
178
- double r = lineWidth / 2.0;
179
- double theta = i * 2 * Math.PI / numPenSegments;
180
-
181
- double cos = Math.cos(theta);
182
- double sin = Math.sin(theta);
183
- pen_dx[i] = (int) (r * (dm00 * cos + dm01 * sin));
184
- pen_dy[i] = (int) (r * (dm10 * cos + dm11 * sin));
185
- }
186
-
187
- prev = LinePath.SEG_CLOSE;
188
- rindex = 0;
189
- started = false;
190
- lineToOrigin = false;
191
- }
192
-
193
- private void computeOffset(int x0, int y0, int x1, int y1, int[] m) {
194
- long lx = (long) x1 - (long) x0;
195
- long ly = (long) y1 - (long) y0;
196
-
197
- int dx, dy;
198
- if (m00 > 0 && m00 == m11 && m01 == 0 & m10 == 0) {
199
- long ilen = LinePath.hypot(lx, ly);
200
- if (ilen == 0) {
201
- dx = dy = 0;
202
- } else {
203
- dx = (int) ((ly * scaledLineWidth2) / ilen);
204
- dy = (int) (-(lx * scaledLineWidth2) / ilen);
205
- }
206
- } else {
207
- double dlx = x1 - x0;
208
- double dly = y1 - y0;
209
- double det = (double) m00 * m11 - (double) m01 * m10;
210
- int sdet = (det > 0) ? 1 : -1;
211
- double a = dly * m00 - dlx * m10;
212
- double b = dly * m01 - dlx * m11;
213
- double dh = LinePath.hypot(a, b);
214
- double div = sdet * lineWidth2 / (65536.0 * dh);
215
- double ddx = dly * m00_2_m01_2 - dlx * m00_m10_m01_m11;
216
- double ddy = dly * m00_m10_m01_m11 - dlx * m10_2_m11_2;
217
- dx = (int) (ddx * div);
218
- dy = (int) (ddy * div);
219
- }
220
-
221
- m[0] = dx;
222
- m[1] = dy;
223
- }
224
-
225
- private void ensureCapacity(int newrindex) {
226
- if (reverse.length < newrindex) {
227
- int[] tmp = new int[Math.max(newrindex, 6 * reverse.length / 5)];
228
- System.arraycopy(reverse, 0, tmp, 0, rindex);
229
- this.reverse = tmp;
230
- }
231
- }
232
-
233
- private boolean isCCW(int x0, int y0, int x1, int y1, int x2, int y2) {
234
- int dx0 = x1 - x0;
235
- int dy0 = y1 - y0;
236
- int dx1 = x2 - x1;
237
- int dy1 = y2 - y1;
238
- return (long) dx0 * dy1 < (long) dy0 * dx1;
239
- }
240
-
241
- private boolean side(int x, int y, int x0, int y0, int x1, int y1) {
242
- long lx = x;
243
- long ly = y;
244
- long lx0 = x0;
245
- long ly0 = y0;
246
- long lx1 = x1;
247
- long ly1 = y1;
248
-
249
- return (ly0 - ly1) * lx + (lx1 - lx0) * ly + (lx0 * ly1 - lx1 * ly0) > 0;
250
- }
251
-
252
- private int computeRoundJoin(int cx, int cy, int xa, int ya, int xb, int yb,
253
- int side, boolean flip, int[] join) {
254
- int px, py;
255
- int ncoords = 0;
256
-
257
- boolean centerSide;
258
- if (side == 0) {
259
- centerSide = side(cx, cy, xa, ya, xb, yb);
260
- } else {
261
- centerSide = (side == 1);
262
- }
263
- for (int i = 0; i < numPenSegments; i++) {
264
- px = cx + pen_dx[i];
265
- py = cy + pen_dy[i];
266
-
267
- boolean penSide = side(px, py, xa, ya, xb, yb);
268
- penIncluded[i] = penSide != centerSide;
269
- }
270
-
271
- int start = -1, end = -1;
272
- for (int i = 0; i < numPenSegments; i++) {
273
- if (penIncluded[i]
274
- && !penIncluded[(i + numPenSegments - 1) % numPenSegments]) {
275
- start = i;
276
- }
277
- if (penIncluded[i] && !penIncluded[(i + 1) % numPenSegments]) {
278
- end = i;
279
- }
280
- }
281
-
282
- if (end < start) {
283
- end += numPenSegments;
284
- }
285
-
286
- if (start != -1 && end != -1) {
287
- long dxa = cx + pen_dx[start] - xa;
288
- long dya = cy + pen_dy[start] - ya;
289
- long dxb = cx + pen_dx[start] - xb;
290
- long dyb = cy + pen_dy[start] - yb;
291
-
292
- boolean rev = (dxa * dxa + dya * dya > dxb * dxb + dyb * dyb);
293
- int i = rev ? end : start;
294
- int incr = rev ? -1 : 1;
295
- while (true) {
296
- int idx = i % numPenSegments;
297
- px = cx + pen_dx[idx];
298
- py = cy + pen_dy[idx];
299
- join[ncoords++] = px;
300
- join[ncoords++] = py;
301
- if (i == (rev ? start : end)) {
302
- break;
303
- }
304
- i += incr;
305
- }
306
- }
307
-
308
- return ncoords / 2;
309
- }
310
-
311
- //private static final long ROUND_JOIN_THRESHOLD = 1000L;
312
- private static final long ROUND_JOIN_THRESHOLD = 100000000L;
313
-
314
- private static final long ROUND_JOIN_INTERNAL_THRESHOLD = 1000000000L;
315
-
316
- private void drawRoundJoin(int x, int y, int omx, int omy, int mx, int my,
317
- int side, int color,
318
- boolean flip, boolean rev, long threshold) {
319
- if ((omx == 0 && omy == 0) || (mx == 0 && my == 0)) {
320
- return;
321
- }
322
-
323
- long domx = (long) omx - mx;
324
- long domy = (long) omy - my;
325
- long len = domx * domx + domy * domy;
326
- if (len < threshold) {
327
- return;
328
- }
329
-
330
- if (rev) {
331
- omx = -omx;
332
- omy = -omy;
333
- mx = -mx;
334
- my = -my;
335
- }
336
-
337
- int bx0 = x + omx;
338
- int by0 = y + omy;
339
- int bx1 = x + mx;
340
- int by1 = y + my;
341
-
342
- int npoints = computeRoundJoin(x, y, bx0, by0, bx1, by1, side, flip, join);
343
- for (int i = 0; i < npoints; i++) {
344
- emitLineTo(join[2 * i], join[2 * i + 1], color, rev);
345
- }
346
- }
347
-
348
- // Return the intersection point of the lines (ix0, iy0) -> (ix1, iy1)
349
- // and (ix0p, iy0p) -> (ix1p, iy1p) in m[0] and m[1]
350
- private void computeMiter(int ix0, int iy0, int ix1, int iy1, int ix0p,
351
- int iy0p, int ix1p, int iy1p, int[] m) {
352
- long x0 = ix0;
353
- long y0 = iy0;
354
- long x1 = ix1;
355
- long y1 = iy1;
356
-
357
- long x0p = ix0p;
358
- long y0p = iy0p;
359
- long x1p = ix1p;
360
- long y1p = iy1p;
361
-
362
- long x10 = x1 - x0;
363
- long y10 = y1 - y0;
364
- long x10p = x1p - x0p;
365
- long y10p = y1p - y0p;
366
-
367
- long den = (x10 * y10p - x10p * y10) >> 16;
368
- if (den == 0) {
369
- m[0] = ix0;
370
- m[1] = iy0;
371
- return;
372
- }
373
-
374
- long t = (x1p * (y0 - y0p) - x0 * y10p + x0p * (y1p - y0)) >> 16;
375
- m[0] = (int) (x0 + (t * x10) / den);
376
- m[1] = (int) (y0 + (t * y10) / den);
377
- }
378
-
379
- private void drawMiter(int px0, int py0, int x0, int y0, int x1, int y1,
380
- int omx, int omy, int mx, int my, int color,
381
- boolean rev) {
382
- if (mx == omx && my == omy) {
383
- return;
384
- }
385
- if (px0 == x0 && py0 == y0) {
386
- return;
387
- }
388
- if (x0 == x1 && y0 == y1) {
389
- return;
390
- }
391
-
392
- if (rev) {
393
- omx = -omx;
394
- omy = -omy;
395
- mx = -mx;
396
- my = -my;
397
- }
398
-
399
- computeMiter(px0 + omx, py0 + omy, x0 + omx, y0 + omy, x0 + mx, y0 + my, x1
400
- + mx, y1 + my, miter);
401
-
402
- // Compute miter length in untransformed coordinates
403
- long dx = (long) miter[0] - x0;
404
- long dy = (long) miter[1] - y0;
405
- long a = (dy * m00 - dx * m10) >> 16;
406
- long b = (dy * m01 - dx * m11) >> 16;
407
- long lenSq = a * a + b * b;
408
-
409
- if (lenSq < miterLimitSq) {
410
- emitLineTo(miter[0], miter[1], color, rev);
411
- }
412
- }
413
-
414
- public void moveTo(int x0, int y0, int c0) {
415
- // System.out.println("LineStroker.moveTo(" + x0/65536.0 + ", " + y0/65536.0 + ")");
416
-
417
- if (lineToOrigin) {
418
- // not closing the path, do the previous lineTo
419
- lineToImpl(sx0, sy0, scolor0, joinToOrigin);
420
- lineToOrigin = false;
421
- }
422
-
423
- if (prev == LinePath.SEG_LINETO) {
424
- finish();
425
- }
426
-
427
- this.sx0 = this.x0 = x0;
428
- this.sy0 = this.y0 = y0;
429
- this.scolor0 = this.color0 = c0;
430
- this.rindex = 0;
431
- this.started = false;
432
- this.joinSegment = false;
433
- this.prev = LinePath.SEG_MOVETO;
434
- }
435
-
436
- boolean joinSegment = false;
437
-
438
- public void lineJoin() {
439
- // System.out.println("LineStroker.lineJoin()");
440
- this.joinSegment = true;
441
- }
442
-
443
- public void lineTo(int x1, int y1, int c1) {
444
- // System.out.println("LineStroker.lineTo(" + x1/65536.0 + ", " + y1/65536.0 + ")");
445
-
446
- if (lineToOrigin) {
447
- if (x1 == sx0 && y1 == sy0) {
448
- // staying in the starting point
449
- return;
450
- }
451
-
452
- // not closing the path, do the previous lineTo
453
- lineToImpl(sx0, sy0, scolor0, joinToOrigin);
454
- lineToOrigin = false;
455
- } else if (x1 == x0 && y1 == y0) {
456
- return;
457
- } else if (x1 == sx0 && y1 == sy0) {
458
- lineToOrigin = true;
459
- joinToOrigin = joinSegment;
460
- joinSegment = false;
461
- return;
462
- }
463
-
464
- lineToImpl(x1, y1, c1, joinSegment);
465
- joinSegment = false;
466
- }
467
-
468
- private void lineToImpl(int x1, int y1, int c1, boolean joinSegment) {
469
- computeOffset(x0, y0, x1, y1, offset);
470
- int mx = offset[0];
471
- int my = offset[1];
472
-
473
- if (!started) {
474
- emitMoveTo(x0 + mx, y0 + my, color0);
475
- this.sx1 = x1;
476
- this.sy1 = y1;
477
- this.mx0 = mx;
478
- this.my0 = my;
479
- started = true;
480
- } else {
481
- boolean ccw = isCCW(px0, py0, x0, y0, x1, y1);
482
- if (joinSegment) {
483
- if (joinStyle == LinePath.JOIN_MITER) {
484
- drawMiter(px0, py0, x0, y0, x1, y1, omx, omy, mx, my, color0, ccw);
485
- } else if (joinStyle == LinePath.JOIN_ROUND) {
486
- drawRoundJoin(x0, y0, omx, omy, mx, my, 0, color0, false, ccw,
487
- ROUND_JOIN_THRESHOLD);
488
- }
489
- } else {
490
- // Draw internal joins as round
491
- drawRoundJoin(x0, y0, omx, omy, mx, my, 0, color0, false, ccw,
492
- ROUND_JOIN_INTERNAL_THRESHOLD);
493
- }
494
-
495
- emitLineTo(x0, y0, color0, !ccw);
496
- }
497
-
498
- emitLineTo(x0 + mx, y0 + my, color0, false);
499
- emitLineTo(x1 + mx, y1 + my, c1, false);
500
-
501
- emitLineTo(x0 - mx, y0 - my, color0, true);
502
- emitLineTo(x1 - mx, y1 - my, c1, true);
503
-
504
- this.omx = mx;
505
- this.omy = my;
506
- this.px0 = x0;
507
- this.py0 = y0;
508
- this.pcolor0 = color0;
509
- this.x0 = x1;
510
- this.y0 = y1;
511
- this.color0 = c1;
512
- this.prev = LinePath.SEG_LINETO;
513
- }
514
-
515
- public void close() {
516
- if (lineToOrigin) {
517
- // ignore the previous lineTo
518
- lineToOrigin = false;
519
- }
520
-
521
- if (!started) {
522
- finish();
523
- return;
524
- }
525
-
526
- computeOffset(x0, y0, sx0, sy0, offset);
527
- int mx = offset[0];
528
- int my = offset[1];
529
-
530
- // Draw penultimate join
531
- boolean ccw = isCCW(px0, py0, x0, y0, sx0, sy0);
532
- if (joinSegment) {
533
- if (joinStyle == LinePath.JOIN_MITER) {
534
- drawMiter(px0, py0, x0, y0, sx0, sy0, omx, omy, mx, my, pcolor0, ccw);
535
- } else if (joinStyle == LinePath.JOIN_ROUND) {
536
- drawRoundJoin(x0, y0, omx, omy, mx, my, 0, color0, false, ccw,
537
- ROUND_JOIN_THRESHOLD);
538
- }
539
- } else {
540
- // Draw internal joins as round
541
- drawRoundJoin(x0, y0, omx, omy, mx, my, 0, color0, false, ccw,
542
- ROUND_JOIN_INTERNAL_THRESHOLD);
543
- }
544
-
545
- emitLineTo(x0 + mx, y0 + my, color0);
546
- emitLineTo(sx0 + mx, sy0 + my, scolor0);
547
-
548
- ccw = isCCW(x0, y0, sx0, sy0, sx1, sy1);
549
-
550
- // Draw final join on the outside
551
- if (!ccw) {
552
- if (joinStyle == LinePath.JOIN_MITER) {
553
- drawMiter(x0, y0, sx0, sy0, sx1, sy1, mx, my, mx0, my0, color0, false);
554
- } else if (joinStyle == LinePath.JOIN_ROUND) {
555
- drawRoundJoin(sx0, sy0, mx, my, mx0, my0, 0, scolor0, false, false,
556
- ROUND_JOIN_THRESHOLD);
557
- }
558
- }
559
-
560
- emitLineTo(sx0 + mx0, sy0 + my0, scolor0);
561
- emitLineTo(sx0 - mx0, sy0 - my0, scolor0); // same as reverse[0], reverse[1]
562
-
563
- // Draw final join on the inside
564
- if (ccw) {
565
- if (joinStyle == LinePath.JOIN_MITER) {
566
- drawMiter(x0, y0, sx0, sy0, sx1, sy1, -mx, -my, -mx0, -my0, color0,
567
- false);
568
- } else if (joinStyle == LinePath.JOIN_ROUND) {
569
- drawRoundJoin(sx0, sy0, -mx, -my, -mx0, -my0, 0, scolor0, true, false,
570
- ROUND_JOIN_THRESHOLD);
571
- }
572
- }
573
-
574
- emitLineTo(sx0 - mx, sy0 - my, scolor0);
575
- emitLineTo(x0 - mx, y0 - my, color0);
576
- for (int i = rindex - 3; i >= 0; i -= 3) {
577
- emitLineTo(reverse[i], reverse[i + 1], reverse[i + 2]);
578
- }
579
-
580
- this.x0 = this.sx0;
581
- this.y0 = this.sy0;
582
- this.rindex = 0;
583
- this.started = false;
584
- this.joinSegment = false;
585
- this.prev = LinePath.SEG_CLOSE;
586
- emitClose();
587
- }
588
-
589
- public void end() {
590
- if (lineToOrigin) {
591
- // not closing the path, do the previous lineTo
592
- lineToImpl(sx0, sy0, scolor0, joinToOrigin);
593
- lineToOrigin = false;
594
- }
595
-
596
- if (prev == LinePath.SEG_LINETO) {
597
- finish();
598
- }
599
-
600
- output.end();
601
- this.joinSegment = false;
602
- this.prev = LinePath.SEG_MOVETO;
603
- }
604
-
605
- long lineLength(long ldx, long ldy) {
606
- long ldet = ((long) m00 * m11 - (long) m01 * m10) >> 16;
607
- long la = (ldy * m00 - ldx * m10) / ldet;
608
- long lb = (ldy * m01 - ldx * m11) / ldet;
609
- long llen = (int) LinePath.hypot(la, lb);
610
- return llen;
611
- }
612
-
613
- private void finish() {
614
- if (capStyle == LinePath.CAP_ROUND) {
615
- drawRoundJoin(x0, y0, omx, omy, -omx, -omy, 1, color0, false, false,
616
- ROUND_JOIN_THRESHOLD);
617
- } else if (capStyle == LinePath.CAP_SQUARE) {
618
- long ldx = px0 - x0;
619
- long ldy = py0 - y0;
620
- long llen = lineLength(ldx, ldy);
621
- if (0 < llen) {
622
- long s = (long) lineWidth2 * 65536 / llen;
623
-
624
- int capx = x0 - (int) (ldx * s >> 16);
625
- int capy = y0 - (int) (ldy * s >> 16);
626
-
627
- emitLineTo(capx + omx, capy + omy, color0);
628
- emitLineTo(capx - omx, capy - omy, color0);
629
- }
630
- }
631
-
632
- for (int i = rindex - 3; i >= 0; i -= 3) {
633
- emitLineTo(reverse[i], reverse[i + 1], reverse[i + 2]);
634
- }
635
- this.rindex = 0;
636
-
637
- if (capStyle == LinePath.CAP_ROUND) {
638
- drawRoundJoin(sx0, sy0, -mx0, -my0, mx0, my0, 1, scolor0, false, false,
639
- ROUND_JOIN_THRESHOLD);
640
- } else if (capStyle == LinePath.CAP_SQUARE) {
641
- long ldx = sx1 - sx0;
642
- long ldy = sy1 - sy0;
643
- long llen = lineLength(ldx, ldy);
644
- if (0 < llen) {
645
- long s = (long) lineWidth2 * 65536 / llen;
646
-
647
- int capx = sx0 - (int) (ldx * s >> 16);
648
- int capy = sy0 - (int) (ldy * s >> 16);
649
-
650
- emitLineTo(capx - mx0, capy - my0, scolor0);
651
- emitLineTo(capx + mx0, capy + my0, scolor0);
652
- }
653
- }
654
-
655
- emitClose();
656
- this.joinSegment = false;
657
- }
658
-
659
- private void emitMoveTo(int x0, int y0, int c0) {
660
- output.moveTo(x0, y0, c0);
661
- }
662
-
663
- private void emitLineTo(int x1, int y1, int c1) {
664
- output.lineTo(x1, y1, c1);
665
- }
666
-
667
- private void emitLineTo(int x1, int y1, int c1, boolean rev) {
668
- if (rev) {
669
- ensureCapacity(rindex + 3);
670
- reverse[rindex++] = x1;
671
- reverse[rindex++] = y1;
672
- reverse[rindex++] = c1;
673
- } else {
674
- emitLineTo(x1, y1, c1);
675
- }
676
- }
677
-
678
- private void emitClose() {
679
- output.close();
680
- }
681
- }