|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object processing.core.PImage processing.core.PGraphics processing.core.PGraphics3D processing.dxf.RawDXF
public class RawDXF
A simple library to write DXF files with Processing. Because this is used with beginRaw() and endRaw(), only individual triangles and (discontinuous) line segments will be written to the file.
Use something like a keyPressed() in PApplet to trigger it, to avoid writing a bazillion .dxf files. Usually, the file will be saved to the sketch's folder. Use Sketch → Show Sketch Folder to see it from the PDE. A simple example of how to use:import processing.dxf.*; boolean record; void setup() { size(500, 500, P3D); } void keyPressed() { // use a key press so that it doesn't make a million files if (key == 'r') record = true; } void draw() { if (record) { beginRaw(DXF, "output.dxf"); } // do all your drawing here if (record) { endRaw(); record = false; } }or to use it and be able to control the current layer:
import processing.dxf.*; boolean record; RawDXF dxf; void setup() { size(500, 500, P3D); } void keyPressed() { // use a key press so that it doesn't make a million files if (key == 'r') record = true; } void draw() { if (record) { dxf = (RawDXF) createGraphics(width, height, DXF, "output.dxf"); beginRaw(dxf); } // do all your drawing here, and to set the layer, call: // if (record) { // dxf.setLayer(num); // } // where 'num' is an integer. // the default is zero, or you can set it to whatever. if (record) { endRaw(); record = false; dxf = null; } }Note that even though this class is a subclass of PGraphics, it only implements the parts of the API that are necessary for beginRaw/endRaw. Based on the original DXF writer from Simon Greenwold, February 2004. Updated for Processing 0070 by Ben Fry in September 2004, and again for Processing beta in April 2005. Rewritten to support beginRaw/endRaw by Ben Fry in February 2006. Updated again for inclusion as a core library in March 2006. Constructor modifications in September 2008 as we approach 1.0.
Field Summary |
---|
Fields inherited from class processing.core.PGraphics |
---|
ambientB, ambientG, ambientR, backgroundColor, bezierDetail, colorMode, colorModeA, colorModeX, colorModeY, colorModeZ, curveTightness, edge, ellipseMode, emissiveB, emissiveG, emissiveR, fill, fillColor, image, imageMode, normalX, normalY, normalZ, pixelCount, rectMode, shapeMode, shininess, smooth, specularB, specularG, specularR, sphereDetailU, sphereDetailV, stroke, strokeCap, strokeColor, strokeJoin, strokeWeight, textAlign, textAlignY, textFont, textLeading, textMode, textSize, textureImage, textureMode, textureU, textureV, tint, tintColor |
Fields inherited from class processing.core.PImage |
---|
format, height, parent, pixels, width |
Constructor Summary | |
---|---|
RawDXF()
|
Method Summary | |
---|---|
void |
beginDraw()
Prepares the PGraphics for drawing. |
void |
beginShape(int kind)
Start a new shape. |
boolean |
displayable()
Return true if this renderer should be drawn to the screen. |
void |
dispose()
Handle any takedown for this graphics context. |
void |
endDraw()
See notes in PGraphics. |
void |
endShape(int mode)
|
void |
println(java.lang.String what)
Write a line to the dxf file. |
void |
setLayer(int layer)
Set the current layer being used in the DXF file. |
void |
setPath(java.lang.String path)
|
void |
vertex(float x,
float y)
|
void |
vertex(float x,
float y,
float z)
|
void |
write(java.lang.String cmd,
float val)
Write a command on one line (as a String), then start a new line and write out a formatted float. |
Methods inherited from class processing.core.PGraphics3D |
---|
ambientLight, ambientLight, applyMatrix, applyMatrix, applyMatrix, applyMatrix, beginCamera, box, camera, camera, directionalLight, endCamera, flush, frustum, getMatrix, getMatrix, hint, is2D, is3D, lightFalloff, lights, lightSpecular, modelX, modelY, modelZ, noLights, noSmooth, ortho, ortho, perspective, perspective, pointLight, popMatrix, printCamera, printMatrix, printProjection, pushMatrix, resetMatrix, rotate, rotate, rotateX, rotateY, rotateZ, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, setMatrix, setMatrix, setSize, smooth, sphere, spotLight, strokeCap, strokeJoin, texture, translate, translate, vertex |
Methods inherited from class processing.core.PImage |
---|
blend, blend, blendColor, clone, copy, copy, filter, filter, get, get, get, getCache, getImage, init, isModified, loadPixels, mask, mask, removeCache, resize, save, set, set, setCache, setModified, setModified, updatePixels, updatePixels |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RawDXF()
Method Detail |
---|
public void setPath(java.lang.String path)
setPath
in class PGraphics
public void dispose()
PGraphics
This is called when a sketch is shut down and this renderer was specified using the size() command, or inside endRecord() and endRaw(), in order to shut things off.
dispose
in class PGraphics
public boolean displayable()
PGraphics
displayable
in class PGraphics
public void beginDraw()
PGraphics
beginDraw
in class PGraphics3D
public void endDraw()
PGraphics3D
endDraw
in class PGraphics3D
public void setLayer(int layer)
public void write(java.lang.String cmd, float val)
public void println(java.lang.String what)
public void beginShape(int kind)
PGraphics
Differences between beginShape() and line() and point() methods.
beginShape() is intended to be more flexible at the expense of being a little more complicated to use. it handles more complicated shapes that can consist of many connected lines (so you get joins) or lines mixed with curves.
The line() and point() command are for the far more common cases (particularly for our audience) that simply need to draw a line or a point on the screen.
From the code side of things, line() may or may not call beginShape() to do the drawing. In the beta code, they do, but in the alpha code, they did not. they might be implemented one way or the other depending on tradeoffs of runtime efficiency vs. implementation efficiency &mdash meaning the speed that things run at vs. the speed it takes me to write the code and maintain it. for beta, the latter is most important so that's how things are implemented.
beginShape
in class PGraphics3D
public void vertex(float x, float y)
vertex
in class PGraphics3D
public void vertex(float x, float y, float z)
vertex
in class PGraphics
public void endShape(int mode)
endShape
in class PGraphics3D
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |