processing.core
Class PGraphics

java.lang.Object
  extended by processing.core.PImage
      extended by processing.core.PGraphics
All Implemented Interfaces:
java.lang.Cloneable, PConstants
Direct Known Subclasses:
PGraphics2D, PGraphics3D, PGraphicsJava2D

public class PGraphics
extends PImage
implements PConstants

Main graphics and rendering context, as well as the base API implementation.

Subclassing and initializing PGraphics objects

Starting in release 0149, subclasses of PGraphics are handled differently. The constructor for subclasses takes no parameters, instead a series of functions are called by the hosting PApplet to specify its attributes. The functions were broken out because of the growing number of parameters such as these that might be used by a renderer, yet with the exception of setSize(), it's not clear which will be necessary. So while the size could be passed in to the constructor instead of a setSize() function, a function would still be needed that would notify the renderer that it was time to finish its initialization. Thus, setSize() simply does both.

Know your rights: public vs. private methods

Methods that are protected are often subclassed by other renderers, however they are not set 'public' because they shouldn't be part of the user-facing public API accessible from PApplet. That is, we don't want sketches calling textModeCheck() or vertexTexture() directly.

Handling warnings and exceptions

Methods that are unavailable generally show a warning, unless their lack of availability will soon cause another exception. For instance, if a method like getMatrix() returns null because it is unavailable, an exception will be thrown stating that the method is unavailable, rather than waiting for the NullPointerException that will occur when the sketch tries to use that method. As of release 0149, warnings will only be shown once, and exceptions have been changed to warnings where possible.

Using xxxxImpl() for subclassing smoothness

The xxxImpl() methods are generally renderer-specific handling for some subset if tasks for a particular function (vague enough for you?) For instance, imageImpl() handles drawing an image whose x/y/w/h and u/v coords have been specified, and screen placement (independent of imageMode) has been determined. There's no point in all renderers implementing the if (imageMode == BLAH) placement/sizing logic, so that's handled by PGraphics, which then calls imageImpl() once all that is figured out.

His brother PImage

PGraphics subclasses PImage so that it can be drawn and manipulated in a similar fashion. As such, many methods are inherited from PGraphics, though many are unavailable: for instance, resize() is not likely to be implemented; the same goes for mask(), depending on the situation.

What's in PGraphics, what ain't

For the benefit of subclasses, as much as possible has been placed inside PGraphics. For instance, bezier interpolation code and implementations of the strokeCap() method (that simply sets the strokeCap variable) are handled here. Features that will vary widely between renderers are located inside the subclasses themselves. For instance, all matrix handling code is per-renderer: Java 2D uses its own AffineTransform, P2D uses a PMatrix2D, and PGraphics3D needs to keep continually update forward and reverse transformations. A proper (future) OpenGL implementation will have all its matrix madness handled by the card. Lighting also falls under this category, however the base material property settings (emissive, specular, et al.) are handled in PGraphics because they use the standard colorMode() logic. Subclasses should override methods like emissiveFromCalc(), which is a point where a valid color has been defined internally, and can be applied in some manner based on the calcXxxx values.

What's in the PGraphics documentation, what ain't

Some things are noted here, some things are not. For public API, always refer to the reference on Processing.org for proper explanations. No attempt has been made to keep the javadoc up to date or complete. It's an enormous task for which we simply do not have the time. That is, it's not something that to be done once—it's a matter of keeping the multiple references synchronized (to say nothing of the translation issues), while targeting them for their separate audiences. Ouch.


Field Summary
 float ambientB
           
 float ambientG
           
 float ambientR
           
 int backgroundColor
          Last background color that was set, zero if an image
 int bezierDetail
           
 int colorMode
          The current colorMode
 float colorModeA
          Max value for alpha set by colorMode
 float colorModeX
          Max value for red (or hue) set by colorMode
 float colorModeY
          Max value for green (or saturation) set by colorMode
 float colorModeZ
          Max value for blue (or value) set by colorMode
 float curveTightness
           
 boolean edge
           
 int ellipseMode
          The current ellipse mode (read-only)
 float emissiveB
           
 float emissiveG
           
 float emissiveR
           
 boolean fill
          true if fill() is enabled, (read-only)
 int fillColor
          fill that was last set (read-only)
 java.awt.Image image
          Java AWT Image object associated with this renderer.
 int imageMode
          The current image alignment (read-only)
 float normalX
          Current normal vector.
 float normalY
          Current normal vector.
 float normalZ
          Current normal vector.
 int pixelCount
           
 int rectMode
          The current rect mode (read-only)
 int shapeMode
          The current shape alignment mode (read-only)
 float shininess
           
 boolean smooth
           
 float specularB
           
 float specularG
           
 float specularR
           
 int sphereDetailU
           
 int sphereDetailV
           
 boolean stroke
          true if stroke() is enabled, (read-only)
 int strokeCap
          Set by strokeCap() (read-only).
 int strokeColor
          stroke that was last set (read-only)
 int strokeJoin
          Set by strokeJoin() (read-only).
 float strokeWeight
          Last value set by strokeWeight() (read-only).
 int textAlign
          The current text align (read-only)
 int textAlignY
          The current vertical text alignment (read-only)
 PFont textFont
          The current text font (read-only)
 float textLeading
          The current text leading (read-only)
 int textMode
          The current text mode (read-only)
 float textSize
          The current text size (read-only)
 PImage textureImage
          Current image being used as a texture
 int textureMode
          Sets whether texture coordinates passed to vertex() calls will be based on coordinates that are based on the IMAGE or NORMALIZED.
 float textureU
          Current horizontal coordinate for texture, will always be between 0 and 1, even if using textureMode(IMAGE).
 float textureV
          Current vertical coordinate for texture, see above.
 boolean tint
          True if tint() is enabled (read-only).
 int tintColor
          tint that was last set (read-only)
 
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
PGraphics()
          Constructor for the PGraphics object.
 
Method Summary
 float alpha(int what)
           
 void ambient(float gray)
           
 void ambient(float x, float y, float z)
           
 void ambient(int rgb)
           
 void ambientLight(float red, float green, float blue)
           
 void ambientLight(float red, float green, float blue, float x, float y, float z)
           
 void applyMatrix(float n00, float n01, float n02, float n10, float n11, float n12)
          Apply a 3x2 affine transformation matrix.
 void applyMatrix(float n00, float n01, float n02, float n03, float n10, float n11, float n12, float n13, float n20, float n21, float n22, float n23, float n30, float n31, float n32, float n33)
          Apply a 4x4 transformation matrix.
 void applyMatrix(PMatrix source)
           
 void applyMatrix(PMatrix2D source)
           
 void applyMatrix(PMatrix3D source)
           
 void arc(float a, float b, float c, float d, float start, float stop)
          Identical parameters and placement to ellipse, but draws only an arc of that ellipse.
 void background(float gray)
          Set the background to a grayscale value, based on the current colorMode.
 void background(float gray, float alpha)
          See notes about alpha in background(x, y, z, a).
 void background(float x, float y, float z)
          Set the background to an r, g, b or h, s, b value, based on the current colorMode.
 void background(float x, float y, float z, float a)
          Clear the background with a color that includes an alpha value.
 void background(int rgb)
          Set the background to a gray or ARGB color.
 void background(int rgb, float alpha)
          See notes about alpha in background(x, y, z, a).
 void background(PImage image)
          Takes an RGB or ARGB image and sets it as the background.
 void beginCamera()
           
 void beginDraw()
          Prepares the PGraphics for drawing.
 void beginRaw(PGraphics rawGraphics)
          Record individual lines and triangles by echoing them to another renderer.
 void beginShape()
          Start a new shape of type POLYGON
 void beginShape(int kind)
          Start a new shape.
 void bezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
          Draw a cubic bezier curve.
 void bezier(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)
           
 void bezierDetail(int detail)
           
 float bezierPoint(float a, float b, float c, float d, float t)
          Evalutes quadratic bezier at point t for points a, b, c, d.
 float bezierTangent(float a, float b, float c, float d, float t)
          Provide the tangent at the given point on the bezier curve.
 void bezierVertex(float x2, float y2, float x3, float y3, float x4, float y4)
           
 void bezierVertex(float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)
           
 float blue(int what)
           
 void box(float size)
           
 void box(float w, float h, float d)
           
 void breakShape()
          This feature is in testing, do not use or rely upon its implementation
 float brightness(int what)
           
 void camera()
           
 void camera(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
           
 boolean canDraw()
          Some renderers have requirements re: when they are ready to draw.
 int color(float gray)
           
 int color(float gray, float alpha)
           
 int color(float x, float y, float z)
           
 int color(float x, float y, float z, float a)
           
 int color(int gray)
           
 int color(int rgb, float alpha)
           
 int color(int gray, int alpha)
           
 int color(int x, int y, int z)
           
 int color(int x, int y, int z, int a)
           
 void colorMode(int mode)
          Callback to handle clearing the background when begin/endRaw is in use.
 void colorMode(int mode, float max)
           
 void colorMode(int mode, float maxX, float maxY, float maxZ)
          Set the colorMode and the maximum values for (r, g, b) or (h, s, b).
 void colorMode(int mode, float maxX, float maxY, float maxZ, float maxA)
           
 void curve(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
          Draws a segment of Catmull-Rom curve.
 void curve(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)
           
 void curveDetail(int detail)
           
 float curvePoint(float a, float b, float c, float d, float t)
          Get a location along a catmull-rom curve segment.
 float curveTangent(float a, float b, float c, float d, float t)
          Calculate the tangent at a t value (0..1) on a Catmull-Rom curve.
 void curveTightness(float tightness)
           
 void curveVertex(float x, float y)
           
 void curveVertex(float x, float y, float z)
           
 void directionalLight(float red, float green, float blue, float nx, float ny, float nz)
           
 boolean displayable()
          Return true if this renderer should be drawn to the screen.
 void dispose()
          Handle any takedown for this graphics context.
 void edge(boolean edge)
          Sets whether the upcoming vertex is part of an edge.
 void ellipse(float a, float b, float c, float d)
           
 void ellipseMode(int mode)
           
 void emissive(float gray)
           
 void emissive(float x, float y, float z)
           
 void emissive(int rgb)
           
 void endCamera()
           
 void endDraw()
          This will finalize rendering so that it can be shown on-screen.
 void endRaw()
           
 void endShape()
           
 void endShape(int mode)
           
 void fill(float gray)
           
 void fill(float gray, float alpha)
           
 void fill(float x, float y, float z)
           
 void fill(float x, float y, float z, float a)
           
 void fill(int rgb)
          Set the fill to either a grayscale value or an ARGB int.
 void fill(int rgb, float alpha)
           
 void flush()
           
 void frustum(float left, float right, float bottom, float top, float near, float far)
           
 PMatrix getMatrix()
           
 PMatrix2D getMatrix(PMatrix2D target)
          Copy the current transformation matrix into the specified target.
 PMatrix3D getMatrix(PMatrix3D target)
          Copy the current transformation matrix into the specified target.
 PStyle getStyle()
           
 PStyle getStyle(PStyle s)
           
 float green(int what)
           
 void hint(int which)
          Enable a hint option.
 float hue(int what)
           
 void image(PImage image, float x, float y)
           
 void image(PImage image, float x, float y, float c, float d)
           
 void image(PImage image, float a, float b, float c, float d, int u1, int v1, int u2, int v2)
          Draw an image(), also specifying u/v coordinates.
 void imageMode(int mode)
          The mode can only be set to CORNERS, CORNER, and CENTER.
 boolean is2D()
          Return true if this renderer supports 2D drawing.
 boolean is3D()
          Return true if this renderer supports 2D drawing.
 int lerpColor(int c1, int c2, float amt)
          Interpolate between two colors, using the current color mode.
static int lerpColor(int c1, int c2, float amt, int mode)
          Interpolate between two colors.
 void lightFalloff(float constant, float linear, float quadratic)
           
 void lights()
           
 void lightSpecular(float x, float y, float z)
           
 void line(float x1, float y1, float x2, float y2)
           
 void line(float x1, float y1, float z1, float x2, float y2, float z2)
           
 float modelX(float x, float y, float z)
          Returns the model space x value for an x, y, z coordinate.
 float modelY(float x, float y, float z)
          Returns the model space y value for an x, y, z coordinate.
 float modelZ(float x, float y, float z)
          Returns the model space z value for an x, y, z coordinate.
 void noFill()
           
 void noLights()
           
 void normal(float nx, float ny, float nz)
          Sets the current normal vector.
 void noSmooth()
          Disable smoothing.
 void noStroke()
           
 void noTint()
           
 void ortho()
           
 void ortho(float left, float right, float bottom, float top, float near, float far)
           
 void perspective()
           
 void perspective(float fovy, float aspect, float zNear, float zFar)
           
 void point(float x, float y)
           
 void point(float x, float y, float z)
           
 void pointLight(float red, float green, float blue, float x, float y, float z)
           
 void popMatrix()
          Replace the current transformation matrix with the top of the stack.
 void popStyle()
           
 void printCamera()
           
 void printMatrix()
          Print the current model (or "transformation") matrix.
 void printProjection()
           
 void pushMatrix()
          Push a copy of the current transformation matrix onto the stack.
 void pushStyle()
           
 void quad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
           
 void rect(float a, float b, float c, float d)
           
 void rectMode(int mode)
           
 float red(int what)
           
 void resetMatrix()
          Set the current transformation matrix to identity.
 void rotate(float angle)
          Two dimensional rotation.
 void rotate(float angle, float vx, float vy, float vz)
          Rotate about a vector in space.
 void rotateX(float angle)
          Rotate around the X axis.
 void rotateY(float angle)
          Rotate around the Y axis.
 void rotateZ(float angle)
          Rotate around the Z axis.
 float saturation(int what)
           
 void scale(float s)
          Scale in all dimensions.
 void scale(float sx, float sy)
          Scale in X and Y.
 void scale(float x, float y, float z)
          Scale in X, Y, and Z.
 float screenX(float x, float y)
          Given an x and y coordinate, returns the x position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.
 float screenX(float x, float y, float z)
          Maps a three dimensional point to its placement on-screen.
 float screenY(float x, float y)
          Given an x and y coordinate, returns the y position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.
 float screenY(float x, float y, float z)
          Maps a three dimensional point to its placement on-screen.
 float screenZ(float x, float y, float z)
          Maps a three dimensional point to its placement on-screen.
 void setMatrix(PMatrix source)
          Set the current transformation matrix to the contents of another.
 void setMatrix(PMatrix2D source)
          Set the current transformation to the contents of the specified source.
 void setMatrix(PMatrix3D source)
          Set the current transformation to the contents of the specified source.
 void setParent(PApplet parent)
           
 void setPath(java.lang.String path)
           
 void setPrimary(boolean primary)
          Set (or unset) this as the main drawing surface.
 void setSize(int w, int h)
          The final step in setting up a renderer, set its size of this renderer.
 void shape(PShape shape)
           
 void shape(PShape shape, float x, float y)
          Convenience method to draw at a particular location.
 void shape(PShape shape, float x, float y, float c, float d)
           
 void shapeMode(int mode)
          Set the orientation for the shape() command (like imageMode() or rectMode()).
 void shininess(float shine)
           
static void showException(java.lang.String msg)
          Show an renderer-related exception that halts the program.
static void showWarning(java.lang.String msg)
          Show a renderer error, and keep track of it so that it's only shown once.
 void smooth()
          If true in PImage, use bilinear interpolation for copy() operations.
 void specular(float gray)
           
 void specular(float x, float y, float z)
           
 void specular(int rgb)
           
 void sphere(float r)
          Draw a sphere with radius r centered at coordinate 0, 0, 0.
 void sphereDetail(int res)
           
 void sphereDetail(int ures, int vres)
          Set the detail level for approximating a sphere.
 void spotLight(float red, float green, float blue, float x, float y, float z, float nx, float ny, float nz, float angle, float concentration)
           
 void stroke(float gray)
           
 void stroke(float gray, float alpha)
           
 void stroke(float x, float y, float z)
           
 void stroke(float x, float y, float z, float a)
           
 void stroke(int rgb)
          Set the tint to either a grayscale or ARGB value.
 void stroke(int rgb, float alpha)
           
 void strokeCap(int cap)
           
 void strokeJoin(int join)
           
 void strokeWeight(float weight)
           
 void style(PStyle s)
           
 void text(char c)
          Write text where we just left off.
 void text(char[] chars, int start, int stop, float x, float y)
          Method to draw text from an array of chars.
 void text(char[] chars, int start, int stop, float x, float y, float z)
           
 void text(char c, float x, float y)
          Draw a single character on screen.
 void text(char c, float x, float y, float z)
          Draw a single character on screen (with a z coordinate)
 void text(float num, float x, float y)
          This does a basic number formatting, to avoid the generally ugly appearance of printing floats.
 void text(float num, float x, float y, float z)
           
 void text(int num, float x, float y)
           
 void text(int num, float x, float y, float z)
           
 void text(java.lang.String str)
          Write text where we just left off.
 void text(java.lang.String str, float x, float y)
          Draw a chunk of text.
 void text(java.lang.String str, float x, float y, float z)
          Same as above but with a z coordinate.
 void text(java.lang.String str, float x1, float y1, float x2, float y2)
          Draw text in a box that is constrained to a particular size.
 void text(java.lang.String s, float x1, float y1, float x2, float y2, float z)
           
 void textAlign(int align)
          Sets the alignment of the text to one of LEFT, CENTER, or RIGHT.
 void textAlign(int alignX, int alignY)
          Sets the horizontal and vertical alignment of the text.
 float textAscent()
          Returns the ascent of the current font at the current size.
 float textDescent()
          Returns the descent of the current font at the current size.
 void textFont(PFont which)
          Sets the current font.
 void textFont(PFont which, float size)
          Useful function to set the font and size at the same time.
 void textLeading(float leading)
          Set the text leading to a specific value.
 void textMode(int mode)
          Sets the text rendering/placement to be either SCREEN (direct to the screen, exact coordinates, only use the font's original size) or MODEL (the default, where text is manipulated by translate() and can have a textSize).
 void textSize(float size)
          Sets the text size, also resets the value for the leading.
 void texture(PImage image)
          Set texture image for current shape.
 void textureMode(int mode)
          Set texture mode to either to use coordinates based on the IMAGE (more intuitive for new users) or NORMALIZED (better for advanced chaps)
 float textWidth(char c)
           
 float textWidth(java.lang.String str)
          Return the width of a line of text.
 void tint(float gray)
           
 void tint(float gray, float alpha)
           
 void tint(float x, float y, float z)
           
 void tint(float x, float y, float z, float a)
           
 void tint(int rgb)
          Set the tint to either a grayscale or ARGB value.
 void tint(int rgb, float alpha)
           
 void translate(float tx, float ty)
          Translate in X and Y.
 void translate(float tx, float ty, float tz)
          Translate in X, Y, and Z.
 void triangle(float x1, float y1, float x2, float y2, float x3, float y3)
           
 void vertex(float[] v)
          Used by renderer subclasses or PShape to efficiently pass in already formatted vertex information.
 void vertex(float x, float y)
           
 void vertex(float x, float y, float z)
           
 void vertex(float x, float y, float u, float v)
           
 void vertex(float x, float y, float z, float u, float v)
           
 
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
 

Field Detail

pixelCount

public int pixelCount

smooth

public boolean smooth

colorMode

public int colorMode
The current colorMode


colorModeX

public float colorModeX
Max value for red (or hue) set by colorMode


colorModeY

public float colorModeY
Max value for green (or saturation) set by colorMode


colorModeZ

public float colorModeZ
Max value for blue (or value) set by colorMode


colorModeA

public float colorModeA
Max value for alpha set by colorMode


tint

public boolean tint
True if tint() is enabled (read-only). Using tint/tintColor seems a better option for naming than tintEnabled/tint because the latter seems ugly, even though g.tint as the actual color seems a little more intuitive, it's just that g.tintEnabled is even more unintuitive. Same goes for fill and stroke, et al.


tintColor

public int tintColor
tint that was last set (read-only)


fill

public boolean fill
true if fill() is enabled, (read-only)


fillColor

public int fillColor
fill that was last set (read-only)


stroke

public boolean stroke
true if stroke() is enabled, (read-only)


strokeColor

public int strokeColor
stroke that was last set (read-only)


strokeWeight

public float strokeWeight
Last value set by strokeWeight() (read-only). This has a default setting, rather than fighting with renderers about whether that renderer supports thick lines.


strokeJoin

public int strokeJoin
Set by strokeJoin() (read-only). This has a default setting so that strokeJoin() need not be called by defaults, because subclasses may not implement it (i.e. PGraphicsGL)


strokeCap

public int strokeCap
Set by strokeCap() (read-only). This has a default setting so that strokeCap() need not be called by defaults, because subclasses may not implement it (i.e. PGraphicsGL)


rectMode

public int rectMode
The current rect mode (read-only)


ellipseMode

public int ellipseMode
The current ellipse mode (read-only)


shapeMode

public int shapeMode
The current shape alignment mode (read-only)


imageMode

public int imageMode
The current image alignment (read-only)


textFont

public PFont textFont
The current text font (read-only)


textAlign

public int textAlign
The current text align (read-only)


textAlignY

public int textAlignY
The current vertical text alignment (read-only)


textMode

public int textMode
The current text mode (read-only)


textSize

public float textSize
The current text size (read-only)


textLeading

public float textLeading
The current text leading (read-only)


ambientR

public float ambientR

ambientG

public float ambientG

ambientB

public float ambientB

specularR

public float specularR

specularG

public float specularG

specularB

public float specularB

emissiveR

public float emissiveR

emissiveG

public float emissiveG

emissiveB

public float emissiveB

shininess

public float shininess

backgroundColor

public int backgroundColor
Last background color that was set, zero if an image


image

public java.awt.Image image
Java AWT Image object associated with this renderer. For P2D and P3D, this will be associated with their MemoryImageSource. For PGraphicsJava2D, it will be the offscreen drawing buffer.


bezierDetail

public int bezierDetail

curveTightness

public float curveTightness

edge

public boolean edge

normalX

public float normalX
Current normal vector.


normalY

public float normalY
Current normal vector.


normalZ

public float normalZ
Current normal vector.


textureMode

public int textureMode
Sets whether texture coordinates passed to vertex() calls will be based on coordinates that are based on the IMAGE or NORMALIZED.


textureU

public float textureU
Current horizontal coordinate for texture, will always be between 0 and 1, even if using textureMode(IMAGE).


textureV

public float textureV
Current vertical coordinate for texture, see above.


textureImage

public PImage textureImage
Current image being used as a texture


sphereDetailU

public int sphereDetailU

sphereDetailV

public int sphereDetailV
Constructor Detail

PGraphics

public PGraphics()
Constructor for the PGraphics object. Use this to ensure that the defaults get set properly. In a subclass, use this(w, h) as the first line of a subclass' constructor to properly set the internal fields and defaults.

Method Detail

setParent

public void setParent(PApplet parent)

setPrimary

public void setPrimary(boolean primary)
Set (or unset) this as the main drawing surface. Meaning that it can safely be set to opaque (and given a default gray background), or anything else that goes along with that.


setPath

public void setPath(java.lang.String path)

setSize

public void setSize(int w,
                    int h)
The final step in setting up a renderer, set its size of this renderer. This was formerly handled by the constructor, but instead it's been broken out so that setParent/setPrimary/setPath can be handled differently. Important that this is ignored by preproc.pl because otherwise it will override setSize() in PApplet/Applet/Component, which will 1) not call super.setSize(), and 2) will cause the renderer to be resized from the event thread (EDT), causing a nasty crash as it collides with the animation thread.


dispose

public void dispose()
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.


canDraw

public boolean canDraw()
Some renderers have requirements re: when they are ready to draw.


beginDraw

public void beginDraw()
Prepares the PGraphics for drawing.

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


endDraw

public void endDraw()
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.


flush

public void flush()

hint

public void hint(int which)
Enable a hint option.

For the most part, hints are temporary api quirks, for which a proper api hasn't been properly worked out. for instance SMOOTH_IMAGES existed because smooth() wasn't yet implemented, but it will soon go away.

They also exist for obscure features in the graphics engine, like enabling/disabling single pixel lines that ignore the zbuffer, the way they do in alphabot.

Current hint options:


beginShape

public void beginShape()
Start a new shape of type POLYGON


beginShape

public void beginShape(int kind)
Start a new shape.

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.


edge

public void edge(boolean edge)
Sets whether the upcoming vertex is part of an edge. Equivalent to glEdgeFlag(), for people familiar with OpenGL.


normal

public void normal(float nx,
                   float ny,
                   float nz)
Sets the current normal vector. Only applies with 3D rendering and inside a beginShape/endShape block.

This is for drawing three dimensional shapes and surfaces, allowing you to specify a vector perpendicular to the surface of the shape, which determines how lighting affects it.

For the most part, PGraphics3D will attempt to automatically assign normals to shapes, but since that's imperfect, this is a better option when you want more control.

For people familiar with OpenGL, this function is basically identical to glNormal3f().


textureMode

public void textureMode(int mode)
Set texture mode to either to use coordinates based on the IMAGE (more intuitive for new users) or NORMALIZED (better for advanced chaps)


texture

public void texture(PImage image)
Set texture image for current shape. Needs to be called between @see beginShape and @see endShape

Parameters:
image - reference to a PImage object

vertex

public void vertex(float x,
                   float y)

vertex

public void vertex(float x,
                   float y,
                   float z)

vertex

public void vertex(float[] v)
Used by renderer subclasses or PShape to efficiently pass in already formatted vertex information.

Parameters:
v - vertex parameters, as a float array of length VERTEX_FIELD_COUNT

vertex

public void vertex(float x,
                   float y,
                   float u,
                   float v)

vertex

public void vertex(float x,
                   float y,
                   float z,
                   float u,
                   float v)

breakShape

public void breakShape()
This feature is in testing, do not use or rely upon its implementation


endShape

public void endShape()

endShape

public void endShape(int mode)

bezierVertex

public void bezierVertex(float x2,
                         float y2,
                         float x3,
                         float y3,
                         float x4,
                         float y4)

bezierVertex

public void bezierVertex(float x2,
                         float y2,
                         float z2,
                         float x3,
                         float y3,
                         float z3,
                         float x4,
                         float y4,
                         float z4)

curveVertex

public void curveVertex(float x,
                        float y)

curveVertex

public void curveVertex(float x,
                        float y,
                        float z)

point

public void point(float x,
                  float y)

point

public void point(float x,
                  float y,
                  float z)

line

public void line(float x1,
                 float y1,
                 float x2,
                 float y2)

line

public void line(float x1,
                 float y1,
                 float z1,
                 float x2,
                 float y2,
                 float z2)

triangle

public void triangle(float x1,
                     float y1,
                     float x2,
                     float y2,
                     float x3,
                     float y3)

quad

public void quad(float x1,
                 float y1,
                 float x2,
                 float y2,
                 float x3,
                 float y3,
                 float x4,
                 float y4)

rectMode

public void rectMode(int mode)

rect

public void rect(float a,
                 float b,
                 float c,
                 float d)

ellipseMode

public void ellipseMode(int mode)

ellipse

public void ellipse(float a,
                    float b,
                    float c,
                    float d)

arc

public void arc(float a,
                float b,
                float c,
                float d,
                float start,
                float stop)
Identical parameters and placement to ellipse, but draws only an arc of that ellipse.

start and stop are always radians because angleMode() was goofy. ellipseMode() sets the placement.

also tries to be smart about start < stop.


box

public void box(float size)

box

public void box(float w,
                float h,
                float d)

sphereDetail

public void sphereDetail(int res)

sphereDetail

public void sphereDetail(int ures,
                         int vres)
Set the detail level for approximating a sphere. The ures and vres params control the horizontal and vertical resolution. Code for sphereDetail() submitted by toxi [031031]. Code for enhanced u/v version from davbol [080801].


sphere

public void sphere(float r)
Draw a sphere with radius r centered at coordinate 0, 0, 0.

Implementation notes:

cache all the points of the sphere in a static array top and bottom are just a bunch of triangles that land in the center point

sphere is a series of concentric circles who radii vary along the shape, based on, er.. cos or something

 [toxi 031031] new sphere code. removed all multiplies with
 radius, as scale() will take care of that anyway

 [toxi 031223] updated sphere code (removed modulos)
 and introduced sphereAt(x,y,z,r)
 to avoid additional translate()'s on the user/sketch side

 [davbol 080801] now using separate sphereDetailU/V
 


bezierPoint

public float bezierPoint(float a,
                         float b,
                         float c,
                         float d,
                         float t)
Evalutes quadratic bezier at point t for points a, b, c, d. t varies between 0 and 1, and a and d are the on curve points, b and c are the control points. this can be done once with the x coordinates and a second time with the y coordinates to get the location of a bezier curve at t.

For instance, to convert the following example:

 stroke(255, 102, 0);
 line(85, 20, 10, 10);
 line(90, 90, 15, 80);
 stroke(0, 0, 0);
 bezier(85, 20, 10, 10, 90, 90, 15, 80);

 // draw it in gray, using 10 steps instead of the default 20
 // this is a slower way to do it, but useful if you need
 // to do things with the coordinates at each step
 stroke(128);
 beginShape(LINE_STRIP);
 for (int i = 0; i <= 10; i++) {
   float t = i / 10.0f;
   float x = bezierPoint(85, 10, 90, 15, t);
   float y = bezierPoint(20, 10, 90, 80, t);
   vertex(x, y);
 }
 endShape();


bezierTangent

public float bezierTangent(float a,
                           float b,
                           float c,
                           float d,
                           float t)
Provide the tangent at the given point on the bezier curve. Fix from davbol for 0136.


bezierDetail

public void bezierDetail(int detail)

bezier

public void bezier(float x1,
                   float y1,
                   float x2,
                   float y2,
                   float x3,
                   float y3,
                   float x4,
                   float y4)
Draw a cubic bezier curve. The first and last points are the on-curve points. The middle two are the 'control' points, or 'handles' in an application like Illustrator.

Identical to typing:

beginShape();
 vertex(x1, y1);
 bezierVertex(x2, y2, x3, y3, x4, y4);
 endShape();
 
In Postscript-speak, this would be:
moveto(x1, y1);
 curveto(x2, y2, x3, y3, x4, y4);
If you were to try and continue that curve like so:
curveto(x5, y5, x6, y6, x7, y7);
This would be done in processing by adding these statements:
bezierVertex(x5, y5, x6, y6, x7, y7)
 
To draw a quadratic (instead of cubic) curve, use the control point twice by doubling it:
bezier(x1, y1, cx, cy, cx, cy, x2, y2);


bezier

public void bezier(float x1,
                   float y1,
                   float z1,
                   float x2,
                   float y2,
                   float z2,
                   float x3,
                   float y3,
                   float z3,
                   float x4,
                   float y4,
                   float z4)

curvePoint

public float curvePoint(float a,
                        float b,
                        float c,
                        float d,
                        float t)
Get a location along a catmull-rom curve segment.

Parameters:
t - Value between zero and one for how far along the segment

curveTangent

public float curveTangent(float a,
                          float b,
                          float c,
                          float d,
                          float t)
Calculate the tangent at a t value (0..1) on a Catmull-Rom curve. Code thanks to Dave Bollinger (Bug #715)


curveDetail

public void curveDetail(int detail)

curveTightness

public void curveTightness(float tightness)

curve

public void curve(float x1,
                  float y1,
                  float x2,
                  float y2,
                  float x3,
                  float y3,
                  float x4,
                  float y4)
Draws a segment of Catmull-Rom curve.

As of 0070, this function no longer doubles the first and last points. The curves are a bit more boring, but it's more mathematically correct, and properly mirrored in curvePoint().

Identical to typing out:

 beginShape();
 curveVertex(x1, y1);
 curveVertex(x2, y2);
 curveVertex(x3, y3);
 curveVertex(x4, y4);
 endShape();
 


curve

public void curve(float x1,
                  float y1,
                  float z1,
                  float x2,
                  float y2,
                  float z2,
                  float x3,
                  float y3,
                  float z3,
                  float x4,
                  float y4,
                  float z4)

smooth

public void smooth()
If true in PImage, use bilinear interpolation for copy() operations. When inherited by PGraphics, also controls shapes.


noSmooth

public void noSmooth()
Disable smoothing. See smooth().


imageMode

public void imageMode(int mode)
The mode can only be set to CORNERS, CORNER, and CENTER.

Support for CENTER was added in release 0146.


image

public void image(PImage image,
                  float x,
                  float y)

image

public void image(PImage image,
                  float x,
                  float y,
                  float c,
                  float d)

image

public void image(PImage image,
                  float a,
                  float b,
                  float c,
                  float d,
                  int u1,
                  int v1,
                  int u2,
                  int v2)
Draw an image(), also specifying u/v coordinates. In this method, the u, v coordinates are always based on image space location, regardless of the current textureMode().


shapeMode

public void shapeMode(int mode)
Set the orientation for the shape() command (like imageMode() or rectMode()).

Parameters:
mode - Either CORNER, CORNERS, or CENTER.

shape

public void shape(PShape shape)

shape

public void shape(PShape shape,
                  float x,
                  float y)
Convenience method to draw at a particular location.


shape

public void shape(PShape shape,
                  float x,
                  float y,
                  float c,
                  float d)

textAlign

public void textAlign(int align)
Sets the alignment of the text to one of LEFT, CENTER, or RIGHT. This will also reset the vertical text alignment to BASELINE.


textAlign

public void textAlign(int alignX,
                      int alignY)
Sets the horizontal and vertical alignment of the text. The horizontal alignment can be one of LEFT, CENTER, or RIGHT. The vertical alignment can be TOP, BOTTOM, CENTER, or the BASELINE (the default).


textAscent

public float textAscent()
Returns the ascent of the current font at the current size. This is a method, rather than a variable inside the PGraphics object because it requires calculation.


textDescent

public float textDescent()
Returns the descent of the current font at the current size. This is a method, rather than a variable inside the PGraphics object because it requires calculation.


textFont

public void textFont(PFont which)
Sets the current font. The font's size will be the "natural" size of this font (the size that was set when using "Create Font"). The leading will also be reset.


textFont

public void textFont(PFont which,
                     float size)
Useful function to set the font and size at the same time.


textLeading

public void textLeading(float leading)
Set the text leading to a specific value. If using a custom value for the text leading, you'll have to call textLeading() again after any calls to textSize().


textMode

public void textMode(int mode)
Sets the text rendering/placement to be either SCREEN (direct to the screen, exact coordinates, only use the font's original size) or MODEL (the default, where text is manipulated by translate() and can have a textSize). The text size cannot be set when using textMode(SCREEN), because it uses the pixels directly from the font.


textSize

public void textSize(float size)
Sets the text size, also resets the value for the leading.


textWidth

public float textWidth(char c)

textWidth

public float textWidth(java.lang.String str)
Return the width of a line of text. If the text has multiple lines, this returns the length of the longest line.


text

public void text(char c)
Write text where we just left off.


text

public void text(char c,
                 float x,
                 float y)
Draw a single character on screen. Extremely slow when used with textMode(SCREEN) and Java 2D, because loadPixels has to be called first and updatePixels last.


text

public void text(char c,
                 float x,
                 float y,
                 float z)
Draw a single character on screen (with a z coordinate)


text

public void text(java.lang.String str)
Write text where we just left off.


text

public void text(java.lang.String str,
                 float x,
                 float y)
Draw a chunk of text. Newlines that are \n (Unix newline or linefeed char, ascii 10) are honored, but \r (carriage return, Windows and Mac OS) are ignored.


text

public void text(char[] chars,
                 int start,
                 int stop,
                 float x,
                 float y)
Method to draw text from an array of chars. This method will usually be more efficient than drawing from a String object, because the String will not be converted to a char array before drawing.


text

public void text(java.lang.String str,
                 float x,
                 float y,
                 float z)
Same as above but with a z coordinate.


text

public void text(char[] chars,
                 int start,
                 int stop,
                 float x,
                 float y,
                 float z)

text

public void text(java.lang.String str,
                 float x1,
                 float y1,
                 float x2,
                 float y2)
Draw text in a box that is constrained to a particular size. The current rectMode() determines what the coordinates mean (whether x1/y1/x2/y2 or x/y/w/h).

Note that the x,y coords of the start of the box will align with the *ascent* of the text, not the baseline, as is the case for the other text() functions.

Newlines that are \n (Unix newline or linefeed char, ascii 10) are honored, and \r (carriage return, Windows and Mac OS) are ignored.


text

public void text(java.lang.String s,
                 float x1,
                 float y1,
                 float x2,
                 float y2,
                 float z)

text

public void text(int num,
                 float x,
                 float y)

text

public void text(int num,
                 float x,
                 float y,
                 float z)

text

public void text(float num,
                 float x,
                 float y)
This does a basic number formatting, to avoid the generally ugly appearance of printing floats. Users who want more control should use their own nf() cmmand, or if they want the long, ugly version of float, use String.valueOf() to convert the float to a String first.


text

public void text(float num,
                 float x,
                 float y,
                 float z)

pushMatrix

public void pushMatrix()
Push a copy of the current transformation matrix onto the stack.


popMatrix

public void popMatrix()
Replace the current transformation matrix with the top of the stack.


translate

public void translate(float tx,
                      float ty)
Translate in X and Y.


translate

public void translate(float tx,
                      float ty,
                      float tz)
Translate in X, Y, and Z.


rotate

public void rotate(float angle)
Two dimensional rotation. Same as rotateZ (this is identical to a 3D rotation along the z-axis) but included for clarity. It'd be weird for people drawing 2D graphics to be using rotateZ. And they might kick our a-- for the confusion. Additional background.


rotateX

public void rotateX(float angle)
Rotate around the X axis.


rotateY

public void rotateY(float angle)
Rotate around the Y axis.


rotateZ

public void rotateZ(float angle)
Rotate around the Z axis. The functions rotate() and rotateZ() are identical, it's just that it make sense to have rotate() and then rotateX() and rotateY() when using 3D; nor does it make sense to use a function called rotateZ() if you're only doing things in 2D. so we just decided to have them both be the same.


rotate

public void rotate(float angle,
                   float vx,
                   float vy,
                   float vz)
Rotate about a vector in space. Same as the glRotatef() function.


scale

public void scale(float s)
Scale in all dimensions.


scale

public void scale(float sx,
                  float sy)
Scale in X and Y. Equivalent to scale(sx, sy, 1). Not recommended for use in 3D, because the z-dimension is just scaled by 1, since there's no way to know what else to scale it by.


scale

public void scale(float x,
                  float y,
                  float z)
Scale in X, Y, and Z.


resetMatrix

public void resetMatrix()
Set the current transformation matrix to identity.


applyMatrix

public void applyMatrix(PMatrix source)

applyMatrix

public void applyMatrix(PMatrix2D source)

applyMatrix

public void applyMatrix(float n00,
                        float n01,
                        float n02,
                        float n10,
                        float n11,
                        float n12)
Apply a 3x2 affine transformation matrix.


applyMatrix

public void applyMatrix(PMatrix3D source)

applyMatrix

public void applyMatrix(float n00,
                        float n01,
                        float n02,
                        float n03,
                        float n10,
                        float n11,
                        float n12,
                        float n13,
                        float n20,
                        float n21,
                        float n22,
                        float n23,
                        float n30,
                        float n31,
                        float n32,
                        float n33)
Apply a 4x4 transformation matrix.


getMatrix

public PMatrix getMatrix()

getMatrix

public PMatrix2D getMatrix(PMatrix2D target)
Copy the current transformation matrix into the specified target. Pass in null to create a new matrix.


getMatrix

public PMatrix3D getMatrix(PMatrix3D target)
Copy the current transformation matrix into the specified target. Pass in null to create a new matrix.


setMatrix

public void setMatrix(PMatrix source)
Set the current transformation matrix to the contents of another.


setMatrix

public void setMatrix(PMatrix2D source)
Set the current transformation to the contents of the specified source.


setMatrix

public void setMatrix(PMatrix3D source)
Set the current transformation to the contents of the specified source.


printMatrix

public void printMatrix()
Print the current model (or "transformation") matrix.


beginCamera

public void beginCamera()

endCamera

public void endCamera()

camera

public void camera()

camera

public void camera(float eyeX,
                   float eyeY,
                   float eyeZ,
                   float centerX,
                   float centerY,
                   float centerZ,
                   float upX,
                   float upY,
                   float upZ)

printCamera

public void printCamera()

ortho

public void ortho()

ortho

public void ortho(float left,
                  float right,
                  float bottom,
                  float top,
                  float near,
                  float far)

perspective

public void perspective()

perspective

public void perspective(float fovy,
                        float aspect,
                        float zNear,
                        float zFar)

frustum

public void frustum(float left,
                    float right,
                    float bottom,
                    float top,
                    float near,
                    float far)

printProjection

public void printProjection()

screenX

public float screenX(float x,
                     float y)
Given an x and y coordinate, returns the x position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.


screenY

public float screenY(float x,
                     float y)
Given an x and y coordinate, returns the y position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.


screenX

public float screenX(float x,
                     float y,
                     float z)
Maps a three dimensional point to its placement on-screen.

Given an (x, y, z) coordinate, returns the x position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.


screenY

public float screenY(float x,
                     float y,
                     float z)
Maps a three dimensional point to its placement on-screen.

Given an (x, y, z) coordinate, returns the y position of where that point would be placed on screen, once affected by translate(), scale(), or any other transformations.


screenZ

public float screenZ(float x,
                     float y,
                     float z)
Maps a three dimensional point to its placement on-screen.

Given an (x, y, z) coordinate, returns its z value. This value can be used to determine if an (x, y, z) coordinate is in front or in back of another (x, y, z) coordinate. The units are based on how the zbuffer is set up, and don't relate to anything "real". They're only useful for in comparison to another value obtained from screenZ(), or directly out of the zbuffer[].


modelX

public float modelX(float x,
                    float y,
                    float z)
Returns the model space x value for an x, y, z coordinate.

This will give you a coordinate after it has been transformed by translate(), rotate(), and camera(), but not yet transformed by the projection matrix. For instance, his can be useful for figuring out how points in 3D space relate to the edge coordinates of a shape.


modelY

public float modelY(float x,
                    float y,
                    float z)
Returns the model space y value for an x, y, z coordinate.


modelZ

public float modelZ(float x,
                    float y,
                    float z)
Returns the model space z value for an x, y, z coordinate.


pushStyle

public void pushStyle()

popStyle

public void popStyle()

style

public void style(PStyle s)

getStyle

public PStyle getStyle()

getStyle

public PStyle getStyle(PStyle s)

strokeWeight

public void strokeWeight(float weight)

strokeJoin

public void strokeJoin(int join)

strokeCap

public void strokeCap(int cap)

noStroke

public void noStroke()

stroke

public void stroke(int rgb)
Set the tint to either a grayscale or ARGB value. See notes attached to the fill() function.


stroke

public void stroke(int rgb,
                   float alpha)

stroke

public void stroke(float gray)

stroke

public void stroke(float gray,
                   float alpha)

stroke

public void stroke(float x,
                   float y,
                   float z)

stroke

public void stroke(float x,
                   float y,
                   float z,
                   float a)

noTint

public void noTint()

tint

public void tint(int rgb)
Set the tint to either a grayscale or ARGB value.


tint

public void tint(int rgb,
                 float alpha)

tint

public void tint(float gray)

tint

public void tint(float gray,
                 float alpha)

tint

public void tint(float x,
                 float y,
                 float z)

tint

public void tint(float x,
                 float y,
                 float z,
                 float a)

noFill

public void noFill()

fill

public void fill(int rgb)
Set the fill to either a grayscale value or an ARGB int.


fill

public void fill(int rgb,
                 float alpha)

fill

public void fill(float gray)

fill

public void fill(float gray,
                 float alpha)

fill

public void fill(float x,
                 float y,
                 float z)

fill

public void fill(float x,
                 float y,
                 float z,
                 float a)

ambient

public void ambient(int rgb)

ambient

public void ambient(float gray)

ambient

public void ambient(float x,
                    float y,
                    float z)

specular

public void specular(int rgb)

specular

public void specular(float gray)

specular

public void specular(float x,
                     float y,
                     float z)

shininess

public void shininess(float shine)

emissive

public void emissive(int rgb)

emissive

public void emissive(float gray)

emissive

public void emissive(float x,
                     float y,
                     float z)

lights

public void lights()

noLights

public void noLights()

ambientLight

public void ambientLight(float red,
                         float green,
                         float blue)

ambientLight

public void ambientLight(float red,
                         float green,
                         float blue,
                         float x,
                         float y,
                         float z)

directionalLight

public void directionalLight(float red,
                             float green,
                             float blue,
                             float nx,
                             float ny,
                             float nz)

pointLight

public void pointLight(float red,
                       float green,
                       float blue,
                       float x,
                       float y,
                       float z)

spotLight

public void spotLight(float red,
                      float green,
                      float blue,
                      float x,
                      float y,
                      float z,
                      float nx,
                      float ny,
                      float nz,
                      float angle,
                      float concentration)

lightFalloff

public void lightFalloff(float constant,
                         float linear,
                         float quadratic)

lightSpecular

public void lightSpecular(float x,
                          float y,
                          float z)

background

public void background(int rgb)
Set the background to a gray or ARGB color.

For the main drawing surface, the alpha value will be ignored. However, alpha can be used on PGraphics objects from createGraphics(). This is the only way to set all the pixels partially transparent, for instance.

Note that background() should be called before any transformations occur, because some implementations may require the current transformation matrix to be identity before drawing.


background

public void background(int rgb,
                       float alpha)
See notes about alpha in background(x, y, z, a).


background

public void background(float gray)
Set the background to a grayscale value, based on the current colorMode.


background

public void background(float gray,
                       float alpha)
See notes about alpha in background(x, y, z, a).


background

public void background(float x,
                       float y,
                       float z)
Set the background to an r, g, b or h, s, b value, based on the current colorMode.


background

public void background(float x,
                       float y,
                       float z,
                       float a)
Clear the background with a color that includes an alpha value. This can only be used with objects created by createGraphics(), because the main drawing surface cannot be set transparent.

It might be tempting to use this function to partially clear the screen on each frame, however that's not how this function works. When calling background(), the pixels will be replaced with pixels that have that level of transparency. To do a semi-transparent overlay, use fill() with alpha and draw a rectangle.


background

public void background(PImage image)
Takes an RGB or ARGB image and sets it as the background. The width and height of the image must be the same size as the sketch. Use image.resize(width, height) to make short work of such a task.

Note that even if the image is set as RGB, the high 8 bits of each pixel should be set opaque (0xFF000000), because the image data will be copied directly to the screen, and non-opaque background images may have strange behavior. Using image.filter(OPAQUE) will handle this easily.

When using 3D, this will also clear the zbuffer (if it exists).


colorMode

public void colorMode(int mode)
Callback to handle clearing the background when begin/endRaw is in use. Handled as separate function for OpenGL (or other) subclasses that override backgroundImpl() but still needs this to work properly.


colorMode

public void colorMode(int mode,
                      float max)

colorMode

public void colorMode(int mode,
                      float maxX,
                      float maxY,
                      float maxZ)
Set the colorMode and the maximum values for (r, g, b) or (h, s, b).

Note that this doesn't set the maximum for the alpha value, which might be confusing if for instance you switched to

colorMode(HSB, 360, 100, 100);
because the alpha values were still between 0 and 255.


colorMode

public void colorMode(int mode,
                      float maxX,
                      float maxY,
                      float maxZ,
                      float maxA)

color

public final int color(int gray)

color

public final int color(float gray)

color

public final int color(int gray,
                       int alpha)
Parameters:
gray - can be packed ARGB or a gray in this case

color

public final int color(int rgb,
                       float alpha)
Parameters:
rgb - can be packed ARGB or a gray in this case

color

public final int color(float gray,
                       float alpha)

color

public final int color(int x,
                       int y,
                       int z)

color

public final int color(float x,
                       float y,
                       float z)

color

public final int color(int x,
                       int y,
                       int z,
                       int a)

color

public final int color(float x,
                       float y,
                       float z,
                       float a)

alpha

public final float alpha(int what)

red

public final float red(int what)

green

public final float green(int what)

blue

public final float blue(int what)

hue

public final float hue(int what)

saturation

public final float saturation(int what)

brightness

public final float brightness(int what)

lerpColor

public int lerpColor(int c1,
                     int c2,
                     float amt)
Interpolate between two colors, using the current color mode.


lerpColor

public static int lerpColor(int c1,
                            int c2,
                            float amt,
                            int mode)
Interpolate between two colors. Like lerp(), but for the individual color components of a color supplied as an int value.


beginRaw

public void beginRaw(PGraphics rawGraphics)
Record individual lines and triangles by echoing them to another renderer.


endRaw

public void endRaw()

showWarning

public static void showWarning(java.lang.String msg)
Show a renderer error, and keep track of it so that it's only shown once.

Parameters:
msg - the error message (which will be stored for later comparison)

showException

public static void showException(java.lang.String msg)
Show an renderer-related exception that halts the program. Currently just wraps the message as a RuntimeException and throws it, but might do something more specific might be used in the future.


displayable

public boolean displayable()
Return true if this renderer should be drawn to the screen. Defaults to returning true, since nearly all renderers are on-screen beasts. But can be overridden for subclasses like PDF so that a window doesn't open up.

A better name? showFrame, displayable, isVisible, visible, shouldDisplay, what to call this?


is2D

public boolean is2D()
Return true if this renderer supports 2D drawing. Defaults to true.


is3D

public boolean is3D()
Return true if this renderer supports 2D drawing. Defaults to true.