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
@@ -33,7 +33,7 @@ import processing.core.PApplet;
|
|
33
33
|
* function is used to draw the shape to the display window. The
|
34
34
|
* <b>PShape</b> object contain a group of methods, linked below, that can
|
35
35
|
* operate on the shape data.
|
36
|
-
|
36
|
+
|
37
37
|
* The <b>loadShape()</b> function supports SVG files created with Inkscape and
|
38
38
|
* Adobe Illustrator. It is not a full SVG implementation, but offers some
|
39
39
|
* straightforward support for handling vector data.
|
@@ -2777,7 +2777,7 @@ public class PShape implements PConstants {
|
|
2777
2777
|
* <b>translate(20, 0)</b> is the same as <b>translate(70, 0)</b>. This
|
2778
2778
|
* transformation is applied directly to the shape, it's not refreshed each
|
2779
2779
|
* time <b>draw()</b> is run.
|
2780
|
-
|
2780
|
+
|
2781
2781
|
* Using this method with the <b>z</b> parameter requires using the P3D
|
2782
2782
|
* parameter in combination with size.
|
2783
2783
|
*
|
@@ -2812,14 +2812,14 @@ public class PShape implements PConstants {
|
|
2812
2812
|
* <b>angle</b> parameter. Angles should be specified in radians (values
|
2813
2813
|
* from 0 to TWO_PI) or converted to radians with the <b>radians()</b>
|
2814
2814
|
* method.
|
2815
|
-
|
2815
|
+
|
2816
2816
|
* Shapes are always rotated around the upper-left corner of their bounding
|
2817
2817
|
* box. Positive numbers rotate objects in a clockwise direction. Subsequent
|
2818
2818
|
* calls to the method accumulates the effect. For example, calling
|
2819
2819
|
* <b>rotateX(HALF_PI)</b> and then <b>rotateX(HALF_PI)</b> is the same as
|
2820
2820
|
* <b>rotateX(PI)</b>. This transformation is applied directly to the shape,
|
2821
2821
|
* it's not refreshed each time <b>draw()</b> is run.
|
2822
|
-
|
2822
|
+
|
2823
2823
|
* This method requires a 3D renderer. You need to use P3D as a third
|
2824
2824
|
* parameter for the <b>size()</b> function as shown in the example above.
|
2825
2825
|
*
|
@@ -2847,14 +2847,14 @@ public class PShape implements PConstants {
|
|
2847
2847
|
* <b>angle</b> parameter. Angles should be specified in radians (values
|
2848
2848
|
* from 0 to TWO_PI) or converted to radians with the <b>radians()</b>
|
2849
2849
|
* method.
|
2850
|
-
|
2850
|
+
|
2851
2851
|
* Shapes are always rotated around the upper-left corner of their bounding
|
2852
2852
|
* box. Positive numbers rotate objects in a clockwise direction. Subsequent
|
2853
2853
|
* calls to the method accumulates the effect. For example, calling
|
2854
2854
|
* <b>rotateY(HALF_PI)</b> and then <b>rotateY(HALF_PI)</b> is the same as
|
2855
2855
|
* <b>rotateY(PI)</b>. This transformation is applied directly to the shape,
|
2856
2856
|
* it's not refreshed each time <b>draw()</b> is run.
|
2857
|
-
|
2857
|
+
|
2858
2858
|
* This method requires a 3D renderer. You need to use P3D as a third
|
2859
2859
|
* parameter for the <b>size()</b> function as shown in the example above.
|
2860
2860
|
*
|
@@ -2882,14 +2882,14 @@ public class PShape implements PConstants {
|
|
2882
2882
|
* <b>angle</b> parameter. Angles should be specified in radians (values
|
2883
2883
|
* from 0 to TWO_PI) or converted to radians with the <b>radians()</b>
|
2884
2884
|
* method.
|
2885
|
-
|
2885
|
+
|
2886
2886
|
* Shapes are always rotated around the upper-left corner of their bounding
|
2887
2887
|
* box. Positive numbers rotate objects in a clockwise direction. Subsequent
|
2888
2888
|
* calls to the method accumulates the effect. For example, calling
|
2889
2889
|
* <b>rotateZ(HALF_PI)</b> and then <b>rotateZ(HALF_PI)</b> is the same as
|
2890
2890
|
* <b>rotateZ(PI)</b>. This transformation is applied directly to the shape,
|
2891
2891
|
* it's not refreshed each time <b>draw()</b> is run.
|
2892
|
-
|
2892
|
+
|
2893
2893
|
* This method requires a 3D renderer. You need to use P3D as a third
|
2894
2894
|
* parameter for the <b>size()</b> function as shown in the example above.
|
2895
2895
|
*
|
@@ -2916,7 +2916,7 @@ public class PShape implements PConstants {
|
|
2916
2916
|
* Rotates a shape the amount specified by the <b>angle</b> parameter.
|
2917
2917
|
* Angles should be specified in radians (values from 0 to TWO_PI) or
|
2918
2918
|
* converted to radians with the <b>radians()</b> method.
|
2919
|
-
|
2919
|
+
|
2920
2920
|
* Shapes are always rotated around the upper-left corner of their bounding
|
2921
2921
|
* box. Positive numbers rotate objects in a clockwise direction.
|
2922
2922
|
* Transformations apply to everything that happens after and subsequent
|
@@ -2971,7 +2971,7 @@ public class PShape implements PConstants {
|
|
2971
2971
|
* <b>scale(2.0)</b> and then <b>scale(1.5)</b> is the same as
|
2972
2972
|
* <b>scale(3.0)</b>. This transformation is applied directly to the shape,
|
2973
2973
|
* it's not refreshed each time <b>draw()</b> is run.
|
2974
|
-
|
2974
|
+
|
2975
2975
|
* Using this method with the <b>z</b> parameter requires using the P3D
|
2976
2976
|
* parameter in combination with size.
|
2977
2977
|
*
|
@@ -42,8 +42,8 @@ import processing.core.PConstants;
|
|
42
42
|
* cannot simply use traditional addition/multiplication/etc. Instead, we'll
|
43
43
|
* need to do some "vector" math, which is made easy by the methods inside the
|
44
44
|
* <b>PVector</b>
|
45
|
-
* class
|
46
|
-
*
|
45
|
+
* class.
|
46
|
+
*
|
47
47
|
* The methods for this class are extensive. For a complete list, visit the
|
48
48
|
* <a
|
49
49
|
* href="http://processing.googlecode.com/svn/trunk/processing/build/javadoc/core/">developer's
|
@@ -39,8 +39,8 @@ import java.awt.Taskbar;
|
|
39
39
|
*/
|
40
40
|
public class ThinkDifferent {
|
41
41
|
|
42
|
-
private static Desktop desktop;
|
43
|
-
private static Taskbar taskbar;
|
42
|
+
private static Desktop desktop; // cached instance
|
43
|
+
private static Taskbar taskbar; // cached instance
|
44
44
|
|
45
45
|
// True if user has tried to quit once. Prevents us from canceling the quit
|
46
46
|
// call if the sketch is held up for some reason, like an exception that's
|
@@ -57,9 +57,9 @@ public class ThinkDifferent {
|
|
57
57
|
* @param sketch The sketch whose quit handler callback should be set.
|
58
58
|
*/
|
59
59
|
static public void init(final PApplet sketch) {
|
60
|
-
getDesktop().setQuitHandler((
|
61
|
-
sketch.exit();
|
62
|
-
|
60
|
+
getDesktop().setQuitHandler((event, quitResponse) -> {
|
61
|
+
sketch.exit();
|
62
|
+
boolean noKnownCrash = PApplet.uncaughtThrowable == null;
|
63
63
|
if (noKnownCrash && !attemptedQuit) { // haven't tried yet
|
64
64
|
quitResponse.cancelQuit(); // tell OS X we'll handle this
|
65
65
|
attemptedQuit = true;
|
@@ -94,7 +94,6 @@ public class ThinkDifferent {
|
|
94
94
|
if (taskbar == null) {
|
95
95
|
taskbar = Taskbar.getTaskbar();
|
96
96
|
}
|
97
|
-
|
98
97
|
return taskbar;
|
99
98
|
}
|
100
99
|
|
@@ -107,7 +106,6 @@ public class ThinkDifferent {
|
|
107
106
|
if (desktop == null) {
|
108
107
|
desktop = Desktop.getDesktop();
|
109
108
|
}
|
110
|
-
|
111
109
|
return desktop;
|
112
110
|
}
|
113
111
|
}
|
@@ -0,0 +1,404 @@
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
2
|
+
|
3
|
+
/*
|
4
|
+
* RawDXF - Code to write DXF files with beginRaw/endRaw
|
5
|
+
* An extension for the Processing project - http://processing.org
|
6
|
+
* <p/>
|
7
|
+
* This library is free software; you can redistribute it and/or
|
8
|
+
* modify it under the terms of the GNU Lesser General Public
|
9
|
+
* License as published by the Free Software Foundation; either
|
10
|
+
* version 2.1 of the License, or (at your option) any later version.
|
11
|
+
* <p/>
|
12
|
+
* This library is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
* Lesser General Public License for more details.
|
16
|
+
* <p/>
|
17
|
+
* You should have received a copy of the GNU Lesser General
|
18
|
+
* Public License along with the Processing project; if not,
|
19
|
+
* write to the Free Software Foundation, Inc., 59 Temple Place,
|
20
|
+
* Suite 330, Boston, MA 02111-1307 USA
|
21
|
+
*/
|
22
|
+
|
23
|
+
package processing.dxf;
|
24
|
+
|
25
|
+
import java.io.File;
|
26
|
+
import java.io.IOException;
|
27
|
+
import java.io.FileWriter;
|
28
|
+
import java.io.PrintWriter;
|
29
|
+
import processing.core.PGraphics;
|
30
|
+
|
31
|
+
|
32
|
+
/**
|
33
|
+
* A simple library to write DXF files with Processing.
|
34
|
+
* Because this is used with beginRaw() and endRaw(), only individual
|
35
|
+
* triangles and (discontinuous) line segments will be written to the file.
|
36
|
+
* <p>
|
37
|
+
* Use something like a keyPressed() in PApplet to trigger it,
|
38
|
+
* to avoid writing a bazillion .dxf files.
|
39
|
+
* <p>
|
40
|
+
* Usually, the file will be saved to the sketch's folder.
|
41
|
+
* Use Sketch → Show Sketch Folder to see it from the PDE.
|
42
|
+
* <p>
|
43
|
+
* A simple example of how to use:
|
44
|
+
* <PRE>
|
45
|
+
* import processing.dxf.*;
|
46
|
+
*
|
47
|
+
* boolean record;
|
48
|
+
*
|
49
|
+
* void setup() {
|
50
|
+
* size(500, 500, P3D);
|
51
|
+
* }
|
52
|
+
*
|
53
|
+
* void keyPressed() {
|
54
|
+
* // use a key press so that it doesn't make a million files
|
55
|
+
* if (key == 'r') record = true;
|
56
|
+
* }
|
57
|
+
*
|
58
|
+
* void draw() {
|
59
|
+
* if (record) {
|
60
|
+
* beginRaw(DXF, "output.dxf");
|
61
|
+
* }
|
62
|
+
*
|
63
|
+
* // do all your drawing here
|
64
|
+
*
|
65
|
+
* if (record) {
|
66
|
+
* endRaw();
|
67
|
+
* record = false;
|
68
|
+
* }
|
69
|
+
* }
|
70
|
+
* </PRE>
|
71
|
+
* or to use it and be able to control the current layer:
|
72
|
+
* <PRE>
|
73
|
+
* import processing.dxf.*;
|
74
|
+
*
|
75
|
+
* boolean record;
|
76
|
+
* RawDXF dxf;
|
77
|
+
*
|
78
|
+
* void setup() {
|
79
|
+
* size(500, 500, P3D);
|
80
|
+
* }
|
81
|
+
*
|
82
|
+
* void keyPressed() {
|
83
|
+
* // use a key press so that it doesn't make a million files
|
84
|
+
* if (key == 'r') record = true;
|
85
|
+
* }
|
86
|
+
*
|
87
|
+
* void draw() {
|
88
|
+
* if (record) {
|
89
|
+
* dxf = (RawDXF) createGraphics(width, height, DXF, "output.dxf");
|
90
|
+
* beginRaw(dxf);
|
91
|
+
* }
|
92
|
+
*
|
93
|
+
* // do all your drawing here, and to set the layer, call:
|
94
|
+
* // if (record) {
|
95
|
+
* // dxf.setLayer(num);
|
96
|
+
* // }
|
97
|
+
* // where 'num' is an integer.
|
98
|
+
* // the default is zero, or you can set it to whatever.
|
99
|
+
*
|
100
|
+
* if (record) {
|
101
|
+
* endRaw();
|
102
|
+
* record = false;
|
103
|
+
* dxf = null;
|
104
|
+
* }
|
105
|
+
* }
|
106
|
+
* </PRE>
|
107
|
+
* Note that even though this class is a subclass of PGraphics, it only
|
108
|
+
* implements the parts of the API that are necessary for beginRaw/endRaw.
|
109
|
+
* <p>
|
110
|
+
* Based on the original DXF writer from Simon Greenwold, February 2004.
|
111
|
+
* Updated for Processing 0070 by Ben Fry in September 2004,
|
112
|
+
* and again for Processing beta in April 2005.
|
113
|
+
* Rewritten to support beginRaw/endRaw by Ben Fry in February 2006.
|
114
|
+
* Updated again for inclusion as a core library in March 2006.
|
115
|
+
* Constructor modifications in September 2008 as we approach 1.0.
|
116
|
+
*/
|
117
|
+
public class RawDXF extends PGraphics {
|
118
|
+
|
119
|
+
File file;
|
120
|
+
PrintWriter writer;
|
121
|
+
int currentLayer;
|
122
|
+
|
123
|
+
|
124
|
+
public RawDXF() { }
|
125
|
+
|
126
|
+
@Override
|
127
|
+
public void setPath(String path) {
|
128
|
+
this.path = path;
|
129
|
+
if (path != null) {
|
130
|
+
file = new File(path);
|
131
|
+
if (!file.isAbsolute()) file = null;
|
132
|
+
}
|
133
|
+
if (file == null) {
|
134
|
+
throw new RuntimeException("DXF export requires an absolute path " +
|
135
|
+
"for the location of the output file.");
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
|
140
|
+
// ..............................................................
|
141
|
+
|
142
|
+
|
143
|
+
protected void allocate() {
|
144
|
+
/*
|
145
|
+
for (int i = 0; i < MAX_TRI_LAYERS; i++) {
|
146
|
+
layerList[i] = NO_LAYER;
|
147
|
+
}
|
148
|
+
*/
|
149
|
+
setLayer(0);
|
150
|
+
}
|
151
|
+
|
152
|
+
|
153
|
+
@Override
|
154
|
+
public void dispose() {
|
155
|
+
writeFooter();
|
156
|
+
|
157
|
+
writer.flush();
|
158
|
+
writer.close();
|
159
|
+
writer = null;
|
160
|
+
}
|
161
|
+
|
162
|
+
@Override
|
163
|
+
public boolean displayable() {
|
164
|
+
return false; // just in case someone wants to use this on its own
|
165
|
+
}
|
166
|
+
|
167
|
+
@Override
|
168
|
+
public boolean is2D() {
|
169
|
+
return false;
|
170
|
+
}
|
171
|
+
|
172
|
+
|
173
|
+
@Override
|
174
|
+
public boolean is3D() {
|
175
|
+
return true;
|
176
|
+
}
|
177
|
+
// ..............................................................
|
178
|
+
|
179
|
+
@Override
|
180
|
+
public void beginDraw() {
|
181
|
+
// have to create file object here, because the name isn't yet
|
182
|
+
// available in allocate()
|
183
|
+
if (writer == null) {
|
184
|
+
try {
|
185
|
+
writer = new PrintWriter(new FileWriter(file));
|
186
|
+
} catch (IOException e) {
|
187
|
+
throw new RuntimeException(e); // java 1.4+
|
188
|
+
}
|
189
|
+
writeHeader();
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
@Override
|
194
|
+
public void endDraw() {
|
195
|
+
writer.flush();
|
196
|
+
}
|
197
|
+
|
198
|
+
|
199
|
+
// ..............................................................
|
200
|
+
|
201
|
+
|
202
|
+
/**
|
203
|
+
* Set the current layer being used in the DXF file.The default is zero.
|
204
|
+
* @param layer
|
205
|
+
*/
|
206
|
+
public void setLayer(int layer) {
|
207
|
+
currentLayer = layer;
|
208
|
+
}
|
209
|
+
|
210
|
+
|
211
|
+
// ..............................................................
|
212
|
+
|
213
|
+
|
214
|
+
private void writeHeader() {
|
215
|
+
writer.println("0");
|
216
|
+
writer.println("SECTION");
|
217
|
+
writer.println("2");
|
218
|
+
writer.println("ENTITIES");
|
219
|
+
}
|
220
|
+
|
221
|
+
|
222
|
+
private void writeFooter() {
|
223
|
+
writer.println("0");
|
224
|
+
writer.println("ENDSEC");
|
225
|
+
writer.println("0");
|
226
|
+
writer.println("EOF");
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
/**
|
231
|
+
* Write a command on one line (as a String), then start a new line
|
232
|
+
* and write out a formatted float.Available for anyone who wants to
|
233
|
+
insert additional commands into the DXF stream.
|
234
|
+
* @param cmd
|
235
|
+
* @param val
|
236
|
+
*/
|
237
|
+
public void write(String cmd, float val) {
|
238
|
+
writer.println(cmd);
|
239
|
+
// Don't number format, will cause trouble on systems that aren't en-US
|
240
|
+
// http://dev.processing.org/bugs/show_bug.cgi?id=495
|
241
|
+
writer.println(val);
|
242
|
+
}
|
243
|
+
|
244
|
+
|
245
|
+
/**
|
246
|
+
* Write a line to the dxf file.Available for anyone who wants to
|
247
|
+
insert additional commands into the DXF stream.
|
248
|
+
* @param what
|
249
|
+
*/
|
250
|
+
public void println(String what) {
|
251
|
+
writer.println(what);
|
252
|
+
}
|
253
|
+
|
254
|
+
|
255
|
+
protected void writeLine(int index1, int index2) {
|
256
|
+
writer.println("0");
|
257
|
+
writer.println("LINE");
|
258
|
+
|
259
|
+
// write out the layer
|
260
|
+
writer.println("8");
|
261
|
+
writer.println(String.valueOf(currentLayer));
|
262
|
+
|
263
|
+
write("10", vertices[index1][X]);
|
264
|
+
write("20", vertices[index1][Y]);
|
265
|
+
write("30", vertices[index1][Z]);
|
266
|
+
|
267
|
+
write("11", vertices[index2][X]);
|
268
|
+
write("21", vertices[index2][Y]);
|
269
|
+
write("31", vertices[index2][Z]);
|
270
|
+
}
|
271
|
+
|
272
|
+
|
273
|
+
/*
|
274
|
+
protected void writeLineStrip() {
|
275
|
+
writeLine();
|
276
|
+
// shift the last vertex to be the first vertex
|
277
|
+
System.arraycopy(vertices[1], 0, vertices[0], 0, vertices[1].length);
|
278
|
+
vertexCount = 1;
|
279
|
+
}
|
280
|
+
*/
|
281
|
+
|
282
|
+
protected void writeTriangle() {
|
283
|
+
writer.println("0");
|
284
|
+
writer.println("3DFACE");
|
285
|
+
|
286
|
+
// write out the layer
|
287
|
+
writer.println("8");
|
288
|
+
/*
|
289
|
+
if (i < MAX_TRI_LAYERS) {
|
290
|
+
if (layerList[i] >= 0) {
|
291
|
+
currentLayer = layerList[i];
|
292
|
+
}
|
293
|
+
}
|
294
|
+
*/
|
295
|
+
writer.println(String.valueOf(currentLayer));
|
296
|
+
|
297
|
+
write("10", vertices[0][X]);
|
298
|
+
write("20", vertices[0][Y]);
|
299
|
+
write("30", vertices[0][Z]);
|
300
|
+
|
301
|
+
write("11", vertices[1][X]);
|
302
|
+
write("21", vertices[1][Y]);
|
303
|
+
write("31", vertices[1][Z]);
|
304
|
+
|
305
|
+
write("12", vertices[2][X]);
|
306
|
+
write("22", vertices[2][Y]);
|
307
|
+
write("32", vertices[2][Z]);
|
308
|
+
|
309
|
+
// Without adding EPSILON, Rhino kinda freaks out.
|
310
|
+
// A face is actually a quad, not a triangle,
|
311
|
+
// so instead kinda fudging the final point here.
|
312
|
+
write("13", vertices[2][X] + EPSILON);
|
313
|
+
write("23", vertices[2][Y] + EPSILON);
|
314
|
+
write("33", vertices[2][Z] + EPSILON);
|
315
|
+
|
316
|
+
vertexCount = 0;
|
317
|
+
}
|
318
|
+
// ..............................................................
|
319
|
+
|
320
|
+
@Override
|
321
|
+
public void beginShape(int kind) {
|
322
|
+
shape = kind;
|
323
|
+
|
324
|
+
if ((shape != LINES) &&
|
325
|
+
(shape != TRIANGLES) &&
|
326
|
+
(shape != POLYGON)) {
|
327
|
+
String err =
|
328
|
+
"RawDXF can only be used with beginRaw(), " +
|
329
|
+
"because it only supports lines and triangles";
|
330
|
+
throw new RuntimeException(err);
|
331
|
+
}
|
332
|
+
|
333
|
+
if ((shape == POLYGON) && fill) {
|
334
|
+
throw new RuntimeException("DXF Export only supports non-filled shapes.");
|
335
|
+
}
|
336
|
+
|
337
|
+
vertexCount = 0;
|
338
|
+
}
|
339
|
+
|
340
|
+
@Override
|
341
|
+
public void vertex(float x, float y) {
|
342
|
+
vertex(x, y, 0);
|
343
|
+
}
|
344
|
+
|
345
|
+
@Override
|
346
|
+
public void vertex(float x, float y, float z) {
|
347
|
+
float vertex[] = vertices[vertexCount];
|
348
|
+
vertex[X] = x; // note: not mx, my, mz like PGraphics3
|
349
|
+
vertex[Y] = y;
|
350
|
+
vertex[Z] = z;
|
351
|
+
|
352
|
+
if (fill) {
|
353
|
+
vertex[R] = fillR;
|
354
|
+
vertex[G] = fillG;
|
355
|
+
vertex[B] = fillB;
|
356
|
+
vertex[A] = fillA;
|
357
|
+
}
|
358
|
+
|
359
|
+
if (stroke) {
|
360
|
+
vertex[SR] = strokeR;
|
361
|
+
vertex[SG] = strokeG;
|
362
|
+
vertex[SB] = strokeB;
|
363
|
+
vertex[SA] = strokeA;
|
364
|
+
vertex[SW] = strokeWeight;
|
365
|
+
}
|
366
|
+
|
367
|
+
if (textureImage != null) { // for the future?
|
368
|
+
vertex[U] = textureU;
|
369
|
+
vertex[V] = textureV;
|
370
|
+
}
|
371
|
+
vertexCount++;
|
372
|
+
|
373
|
+
if ((shape == LINES) && (vertexCount == 2)) {
|
374
|
+
writeLine(0, 1);
|
375
|
+
vertexCount = 0;
|
376
|
+
|
377
|
+
/*
|
378
|
+
} else if ((shape == LINE_STRIP) && (vertexCount == 2)) {
|
379
|
+
writeLineStrip();
|
380
|
+
*/
|
381
|
+
|
382
|
+
} else if ((shape == TRIANGLES) && (vertexCount == 3)) {
|
383
|
+
writeTriangle();
|
384
|
+
}
|
385
|
+
}
|
386
|
+
|
387
|
+
@Override
|
388
|
+
public void endShape(int mode) {
|
389
|
+
if (shape == POLYGON) {
|
390
|
+
for (int i = 0; i < vertexCount - 1; i++) {
|
391
|
+
writeLine(i, i+1);
|
392
|
+
}
|
393
|
+
if (mode == CLOSE) {
|
394
|
+
writeLine(vertexCount - 1, 0);
|
395
|
+
}
|
396
|
+
}
|
397
|
+
/*
|
398
|
+
if ((vertexCount != 0) &&
|
399
|
+
((shape != LINE_STRIP) && (vertexCount != 1))) {
|
400
|
+
System.err.println("Extra vertex boogers found.");
|
401
|
+
}
|
402
|
+
*/
|
403
|
+
}
|
404
|
+
}
|