processing.pdf
Class PGraphicsPDF

java.lang.Object
  extended by processing.core.PImage
      extended by processing.core.PGraphics
          extended by processing.core.PGraphicsJava2D
              extended by processing.pdf.PGraphicsPDF
All Implemented Interfaces:
java.lang.Cloneable, PConstants

public class PGraphicsPDF
extends PGraphicsJava2D


Field Summary
 
Fields inherited from class processing.core.PGraphicsJava2D
fillGradient, fillGradientObject, g2, strokeGradient, strokeGradientObject
 
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
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
PGraphicsPDF()
           
 
Method Summary
 void addFonts(java.lang.String directory)
          Add a directory that should be searched for font data.
 void beginDraw()
          Prepares the PGraphics for drawing.
 void blend(int sx, int sy, int dx, int dy, int mode)
           
 void blend(int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode)
          Blends one area of this image to another area.
 void blend(PImage src, int sx, int sy, int dx, int dy, int mode)
           
 void blend(PImage src, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2, int mode)
          Copies area of one image into another PImage object.
 void copy(int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2)
          Copy things from one area of this image to another area in the same image.
 void copy(PImage src, int sx1, int sy1, int sx2, int sy2, int dx1, int dy1, int dx2, int dy2)
          Copies area of one image into another PImage object.
 boolean displayable()
          Don't open a window for this renderer, it won't be used.
 void dispose()
          Handle any takedown for this graphics context.
 void endDraw()
          This will finalize rendering so that it can be shown on-screen.
 void filter(int kind)
          Method to apply a variety of basic filters to this image.
 void filter(int kind, float param)
          Method to apply a variety of basic filters to this image.
 PImage get()
          Returns a copy of this PImage.
 int get(int x, int y)
          Returns an ARGB "color" type (a packed 32 bit int with the color.
 PImage get(int x, int y, int c, int d)
          Grab a subsection of a PImage, and copy it into a fresh PImage.
 java.lang.String[] listFonts()
          List the fonts known to the PDF renderer.
 void loadPixels()
          Call this when you want to mess with the pixels[] array.
 void mask(int[] alpha)
          Set alpha channel for an image.
 void mask(PImage alpha)
          Set alpha channel for an image using another image as the source.
 void nextPage()
          Call to explicitly go to the next page from within a single draw().
 void save(java.lang.String filename)
          Save this image to disk.
 void set(int x, int y, int argb)
          Set a single pixel to the specified color.
 void set(int x, int y, PImage image)
          Efficient method of drawing an image's pixels directly to this surface.
 void setPath(java.lang.String path)
           
 void textMode(int mode)
          Change the textMode() to either SHAPE or MODEL.
 void updatePixels()
          Update the pixels[] buffer to the PGraphics image.
 void updatePixels(int x, int y, int c, int d)
          Update the pixels[] buffer to the PGraphics image.
 
Methods inherited from class processing.core.PGraphicsJava2D
applyMatrix, applyMatrix, backgroundImpl, beginRaw, beginShape, bezierDetail, bezierVertex, bezierVertex, box, breakShape, canDraw, curveDetail, curveVertex, endRaw, endShape, getImpl, getMatrix, getMatrix, getMatrix, line, noSmooth, point, popMatrix, printMatrix, pushMatrix, quad, resetMatrix, resize, rotate, rotate, rotateX, rotateY, rotateZ, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, setMatrix, setMatrix, setSize, smooth, sphere, strokeCap, strokeJoin, strokeWeight, textAscent, textDescent, textSize, texture, translate, triangle, vertex, vertex, vertex, vertex
 
Methods inherited from class processing.core.PGraphics
alpha, ambient, ambient, ambient, ambientLight, ambientLight, applyMatrix, applyMatrix, applyMatrix, arc, background, background, background, background, background, background, background, beginCamera, beginShape, bezier, bezier, bezierPoint, bezierTangent, blue, box, brightness, camera, camera, color, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, curve, curve, curvePoint, curveTangent, curveTightness, curveVertex, directionalLight, edge, ellipse, ellipseMode, emissive, emissive, emissive, endCamera, endShape, fill, fill, fill, fill, fill, fill, flush, frustum, getStyle, getStyle, green, hint, hue, image, image, image, imageMode, is2D, is3D, lerpColor, lerpColor, lightFalloff, lights, lightSpecular, line, modelX, modelY, modelZ, noFill, noLights, normal, noStroke, noTint, ortho, ortho, perspective, perspective, point, pointLight, popStyle, printCamera, printProjection, pushStyle, rect, rectMode, red, saturation, setMatrix, setParent, setPrimary, shape, shape, shape, shapeMode, shininess, showException, showWarning, specular, specular, specular, sphereDetail, sphereDetail, spotLight, stroke, stroke, stroke, stroke, stroke, stroke, style, text, text, text, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textFont, textFont, textLeading, textureMode, textWidth, textWidth, tint, tint, tint, tint, tint, tint, translate, vertex
 
Methods inherited from class processing.core.PImage
blendColor, clone, getCache, getImage, init, isModified, removeCache, setCache, setModified, setModified
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PGraphicsPDF

public PGraphicsPDF()
Method Detail

setPath

public void setPath(java.lang.String path)
Overrides:
setPath in class PGraphics

beginDraw

public void beginDraw()
Description copied from class: PGraphics
Prepares the PGraphics for drawing.

When creating your own PGraphics, you should call this before drawing anything.

Overrides:
beginDraw in class PGraphicsJava2D

endDraw

public void endDraw()
Description copied from class: PGraphics
This will finalize rendering so that it can be shown on-screen.

When creating your own PGraphics, you should call this when you're finished drawing.

Overrides:
endDraw in class PGraphicsJava2D

textMode

public void textMode(int mode)
Change the textMode() to either SHAPE or MODEL.
This resets all renderer settings, and should therefore be called before any other commands that set the fill() or the textFont() or anything. Unlike other renderers, use textMode() directly after the size() command.

Overrides:
textMode in class PGraphics

nextPage

public void nextPage()
Call to explicitly go to the next page from within a single draw().


dispose

public void dispose()
Description copied from class: PGraphics
Handle any takedown for this graphics context.

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.

Overrides:
dispose in class PGraphics

displayable

public boolean displayable()
Don't open a window for this renderer, it won't be used.

Overrides:
displayable in class PGraphics

loadPixels

public void loadPixels()
Description copied from class: PImage
Call this when you want to mess with the pixels[] array.

For subclasses where the pixels[] buffer isn't set by default, this should copy all data into the pixels[] array

Overrides:
loadPixels in class PGraphicsJava2D

updatePixels

public void updatePixels()
Description copied from class: PGraphicsJava2D
Update the pixels[] buffer to the PGraphics image.

Unlike in PImage, where updatePixels() only requests that the update happens, in PGraphicsJava2D, this will happen immediately.

Overrides:
updatePixels in class PGraphicsJava2D

updatePixels

public void updatePixels(int x,
                         int y,
                         int c,
                         int d)
Description copied from class: PGraphicsJava2D
Update the pixels[] buffer to the PGraphics image.

Unlike in PImage, where updatePixels() only requests that the update happens, in PGraphicsJava2D, this will happen immediately.

Overrides:
updatePixels in class PGraphicsJava2D

get

public int get(int x,
               int y)
Description copied from class: PImage
Returns an ARGB "color" type (a packed 32 bit int with the color. If the coordinate is outside the image, zero is returned (black, but completely transparent).

If the image is in RGB format (i.e. on a PVideo object), the value will get its high bits set, just to avoid cases where they haven't been set already.

If the image is in ALPHA format, this returns a white with its alpha value set.

This function is included primarily for beginners. It is quite slow because it has to check to see if the x, y that was provided is inside the bounds, and then has to check to see what image type it is. If you want things to be more efficient, access the pixels[] array directly.

Overrides:
get in class PGraphicsJava2D

get

public PImage get(int x,
                  int y,
                  int c,
                  int d)
Description copied from class: PImage
Grab a subsection of a PImage, and copy it into a fresh PImage. As of release 0149, no longer honors imageMode() for the coordinates.

Overrides:
get in class PImage

get

public PImage get()
Description copied from class: PImage
Returns a copy of this PImage. Equivalent to get(0, 0, width, height).

Overrides:
get in class PGraphicsJava2D

set

public void set(int x,
                int y,
                int argb)
Description copied from class: PImage
Set a single pixel to the specified color.

Overrides:
set in class PGraphicsJava2D

set

public void set(int x,
                int y,
                PImage image)
Description copied from class: PImage
Efficient method of drawing an image's pixels directly to this surface. No variations are employed, meaning that any scale, tint, or imageMode settings will be ignored.

Overrides:
set in class PImage

mask

public void mask(int[] alpha)
Description copied from class: PImage
Set alpha channel for an image. Black colors in the source image will make the destination image completely transparent, and white will make things fully opaque. Gray values will be in-between steps.

Strictly speaking the "blue" value from the source image is used as the alpha color. For a fully grayscale image, this is correct, but for a color image it's not 100% accurate. For a more accurate conversion, first use filter(GRAY) which will make the image into a "correct" grayscake by performing a proper luminance-based conversion.

Overrides:
mask in class PGraphicsJava2D

mask

public void mask(PImage alpha)
Description copied from class: PImage
Set alpha channel for an image using another image as the source.

Overrides:
mask in class PGraphicsJava2D

filter

public void filter(int kind)
Description copied from class: PImage
Method to apply a variety of basic filters to this image.

Luminance conversion code contributed by toxi

Gaussian blur code contributed by Mario Klingemann

Overrides:
filter in class PImage

filter

public void filter(int kind,
                   float param)
Description copied from class: PImage
Method to apply a variety of basic filters to this image. These filters all take a parameter.

Gaussian blur code contributed by Mario Klingemann and later updated by toxi for better speed.

Overrides:
filter in class PImage

copy

public void copy(int sx1,
                 int sy1,
                 int sx2,
                 int sy2,
                 int dx1,
                 int dy1,
                 int dx2,
                 int dy2)
Description copied from class: PImage
Copy things from one area of this image to another area in the same image.

Overrides:
copy in class PGraphicsJava2D

copy

public void copy(PImage src,
                 int sx1,
                 int sy1,
                 int sx2,
                 int sy2,
                 int dx1,
                 int dy1,
                 int dx2,
                 int dy2)
Description copied from class: PImage
Copies area of one image into another PImage object.

Overrides:
copy in class PImage

blend

public void blend(int sx,
                  int sy,
                  int dx,
                  int dy,
                  int mode)

blend

public void blend(PImage src,
                  int sx,
                  int sy,
                  int dx,
                  int dy,
                  int mode)

blend

public void blend(int sx1,
                  int sy1,
                  int sx2,
                  int sy2,
                  int dx1,
                  int dy1,
                  int dx2,
                  int dy2,
                  int mode)
Description copied from class: PImage
Blends one area of this image to another area.

Overrides:
blend in class PImage
See Also:
PImage.blendColor(int,int,int)

blend

public void blend(PImage src,
                  int sx1,
                  int sy1,
                  int sx2,
                  int sy2,
                  int dx1,
                  int dy1,
                  int dx2,
                  int dy2,
                  int mode)
Description copied from class: PImage
Copies area of one image into another PImage object.

Overrides:
blend in class PImage
See Also:
PImage.blendColor(int,int,int)

save

public void save(java.lang.String filename)
Description copied from class: PImage
Save this image to disk.

As of revision 0100, this function requires an absolute path, in order to avoid confusion. To save inside the sketch folder, use the function savePath() from PApplet, or use saveFrame() instead. As of revision 0116, savePath() is not needed if this object has been created (as recommended) via createImage() or createGraphics() or one of its neighbors.

As of revision 0115, when using Java 1.4 and later, you can write to several formats besides tga and tiff. If Java 1.4 is installed and the extension used is supported (usually png, jpg, jpeg, bmp, and tiff), then those methods will be used to write the image. To get a list of the supported formats for writing, use:
println(javax.imageio.ImageIO.getReaderFormatNames())

To use the original built-in image writers, use .tga or .tif as the extension, or don't include an extension. When no extension is used, the extension .tif will be added to the file name.

The ImageIO API claims to support wbmp files, however they probably require a black and white image. Basic testing produced a zero-length file with no error.

Overrides:
save in class PImage

addFonts

public void addFonts(java.lang.String directory)
Add a directory that should be searched for font data.
On Mac OS X, the following directories are added by default: On Windows, all drive letters are searched for WINDOWS\Fonts or WINNT\Fonts, any that exists is added.

On Linux or any other platform, you'll need to add the directories by hand. (If there are actual standards here that we can use as a starting point, please file a bug to make a note of it)


listFonts

public java.lang.String[] listFonts()
List the fonts known to the PDF renderer. This is like PFont.list(), however not all those fonts are available by default.