processing.core
Class PGraphics2D

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

public class PGraphics2D
extends PGraphics

Subclass of PGraphics that handles fast 2D rendering, more commonly referred to as P2D. This class uses no Java2D and will run with Java 1.1.


Field Summary
 
Fields inherited from class processing.core.PGraphics
A, AB, AG, ambientB, ambientG, ambientR, AR, AUTO_NORMAL, B, backgroundColor, BEEN_LIT, bezierDetail, camera, cameraAspect, cameraFar, cameraFOV, cameraInv, cameraNear, cameraX, cameraY, cameraZ, colorMode, colorModeA, colorModeX, colorModeY, colorModeZ, currentLightFalloffConstant, currentLightFalloffLinear, currentLightFalloffQuadratic, currentLightSpecular, curveTightness, DA, DB, DG, DR, EB, EG, ellipseMode, emissiveB, emissiveG, emissiveR, ER, fill, fillColor, G, height1, image, INDEX, lightCount, lightDiffuse, lightFalloffConstant, lightFalloffLinear, lightFalloffQuadratic, lightNormal, lightPosition, lightSpecular, lightSpotAngle, lightSpotAngleCos, lightSpotConcentration, lightType, LINE_FIELD_COUNT, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33, MANUAL_SHAPE_NORMAL, MANUAL_VERTEX_NORMAL, MAX_LIGHTS, modelview, modelviewInv, MX, MY, MZ, normalCount, normalMode, normalX, normalY, normalZ, NX, NY, NZ, pixelCount, projection, R, raw, rectMode, SA, SB, settingsInited, SG, SHINE, shininess, SPA, SPB, specularA, specularB, specularG, specularR, SPG, sphereDetailU, sphereDetailV, SPR, SR, stencil, stroke, STROKE_MODE, STROKE_WEIGHT, strokeCap, strokeColor, strokeJoin, strokeWeight, SW, textAlign, textAlignY, textFont, textFontNative, textFontNativeMetrics, textLeading, textMode, textSize, TEXTURE_INDEX, textureImage, textureMode, textureU, textureV, textX, textY, textZ, tint, tintColor, TRI_DIFFUSE_A, TRI_DIFFUSE_B, TRI_DIFFUSE_G, TRI_DIFFUSE_R, TRI_SPECULAR_A, TRI_SPECULAR_B, TRI_SPECULAR_G, TRI_SPECULAR_R, TRIANGLE_COLOR_COUNT, TRIANGLE_FIELD_COUNT, U, V, VERTEX1, VERTEX2, VERTEX3, VW, VX, VY, VZ, width1, X, Y, Z, zbuffer
 
Fields inherited from class processing.core.PImage
cache, format, height, imageMode, modified, mx1, mx2, my1, my2, parent, pixels, smooth, width
 
Fields inherited from interface processing.core.PConstants
ADD, ALPHA, ALPHA_MASK, ALT, AMBIENT, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BURN, CENTER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_DEPTH_TEST, DISABLE_ERROR_REPORT, DISABLE_FLYING_POO, DODGE, DOWN, DXF, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENTER, EPSILON, ERODE, ESC, EXCLUSION, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINES, LINUX, MACOS9, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMALIZED, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PDF, PERSPECTIVE, PI, PIXEL_CENTER, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD_STRIP, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, WAIT, WHITESPACE, WINDOWS
 
Constructor Summary
PGraphics2D(int iwidth, int iheight, PApplet applet)
           
 
Method Summary
static int _blend(int p1, int p2, int a2)
           
 void beginDraw()
          Prepares the PGraphics for drawing.
 void beginShape(int kind)
          Start a new shape.
 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 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 ellipseImpl(float x1, float y1, float w, float h)
           
 void endDraw()
          This will finalize rendering so that it can be shown on-screen.
 void endShape(int mode)
           
 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.PGraphics
alpha, ambient, ambient, ambient, ambientLight, ambientLight, applyMatrix, applyMatrix, arc, background, background, background, background, background, background, background, beginCamera, beginRaw, beginShape, bezier, bezierDetail, bezierPoint, bezierTangent, bezierVertex, bezierVertex, blue, box, box, breakShape, brightness, camera, camera, canDraw, color, color, color, color, color, color, color, color, color, colorMode, colorMode, colorMode, colorMode, curve, curveDetail, curvePoint, curveTangent, curveTightness, curveVertex, curveVertex, directionalLight, displayable, dispose, ellipse, ellipseMode, emissive, emissive, emissive, endCamera, endRaw, endShape, fill, fill, fill, fill, fill, fill, frustum, green, hint, hue, image, image, image, lerpColor, lerpColor, lightFalloff, lights, lightSpecular, line, line, loadMatrix, mask, mask, modelX, modelY, modelZ, noFill, noLights, normal, noStroke, noTint, ortho, ortho, perspective, perspective, point, point, pointLight, popMatrix, printCamera, printMatrix, printProjection, pushMatrix, quad, rect, rectMode, red, resetMatrix, resize, rotate, rotate, rotateX, rotateY, rotateZ, saturation, scale, scale, scale, screenX, screenX, screenY, screenY, screenZ, setMainDrawingSurface, shininess, specular, specular, specular, specular, specular, sphere, sphereDetail, sphereDetail, spotLight, stroke, stroke, stroke, stroke, stroke, stroke, strokeCap, strokeJoin, strokeWeight, text, text, text, text, text, text, text, text, text, text, text, text, textAlign, textAlign, textAscent, textDescent, textFont, textFont, textLeading, textMode, textSize, texture, textureMode, textWidth, textWidth, tint, tint, tint, tint, tint, tint, translate, translate, triangle, unhint
 
Methods inherited from class processing.core.PImage
blend, blend, blendColor, clone, copy, copy, filter, filter, get, get, get, imageMode, init, loadPixels, noSmooth, save, set, set, smooth, updatePixels, updatePixels
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PGraphics2D

public PGraphics2D(int iwidth,
                   int iheight,
                   PApplet applet)
Method Detail

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.

Specified by:
beginDraw in class PGraphics

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.

Specified by:
endDraw in class PGraphics

beginShape

public void beginShape(int kind)
Description copied from class: PGraphics
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.

Specified by:
beginShape in class PGraphics

vertex

public void vertex(float x,
                   float y)
Specified by:
vertex in class PGraphics

vertex

public void vertex(float x,
                   float y,
                   float u,
                   float v)
Specified by:
vertex in class PGraphics

vertex

public void vertex(float x,
                   float y,
                   float z)
Specified by:
vertex in class PGraphics

vertex

public void vertex(float x,
                   float y,
                   float z,
                   float u,
                   float v)
Specified by:
vertex in class PGraphics

endShape

public void endShape(int mode)
Specified by:
endShape in class PGraphics

ellipseImpl

public void ellipseImpl(float x1,
                        float y1,
                        float w,
                        float h)

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)
Overrides:
bezier in class PGraphics

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)
Overrides:
curve in class PGraphics

_blend

public static final int _blend(int p1,
                               int p2,
                               int a2)