- java.lang.Object
-
- processing.core.PImage
-
- processing.core.PGraphics
-
- All Implemented Interfaces:
Cloneable,PConstants
- Direct Known Subclasses:
PGraphicsOpenGL
public class PGraphics extends PImage implements PConstants
( begin auto-generated from PGraphics.xml ) Main graphics and rendering context, as well as the base API implementation for processing "core". Use this class if you need to draw into an off-screen graphics buffer. A PGraphics object can be constructed with the createGraphics() function. The beginDraw() and endDraw() methods (see above example) are necessary to set up the buffer and to finalize it. The fields and methods for this class are extensive. For a complete list, visit the developer's reference. ( end auto-generated )Advanced
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.- setParent(PApplet) - is called to specify the parent PApplet.
- setPrimary(boolean) - called with true if this PGraphics will be the primary drawing surface used by the sketch, or false if not.
- setPath(String) - called when the renderer needs a filename or output path, such as with the PDF or DXF renderers.
- setSize(int, int) - this is called last, at which point it's safe for the renderer to complete its initialization routine.
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. We're working right now on synchronizing the two references, so the website reference is generated from the javadoc comments. Yay.- See Also:
PApplet.createGraphics(int, int, String)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPGraphics.AsyncImageSaver
-
Field Summary
Fields Modifier and Type Field Description static intAstatic intABstatic intAGfloatambientBintambientColorfloatambientGfloatambientRstatic intARprotected static PGraphics.AsyncImageSaverasyncImageSaverprotected booleanautoNormalstatic intBprotected floatbackgroundAprotected intbackgroundAiprotected booleanbackgroundAlphaprotected floatbackgroundBprotected intbackgroundBiintbackgroundColorLast background color that was set, zero if an imageprotected floatbackgroundGprotected intbackgroundGiprotected floatbackgroundRprotected intbackgroundRistatic intBEEN_LITprotected PMatrix3DbezierBasisInverseprotected PMatrix3DbezierBasisMatrixintbezierDetailprotected PMatrix3DbezierDrawMatrixprotected booleanbezierInitedprotected intblendModeThe current blending mode.protected WeakHashMap<PImage,Object>cacheMapStorage for renderer-specific image data.protected floatcalcAprotected intcalcAiprotected booleancalcAlphaprotected floatcalcBprotected intcalcBiprotected intcalcColorprotected floatcalcGprotected intcalcGiprotected floatcalcRprotected intcalcRiintcolorModeThe current colorModefloatcolorModeAMax value for alpha set by colorModefloatcolorModeXMax value for red (or hue) set by colorModefloatcolorModeYMax value for green (or saturation) set by colorModefloatcolorModeZMax value for blue (or value) set by colorModeprotected static float[]cosLUTprotected PMatrix3DcurveBasisMatrixintcurveDetailprotected PMatrix3DcurveDrawMatrixprotected booleancurveInitedfloatcurveTightnessprotected PMatrix3DcurveToBezierMatrixprotected intcurveVertexCountprotected float[][]curveVerticesstatic intDAstatic intDBprotected static intDEFAULT_STROKE_CAPprotected static intDEFAULT_STROKE_JOINprotected static floatDEFAULT_STROKE_WEIGHTstatic intDEFAULT_VERTICESstatic intDGstatic intDRstatic intEBbooleanedgestatic intEDGEstatic intEGintellipseModeThe current ellipse mode (read-only)floatemissiveBintemissiveColorfloatemissiveGfloatemissiveRstatic intERprotected static StringERROR_BACKGROUND_IMAGE_FORMATprotected static StringERROR_BACKGROUND_IMAGE_SIZEprotected static StringERROR_PUSHMATRIX_OVERFLOWprotected static StringERROR_PUSHMATRIX_UNDERFLOWprotected static StringERROR_TEXTFONT_NULL_PFONTbooleanfilltrue if fill() is enabled, (read-only)protected floatfillAprotected intfillAiprotected booleanfillAlphaprotected floatfillBprotected intfillBiintfillColorfill that was last set (read-only)protected floatfillGprotected intfillGiprotected floatfillRprotected intfillRistatic intGstatic intHAS_NORMALprotected boolean[]hintsArray of hint[] items.ImageimageJava AWT Image object associated with this renderer.intimageModeThe current image alignment (read-only)protected static intMATRIX_STACK_DEPTHCurrent model-view matrix transformation of the form m[row][column], which is a "column vector" (as opposed to "row vector") matrix.protected static intNORMAL_MODE_AUTOprotected static intNORMAL_MODE_SHAPEprotected static intNORMAL_MODE_VERTEXprotected intnormalModefloatnormalXCurrent normal vector.floatnormalYCurrent normal vector.floatnormalZCurrent normal vector.static intNXstatic intNYstatic intNZprotected Stringpathpath to the file being saved for this renderer (if any)intpixelCountprotected booleanprimaryGraphicsTrue if this is the main graphics context for a sketch.static intRprotected PGraphicsrawprotected booleanreapplySettingsintrectModeThe current rect mode (read-only)static intSAstatic intSBbooleansetAmbientprotected booleansettingsInitedstatic intSGprotected intshapeType of shape passed to beginShape(), zero if no shape is currently being drawn.intshapeModeThe current shape alignment mode (read-only)static intSHINEfloatshininessprotected static intSINCOS_LENGTHprotected static floatSINCOS_PRECISIONprotected static float[]sinLUTintsmoothstatic intSPBfloatspecularBintspecularColorfloatspecularGfloatspecularRstatic intSPGintsphereDetailUintsphereDetailVprotected float[]sphereXprotected float[]sphereYprotected float[]sphereZstatic intSPRstatic intSRstroke argb valuesbooleanstroketrue if stroke() is enabled, (read-only)protected floatstrokeAprotected intstrokeAiprotected booleanstrokeAlphaprotected floatstrokeBprotected intstrokeBiintstrokeCapSet by strokeCap() (read-only).intstrokeColorstroke that was last set (read-only)protected floatstrokeGprotected intstrokeGiintstrokeJoinSet by strokeJoin() (read-only).protected floatstrokeRprotected intstrokeRifloatstrokeWeightLast value set by strokeWeight() (read-only).protected PSurfacesurfaceSurface object that we're talking tostatic intSWstroke weightinttextAlignThe current text align (read-only)inttextAlignYThe current vertical text alignment (read-only)protected inttextBreakCountprotected int[]textBreakStartprotected int[]textBreakStopprotected char[]textBufferInternal buffer used by the text() functions because the String object is slowPFonttextFontThe current text font (read-only)floattextLeadingThe current text leading (read-only)inttextModeThe current text mode (read-only)floattextSizeThe current text size (read-only)PImagetextureImageCurrent image being used as a textureinttextureModeSets whether texture coordinates passed to vertex() calls will be based on coordinates that are based on the IMAGE or NORMALIZED.floattextureUCurrent horizontal coordinate for texture, will always be between 0 and 1, even if using textureMode(IMAGE).floattextureVCurrent vertical coordinate for texture, see above.protected char[]textWidthBufferbooleantintTrue if tint() is enabled (read-only).protected floattintAprotected inttintAiprotected booleantintAlphaprotected floattintBprotected inttintBiinttintColortint that was last set (read-only)protected floattintGprotected inttintGiprotected floattintRprotected inttintRistatic intTXstatic intTYstatic intTZstatic intUstatic intVstatic intVERTEX_FIELD_COUNTprotected intvertexCountprotected float[][]verticesstatic intVWstatic intVXstatic intVYstatic intVZprotected static Map<String,Object>warnings-
Fields inherited from class processing.core.PImage
ALPHA_MASK, BLUE_MASK, format, GREEN_MASK, height, loaded, modified, mx1, mx2, my1, my2, parent, pixelDensity, pixelHeight, pixels, pixelWidth, RED_MASK, saveImageFormats, width
-
Fields inherited from interface processing.core.PConstants
ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ASYNC_SAVEFRAME, DISABLE_BUFFER_READING, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_KEY_REPEAT, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ASYNC_SAVEFRAME, ENABLE_BUFFER_READING, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_KEY_REPEAT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, FX2D, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPAN, SPHERE, SPOT, SQUARE, SUBTRACT, SVG, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z
-
-
Constructor Summary
Constructors Constructor Description PGraphics()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description floatalpha(int rgb)( begin auto-generated from alpha.xml ) Extracts the alpha value from a color.voidambient(float gray)voidambient(float v1, float v2, float v3)voidambient(int rgb)( begin auto-generated from ambient.xml ) Sets the ambient reflectance for shapes drawn to the screen.protected voidambientFromCalc()voidambientLight(float v1, float v2, float v3)( begin auto-generated from ambientLight.xml ) Adds an ambient light.voidambientLight(float v1, float v2, float v3, float x, float y, float z)voidapplyMatrix(float n00, float n01, float n02, float n10, float n11, float n12)voidapplyMatrix(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)voidapplyMatrix(PMatrix source)( begin auto-generated from applyMatrix.xml ) Multiplies the current matrix by the one specified through the parameters.voidapplyMatrix(PMatrix2D source)voidapplyMatrix(PMatrix3D source)voidarc(float a, float b, float c, float d, float start, float stop)( begin auto-generated from arc.xml ) Draws an arc in the display window.voidarc(float a, float b, float c, float d, float start, float stop, int mode)protected voidarcImpl(float x, float y, float w, float h, float start, float stop, int mode)Start and stop are in radians, converted by the parent function.voidattrib(String name, boolean... values)voidattrib(String name, float... values)voidattrib(String name, int... values)voidattribColor(String name, int color)voidattribNormal(String name, float nx, float ny, float nz)voidattribPosition(String name, float x, float y, float z)protected voidawaitAsyncSaveCompletion(String filename)If there is running async save task for this file, blocks until it completes.voidbackground(float gray)voidbackground(float gray, float alpha)voidbackground(float v1, float v2, float v3)voidbackground(float v1, float v2, float v3, float alpha)voidbackground(int rgb)( begin auto-generated from background.xml ) The background() function sets the color used for the background of the Processing window.voidbackground(int rgb, float alpha)voidbackground(PImage image)Takes an RGB or ARGB image and sets it as the background.protected voidbackgroundFromCalc()protected voidbackgroundImpl()Actual implementation of clearing the background, now that the internal variables for background color have been set.protected voidbackgroundImpl(PImage image)Actually set the background image.voidbeginCamera()( begin auto-generated from beginCamera.xml ) The beginCamera() and endCamera() functions enable advanced customization of the camera space.voidbeginContour()voidbeginDraw()( begin auto-generated from PGraphics_beginDraw.xml ) Sets the default properties for a PGraphics object.PGLbeginPGL()voidbeginRaw(PGraphics rawGraphics)Record individual lines and triangles by echoing them to another renderer.voidbeginShape()Start a new shape of type POLYGONvoidbeginShape(int kind)( begin auto-generated from beginShape.xml ) Using the beginShape() and endShape() functions allow creating more complex forms.voidbezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)voidbezier(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)( begin auto-generated from bezier.xml ) Draws a Bezier curve on the screen.voidbezierDetail(int detail)( begin auto-generated from bezierDetail.xml ) Sets the resolution at which Beziers display.protected voidbezierInit()protected voidbezierInitCheck()floatbezierPoint(float a, float b, float c, float d, float t)( begin auto-generated from bezierPoint.xml ) Evaluates the Bezier at point t for points a, b, c, d.floatbezierTangent(float a, float b, float c, float d, float t)( begin auto-generated from bezierTangent.xml ) Calculates the tangent of a point on a Bezier curve.voidbezierVertex(float x2, float y2, float x3, float y3, float x4, float y4)voidbezierVertex(float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)( begin auto-generated from bezierVertex.xml ) Specifies vertex coordinates for Bezier curves.protected voidbezierVertexCheck()protected voidbezierVertexCheck(int shape, int vertexCount)voidblendMode(int mode)( begin auto-generated from blendMode.xml ) This is a new reference entry for Processing 2.0.protected voidblendModeImpl()floatblue(int rgb)( begin auto-generated from blue.xml ) Extracts the blue value from a color, scaled to match current colorMode().voidbox(float size)( begin auto-generated from box.xml ) A box is an extruded rectangle.voidbox(float w, float h, float d)floatbrightness(int rgb)( begin auto-generated from brightness.xml ) Extracts the brightness value from a color.voidcamera()( begin auto-generated from camera.xml ) Sets the position of the camera through setting the eye position, the center of the scene, and which axis is facing upward.voidcamera(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)protected voidcheckSettings()voidcircle(float x, float y, float extent)( begin auto-generated from circle.xml ) Draws a circle to the screen.voidclear()voidclip(float a, float b, float c, float d)( begin auto-generated from clip.xml ) Limits the rendering to the boundaries of a rectangle defined by the parameters.protected voidclipImpl(float x1, float y1, float x2, float y2)intcolor(float gray)intcolor(float gray, float alpha)intcolor(float v1, float v2, float v3)intcolor(float v1, float v2, float v3, float a)intcolor(int c)intcolor(int c, float alpha)intcolor(int c, int alpha)intcolor(int v1, int v2, int v3)intcolor(int v1, int v2, int v3, int a)protected voidcolorCalc(float gray)protected voidcolorCalc(float gray, float alpha)protected voidcolorCalc(float x, float y, float z)protected voidcolorCalc(float x, float y, float z, float a)protected voidcolorCalc(int rgb)Set the fill to either a grayscale value or an ARGB int.protected voidcolorCalc(int rgb, float alpha)protected voidcolorCalcARGB(int argb, float alpha)Unpacks AARRGGBB color for direct use with colorCalc.voidcolorMode(int mode)( begin auto-generated from colorMode.xml ) Changes the way Processing interprets color data.voidcolorMode(int mode, float max)voidcolorMode(int mode, float max1, float max2, float max3)voidcolorMode(int mode, float max1, float max2, float max3, float maxA)protected PFontcreateDefaultFont(float size)Used by PGraphics to remove the requirement for loading a font.protected PFontcreateFont(String name, float size, boolean smooth, char[] charset)PShapecreateShape()PShapecreateShape(int type)PShapecreateShape(int kind, float... p)protected PShapecreateShapeFamily(int type)Override this method to return an appropriate shape for your rendererprotected PShapecreateShapePrimitive(int kind, float... p)Override this to have a custom shape object used by your renderer.PSurfacecreateSurface()voidcurve(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)( begin auto-generated from curve.xml ) Draws a curved line on the screen.voidcurve(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)voidcurveDetail(int detail)( begin auto-generated from curveDetail.xml ) Sets the resolution at which curves display.protected voidcurveInit()Set the number of segments to use when drawing a Catmull-Rom curve, and setting the s parameter, which defines how tightly the curve fits to each vertex.protected voidcurveInitCheck()floatcurvePoint(float a, float b, float c, float d, float t)( begin auto-generated from curvePoint.xml ) Evalutes the curve at point t for points a, b, c, d.floatcurveTangent(float a, float b, float c, float d, float t)( begin auto-generated from curveTangent.xml ) Calculates the tangent of a point on a curve.voidcurveTightness(float tightness)( begin auto-generated from curveTightness.xml ) Modifies the quality of forms created with curve() and curveVertex().voidcurveVertex(float x, float y)( begin auto-generated from curveVertex.xml ) Specifies vertex coordinates for curves.voidcurveVertex(float x, float y, float z)protected voidcurveVertexCheck()protected voidcurveVertexCheck(int shape)Perform initialization specific to curveVertex(), and handle standard error modes.protected voidcurveVertexSegment(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)Handle emitting a specific segment of Catmull-Rom curve.protected voidcurveVertexSegment(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)Handle emitting a specific segment of Catmull-Rom curve.protected voiddefaultFontOrDeath(String method)Same as below, but defaults to a 12 point font, just as MacWrite intended.protected voiddefaultFontOrDeath(String method, float size)First try to create a default font, but if that's not possible, throw an exception that halts the program because textFont() has not been used prior to the specified method.protected voiddefaultSettings()Set engine's default values.voiddirectionalLight(float v1, float v2, float v3, float nx, float ny, float nz)( begin auto-generated from directionalLight.xml ) Adds a directional light.booleandisplayable()Return true if this renderer should be drawn to the screen.voiddispose()Handle any takedown for this graphics context.voidedge(boolean edge)Sets whether the upcoming vertex is part of an edge.voidellipse(float a, float b, float c, float d)( begin auto-generated from ellipse.xml ) Draws an ellipse (oval) in the display window.protected voidellipseImpl(float x, float y, float w, float h)voidellipseMode(int mode)( begin auto-generated from ellipseMode.xml ) The origin of the ellipse is modified by the ellipseMode() function.voidemissive(float gray)gray number specifying value between white and blackvoidemissive(float v1, float v2, float v3)voidemissive(int rgb)( begin auto-generated from emissive.xml ) Sets the emissive color of the material used for drawing shapes drawn to the screen.protected voidemissiveFromCalc()voidendCamera()( begin auto-generated from endCamera.xml ) The beginCamera() and endCamera() functions enable advanced customization of the camera space.voidendContour()voidendDraw()( begin auto-generated from PGraphics_endDraw.xml ) Finalizes the rendering of a PGraphics object so that it can be shown on screen.voidendPGL()voidendRaw()voidendShape()voidendShape(int mode)( begin auto-generated from endShape.xml ) The endShape() function is the companion to beginShape() and may only be called after beginShape().voidfill(float gray)voidfill(float gray, float alpha)voidfill(float v1, float v2, float v3)voidfill(float v1, float v2, float v3, float alpha)voidfill(int rgb)( begin auto-generated from fill.xml ) Sets the color used to fill shapes.voidfill(int rgb, float alpha)protected voidfillFromCalc()voidfilter(PShader shader)voidflush()voidfrustum(float left, float right, float bottom, float top, float near, float far)( begin auto-generated from frustum.xml ) Sets a perspective matrix defined through the parameters.ObjectgetCache(PImage image)Get cache storage data for the specified renderer.PMatrixgetMatrix()PMatrix2DgetMatrix(PMatrix2D target)Copy the current transformation matrix into the specified target.PMatrix3DgetMatrix(PMatrix3D target)Copy the current transformation matrix into the specified target.PGraphicsgetRaw()PStylegetStyle()PStylegetStyle(PStyle s)floatgreen(int rgb)( begin auto-generated from green.xml ) Extracts the green value from a color, scaled to match current colorMode().protected voidhandleTextSize(float size)Sets the actual size.booleanhaveRaw()voidhint(int which)( begin auto-generated from hint.xml ) Set various hints and hacks for the renderer.floathue(int rgb)( begin auto-generated from hue.xml ) Extracts the hue value from a color.voidimage(PImage img, float a, float b)( begin auto-generated from image.xml ) Displays images to the screen.voidimage(PImage img, float a, float b, float c, float d)voidimage(PImage img, float a, float b, float c, float d, int u1, int v1, int u2, int v2)Draw an image(), also specifying u/v coordinates.protected voidimageImpl(PImage img, float x1, float y1, float x2, float y2, int u1, int v1, int u2, int v2)Expects x1, y1, x2, y2 coordinates where (x2 >= x1) and (y2 >= y1).voidimageMode(int mode)( begin auto-generated from imageMode.xml ) Modifies the location from which images draw.booleanis2D()Return true if this renderer supports 2D drawing.booleanis2X()booleanis3D()Return true if this renderer supports 3D drawing.booleanisGL()Return true if this renderer does rendering through OpenGL.intlerpColor(int c1, int c2, float amt)( begin auto-generated from lerpColor.xml ) Calculates a color or colors between two color at a specific increment.static intlerpColor(int c1, int c2, float amt, int mode)voidlightFalloff(float constant, float linear, float quadratic)( begin auto-generated from lightFalloff.xml ) Sets the falloff rates for point lights, spot lights, and ambient lights.voidlights()( begin auto-generated from lights.xml ) Sets the default ambient light, directional light, falloff, and specular values.voidlightSpecular(float v1, float v2, float v3)( begin auto-generated from lightSpecular.xml ) Sets the specular color for lights.voidline(float x1, float y1, float x2, float y2)( begin auto-generated from line.xml ) Draws a line (a direct path between two points) to the screen.voidline(float x1, float y1, float z1, float x2, float y2, float z2)PShaderloadShader(String fragFilename)( begin auto-generated from loadShader.xml ) This is a new reference entry for Processing 2.0.PShaderloadShader(String fragFilename, String vertFilename)PShapeloadShape(String filename)PShapeloadShape(String filename, String options)floatmodelX(float x, float y, float z)( begin auto-generated from modelX.xml ) Returns the three-dimensional X, Y, Z position in model space.floatmodelY(float x, float y, float z)( begin auto-generated from modelY.xml ) Returns the three-dimensional X, Y, Z position in model space.floatmodelZ(float x, float y, float z)( begin auto-generated from modelZ.xml ) Returns the three-dimensional X, Y, Z position in model space.voidnoClip()( begin auto-generated from noClip.xml ) Disables the clipping previously started by the clip() function.voidnoFill()( begin auto-generated from noFill.xml ) Disables filling geometry.voidnoLights()( begin auto-generated from noLights.xml ) Disable all lighting.voidnormal(float nx, float ny, float nz)( begin auto-generated from normal.xml ) Sets the current normal vector.voidnoSmooth()voidnoStroke()( begin auto-generated from noStroke.xml ) Disables drawing the stroke (outline).voidnoTexture()Removes texture image for current shape.voidnoTint()( begin auto-generated from noTint.xml ) Removes the current fill value for displaying images and reverts to displaying images with their original hues.voidortho()( begin auto-generated from ortho.xml ) Sets an orthographic projection and defines a parallel clipping volume.voidortho(float left, float right, float bottom, float top)voidortho(float left, float right, float bottom, float top, float near, float far)voidperspective()( begin auto-generated from perspective.xml ) Sets a perspective projection applying foreshortening, making distant objects appear smaller than closer ones.voidperspective(float fovy, float aspect, float zNear, float zFar)voidpoint(float x, float y)( begin auto-generated from point.xml ) Draws a point, a coordinate in space at the dimension of one pixel.voidpoint(float x, float y, float z)voidpointLight(float v1, float v2, float v3, float x, float y, float z)( begin auto-generated from pointLight.xml ) Adds a point light.voidpop()( begin auto-generated from pop.xml ) The pop() function restores the previous drawing style settings and transformations after push() has changed them.voidpopMatrix()( begin auto-generated from popMatrix.xml ) Pops the current transformation matrix off the matrix stack.voidpopStyle()( begin auto-generated from popStyle.xml ) The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these functions are always used together.voidprintCamera()( begin auto-generated from printCamera.xml ) Prints the current camera matrix to the Console (the text window at the bottom of Processing).voidprintMatrix()( begin auto-generated from printMatrix.xml ) Prints the current matrix to the Console (the text window at the bottom of Processing).voidprintProjection()( begin auto-generated from printProjection.xml ) Prints the current projection matrix to the Console (the text window at the bottom of Processing).protected voidprocessImageBeforeAsyncSave(PImage image)voidpush()( begin auto-generated from push.xml ) The push() function saves the current drawing style settings and transformations, while pop() restores these settings.voidpushMatrix()( begin auto-generated from pushMatrix.xml ) Pushes the current transformation matrix onto the matrix stack.voidpushStyle()( begin auto-generated from pushStyle.xml ) The pushStyle() function saves the current style settings and popStyle() restores the prior settings.voidquad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)( begin auto-generated from quad.xml ) A quad is a quadrilateral, a four sided polygon.voidquadraticVertex(float cx, float cy, float x3, float y3)voidquadraticVertex(float cx, float cy, float cz, float x3, float y3, float z3)protected voidreapplySettings()Re-apply current settings.voidrect(float a, float b, float c, float d)( begin auto-generated from rect.xml ) Draws a rectangle to the screen.voidrect(float a, float b, float c, float d, float r)voidrect(float a, float b, float c, float d, float tl, float tr, float br, float bl)protected voidrectImpl(float x1, float y1, float x2, float y2)protected voidrectImpl(float x1, float y1, float x2, float y2, float tl, float tr, float br, float bl)voidrectMode(int mode)( begin auto-generated from rectMode.xml ) Modifies the location from which rectangles draw.floatred(int rgb)( begin auto-generated from red.xml ) Extracts the red value from a color, scaled to match current colorMode().voidremoveCache(PImage image)Remove information associated with this renderer from the cache, if any.voidresetMatrix()( begin auto-generated from resetMatrix.xml ) Replaces the current matrix with the identity matrix.voidresetShader()( begin auto-generated from resetShader.xml ) This is a new reference entry for Processing 2.0.voidresetShader(int kind)voidrotate(float angle)( begin auto-generated from rotate.xml ) Rotates a shape the amount specified by the angle parameter.voidrotate(float angle, float x, float y, float z)AdvancedvoidrotateX(float angle)( begin auto-generated from rotateX.xml ) Rotates a shape around the x-axis the amount specified by the angle parameter.voidrotateY(float angle)( begin auto-generated from rotateY.xml ) Rotates a shape around the y-axis the amount specified by the angle parameter.voidrotateZ(float angle)( begin auto-generated from rotateZ.xml ) Rotates a shape around the z-axis the amount specified by the angle parameter.floatsaturation(int rgb)( begin auto-generated from saturation.xml ) Extracts the saturation value from a color.booleansave(String filename)( begin auto-generated from PImage_save.xml ) Saves the image into a file.voidscale(float s)( begin auto-generated from scale.xml ) Increases or decreases the size of a shape by expanding and contracting vertices.voidscale(float x, float y)Advancedvoidscale(float x, float y, float z)floatscreenX(float x, float y)( begin auto-generated from screenX.xml ) Takes a three-dimensional X, Y, Z position and returns the X value for where it will appear on a (two-dimensional) screen.floatscreenX(float x, float y, float z)floatscreenY(float x, float y)( begin auto-generated from screenY.xml ) Takes a three-dimensional X, Y, Z position and returns the Y value for where it will appear on a (two-dimensional) screen.floatscreenY(float x, float y, float z)floatscreenZ(float x, float y, float z)( begin auto-generated from screenZ.xml ) Takes a three-dimensional X, Y, Z position and returns the Z value for where it will appear on a (two-dimensional) screen.voidsetCache(PImage image, Object storage)Store data of some kind for the renderer that requires extra metadata of some kind.voidsetMatrix(PMatrix source)Set the current transformation matrix to the contents of another.voidsetMatrix(PMatrix2D source)Set the current transformation to the contents of the specified source.voidsetMatrix(PMatrix3D source)Set the current transformation to the contents of the specified source.voidsetParent(PApplet parent)voidsetPath(String path)voidsetPrimary(boolean primary)Set (or unset) this as the main drawing surface.voidsetSize(int w, int h)The final step in setting up a renderer, set its size of this renderer.voidshader(PShader shader)( begin auto-generated from shader.xml ) This is a new reference entry for Processing 2.0.voidshader(PShader shader, int kind)voidshape(PShape shape)voidshape(PShape shape, float x, float y)( begin auto-generated from shape.xml ) Displays shapes to the screen.protected voidshape(PShape shape, float x, float y, float z)voidshape(PShape shape, float a, float b, float c, float d)protected voidshape(PShape shape, float x, float y, float z, float c, float d, float e)voidshapeMode(int mode)( begin auto-generated from shapeMode.xml ) Modifies the location from which shapes draw.voidshearX(float angle)( begin auto-generated from shearX.xml ) Shears a shape around the x-axis the amount specified by the angle parameter.voidshearY(float angle)( begin auto-generated from shearY.xml ) Shears a shape around the y-axis the amount specified by the angle parameter.voidshininess(float shine)( begin auto-generated from shininess.xml ) Sets the amount of gloss in the surface of shapes.static voidshowDepthWarning(String method)Display a warning that the specified method is only available with 3D.static voidshowDepthWarningXYZ(String method)Display a warning that the specified method that takes x, y, z parameters can only be used with x and y parameters in this renderer.static voidshowException(String msg)Show an renderer-related exception that halts the program.static voidshowMethodWarning(String method)Display a warning that the specified method is simply unavailable.static voidshowMissingWarning(String method)Display a warning that the specified method is not implemented, meaning that it could be either a completely missing function, although other variations of it may still work properly.static voidshowVariationWarning(String str)Error that a particular variation of a method is unavailable (even though other variations are).static voidshowWarning(String msg)Show a renderer error, and keep track of it so that it's only shown once.static voidshowWarning(String msg, Object... args)Version of showWarning() that takes a parsed String.voidsmooth()voidsmooth(int quality)voidspecular(float gray)gray number specifying value between white and blackvoidspecular(float v1, float v2, float v3)voidspecular(int rgb)( begin auto-generated from specular.xml ) Sets the specular color of the materials used for shapes drawn to the screen, which sets the color of hightlights.protected voidspecularFromCalc()voidsphere(float r)( begin auto-generated from sphere.xml ) A sphere is a hollow ball made from tessellated triangles.voidsphereDetail(int res)( begin auto-generated from sphereDetail.xml ) Controls the detail used to render a sphere by adjusting the number of vertices of the sphere mesh.voidsphereDetail(int ures, int vres)protected voidsplineForward(int segments, PMatrix3D matrix)Setup forward-differencing matrix to be used for speedy curve rendering.voidspotLight(float v1, float v2, float v3, float x, float y, float z, float nx, float ny, float nz, float angle, float concentration)( begin auto-generated from spotLight.xml ) Adds a spot light.voidsquare(float x, float y, float extent)( begin auto-generated from square.xml ) Draws a square to the screen.voidstroke(float gray)voidstroke(float gray, float alpha)voidstroke(float v1, float v2, float v3)voidstroke(float v1, float v2, float v3, float alpha)voidstroke(int rgb)( begin auto-generated from stroke.xml ) Sets the color used to draw lines and borders around shapes.voidstroke(int rgb, float alpha)voidstrokeCap(int cap)( begin auto-generated from strokeCap.xml ) Sets the style for rendering line endings.protected voidstrokeFromCalc()voidstrokeJoin(int join)( begin auto-generated from strokeJoin.xml ) Sets the style of the joints which connect line segments.voidstrokeWeight(float weight)( begin auto-generated from strokeWeight.xml ) Sets the width of the stroke used for lines, points, and the border around shapes.voidstyle(PStyle s)voidtext(char[] chars, int start, int stop, float x, float y)Advancedvoidtext(char[] chars, int start, int stop, float x, float y, float z)voidtext(char c, float x, float y)( begin auto-generated from text.xml ) Draws text to the screen.voidtext(char c, float x, float y, float z)voidtext(float num, float x, float y)This does a basic number formatting, to avoid the generally ugly appearance of printing floats.voidtext(float num, float x, float y, float z)voidtext(int num, float x, float y)voidtext(int num, float x, float y, float z)voidtext(String str, float x, float y)Advancedvoidtext(String str, float x, float y, float z)Same as above but with a z coordinate.voidtext(String str, float x1, float y1, float x2, float y2)AdvancedvoidtextAlign(int alignX)voidtextAlign(int alignX, int alignY)( begin auto-generated from textAlign.xml ) Sets the current alignment for drawing text.floattextAscent()( begin auto-generated from textAscent.xml ) Returns ascent of the current font at its current size.protected voidtextCharImpl(char ch, float x, float y)protected voidtextCharModelImpl(PImage glyph, float x1, float y1, float x2, float y2, int u2, int v2)floattextDescent()( begin auto-generated from textDescent.xml ) Returns descent of the current font at its current size.voidtextFont(PFont which)( begin auto-generated from textFont.xml ) Sets the current font that will be drawn with the text() function.voidtextFont(PFont which, float size)protected voidtextFontImpl(PFont which, float size)Called from textFont.voidtextLeading(float leading)( begin auto-generated from textLeading.xml ) Sets the spacing between lines of text in units of pixels.protected voidtextLineAlignImpl(char[] buffer, int start, int stop, float x, float y)Handles placement of a text line, then calls textLineImpl to actually render at the specific point.protected voidtextLineImpl(char[] buffer, int start, int stop, float x, float y)Implementation of actual drawing for a line of text.voidtextMode(int mode)( begin auto-generated from textMode.xml ) Sets the way text draws to the screen.protected booleantextModeCheck(int mode)protected booleantextSentence(char[] buffer, int start, int stop, float boxWidth, float spaceWidth)Emit a sentence of text, defined as a chunk of text without any newlines.protected voidtextSentenceBreak(int start, int stop)voidtextSize(float size)( begin auto-generated from textSize.xml ) Sets the current font size.protected voidtextSizeImpl(float size)Called from textSize() after validating size.voidtexture(PImage image)( begin auto-generated from texture.xml ) Sets a texture to be applied to vertex points.voidtextureMode(int mode)( begin auto-generated from textureMode.xml ) Sets the coordinate space for texture mapping.voidtextureWrap(int wrap)( begin auto-generated from textureWrap.xml ) Description to come...floattextWidth(char c)floattextWidth(char[] chars, int start, int length)floattextWidth(String str)( begin auto-generated from textWidth.xml ) Calculates and returns the width of any character or text string.protected floattextWidthImpl(char[] buffer, int start, int stop)Implementation of returning the text width of the chars [start, stop) in the buffer.voidtint(float gray)voidtint(float gray, float alpha)voidtint(float v1, float v2, float v3)voidtint(float v1, float v2, float v3, float alpha)voidtint(int rgb)( begin auto-generated from tint.xml ) Sets the fill value for displaying images.voidtint(int rgb, float alpha)protected voidtintFromCalc()voidtranslate(float x, float y)( begin auto-generated from translate.xml ) Specifies an amount to displace objects within the display window.voidtranslate(float x, float y, float z)voidtriangle(float x1, float y1, float x2, float y2, float x3, float y3)( begin auto-generated from triangle.xml ) A triangle is a plane created by connecting three points.voidvertex(float[] v)Used by renderer subclasses or PShape to efficiently pass in already formatted vertex information.voidvertex(float x, float y)voidvertex(float x, float y, float z)voidvertex(float x, float y, float u, float v)voidvertex(float x, float y, float z, float u, float v)( begin auto-generated from vertex.xml ) All shapes are constructed by connecting a series of vertices.protected voidvertexCheck()protected voidvertexTexture(float u, float v)Set (U, V) coords for the next vertex in the current shape.-
Methods inherited from class processing.core.PImage
blend, blend, blendColor, blurAlpha, blurARGB, blurRGB, buildBlurKernel, checkAlpha, clone, copy, copy, copy, dilate, erode, filter, filter, get, get, get, getImage, getImpl, getModifiedX1, getModifiedX2, getModifiedY1, getModifiedY2, getNative, init, init, isLoaded, isModified, loadPixels, loadTIFF, mask, mask, opaque, resize, saveImageIO, saveTGA, saveTIFF, set, set, setImpl, setLoaded, setLoaded, setModified, setModified, updatePixels, updatePixels
-
-
-
-
Field Detail
-
pixelCount
public int pixelCount
-
smooth
public int smooth
-
settingsInited
protected boolean settingsInited
-
reapplySettings
protected boolean reapplySettings
-
raw
protected PGraphics raw
-
path
protected String path
path to the file being saved for this renderer (if any)
-
primaryGraphics
protected boolean primaryGraphics
True if this is the main graphics context for a sketch. False for offscreen buffers retrieved via createGraphics().
-
hints
protected boolean[] hints
Array of hint[] items. These are hacks to get around various temporary workarounds inside the environment. Note that this array cannot be static, as a hint() may result in a runtime change specific to a renderer. For instance, calling hint(DISABLE_DEPTH_TEST) has to call glDisable() right away on an instance of PGraphicsOpenGL. The hints[] array is allocated early on because it might be used inside beginDraw(), allocate(), etc.
-
cacheMap
protected WeakHashMap<PImage,Object> cacheMap
Storage for renderer-specific image data. In 1.x, renderers wrote cache data into the image object. In 2.x, the renderer has a weak-referenced map that points at any of the images it has worked on already. When the images go out of scope, they will be properly garbage collected.
-
R
public static final int R
- See Also:
- Constant Field Values
-
G
public static final int G
- See Also:
- Constant Field Values
-
B
public static final int B
- See Also:
- Constant Field Values
-
A
public static final int A
- See Also:
- Constant Field Values
-
U
public static final int U
- See Also:
- Constant Field Values
-
V
public static final int V
- See Also:
- Constant Field Values
-
NX
public static final int NX
- See Also:
- Constant Field Values
-
NY
public static final int NY
- See Also:
- Constant Field Values
-
NZ
public static final int NZ
- See Also:
- Constant Field Values
-
EDGE
public static final int EDGE
- See Also:
- Constant Field Values
-
SR
public static final int SR
stroke argb values- See Also:
- Constant Field Values
-
SG
public static final int SG
- See Also:
- Constant Field Values
-
SB
public static final int SB
- See Also:
- Constant Field Values
-
SA
public static final int SA
- See Also:
- Constant Field Values
-
SW
public static final int SW
stroke weight- See Also:
- Constant Field Values
-
TX
public static final int TX
- See Also:
- Constant Field Values
-
TY
public static final int TY
- See Also:
- Constant Field Values
-
TZ
public static final int TZ
- See Also:
- Constant Field Values
-
VX
public static final int VX
- See Also:
- Constant Field Values
-
VY
public static final int VY
- See Also:
- Constant Field Values
-
VZ
public static final int VZ
- See Also:
- Constant Field Values
-
VW
public static final int VW
- See Also:
- Constant Field Values
-
AR
public static final int AR
- See Also:
- Constant Field Values
-
AG
public static final int AG
- See Also:
- Constant Field Values
-
AB
public static final int AB
- See Also:
- Constant Field Values
-
DR
public static final int DR
- See Also:
- Constant Field Values
-
DG
public static final int DG
- See Also:
- Constant Field Values
-
DB
public static final int DB
- See Also:
- Constant Field Values
-
DA
public static final int DA
- See Also:
- Constant Field Values
-
SPR
public static final int SPR
- See Also:
- Constant Field Values
-
SPG
public static final int SPG
- See Also:
- Constant Field Values
-
SPB
public static final int SPB
- See Also:
- Constant Field Values
-
SHINE
public static final int SHINE
- See Also:
- Constant Field Values
-
ER
public static final int ER
- See Also:
- Constant Field Values
-
EG
public static final int EG
- See Also:
- Constant Field Values
-
EB
public static final int EB
- See Also:
- Constant Field Values
-
BEEN_LIT
public static final int BEEN_LIT
- See Also:
- Constant Field Values
-
HAS_NORMAL
public static final int HAS_NORMAL
- See Also:
- Constant Field Values
-
VERTEX_FIELD_COUNT
public static final int VERTEX_FIELD_COUNT
- See Also:
- Constant Field Values
-
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)
-
tintAlpha
protected boolean tintAlpha
-
tintR
protected float tintR
-
tintG
protected float tintG
-
tintB
protected float tintB
-
tintA
protected float tintA
-
tintRi
protected int tintRi
-
tintGi
protected int tintGi
-
tintBi
protected int tintBi
-
tintAi
protected int tintAi
-
fill
public boolean fill
true if fill() is enabled, (read-only)
-
fillColor
public int fillColor
fill that was last set (read-only)
-
fillAlpha
protected boolean fillAlpha
-
fillR
protected float fillR
-
fillG
protected float fillG
-
fillB
protected float fillB
-
fillA
protected float fillA
-
fillRi
protected int fillRi
-
fillGi
protected int fillGi
-
fillBi
protected int fillBi
-
fillAi
protected int fillAi
-
stroke
public boolean stroke
true if stroke() is enabled, (read-only)
-
strokeColor
public int strokeColor
stroke that was last set (read-only)
-
strokeAlpha
protected boolean strokeAlpha
-
strokeR
protected float strokeR
-
strokeG
protected float strokeG
-
strokeB
protected float strokeB
-
strokeA
protected float strokeA
-
strokeRi
protected int strokeRi
-
strokeGi
protected int strokeGi
-
strokeBi
protected int strokeBi
-
strokeAi
protected int strokeAi
-
DEFAULT_STROKE_WEIGHT
protected static final float DEFAULT_STROKE_WEIGHT
- See Also:
- Constant Field Values
-
DEFAULT_STROKE_JOIN
protected static final int DEFAULT_STROKE_JOIN
- See Also:
- Constant Field Values
-
DEFAULT_STROKE_CAP
protected static final int DEFAULT_STROKE_CAP
- See Also:
- Constant Field Values
-
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)
-
ERROR_TEXTFONT_NULL_PFONT
protected static final String ERROR_TEXTFONT_NULL_PFONT
- See Also:
- Constant Field Values
-
ambientColor
public int ambientColor
-
ambientR
public float ambientR
-
ambientG
public float ambientG
-
ambientB
public float ambientB
-
setAmbient
public boolean setAmbient
-
specularColor
public int specularColor
-
specularR
public float specularR
-
specularG
public float specularG
-
specularB
public float specularB
-
emissiveColor
public int emissiveColor
-
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
-
backgroundAlpha
protected boolean backgroundAlpha
-
backgroundR
protected float backgroundR
-
backgroundG
protected float backgroundG
-
backgroundB
protected float backgroundB
-
backgroundA
protected float backgroundA
-
backgroundRi
protected int backgroundRi
-
backgroundGi
protected int backgroundGi
-
backgroundBi
protected int backgroundBi
-
backgroundAi
protected int backgroundAi
-
ERROR_BACKGROUND_IMAGE_SIZE
protected static final String ERROR_BACKGROUND_IMAGE_SIZE
- See Also:
- Constant Field Values
-
ERROR_BACKGROUND_IMAGE_FORMAT
protected static final String ERROR_BACKGROUND_IMAGE_FORMAT
- See Also:
- Constant Field Values
-
blendMode
protected int blendMode
The current blending mode.
-
MATRIX_STACK_DEPTH
protected static final int MATRIX_STACK_DEPTH
Current model-view matrix transformation of the form m[row][column], which is a "column vector" (as opposed to "row vector") matrix.- See Also:
- Constant Field Values
-
ERROR_PUSHMATRIX_OVERFLOW
protected static final String ERROR_PUSHMATRIX_OVERFLOW
- See Also:
- Constant Field Values
-
ERROR_PUSHMATRIX_UNDERFLOW
protected static final String ERROR_PUSHMATRIX_UNDERFLOW
- See Also:
- Constant Field Values
-
image
public Image image
Java AWT Image object associated with this renderer. For the 1.0 version of P2D and P3D, this was associated with their MemoryImageSource. For PGraphicsJava2D, it will be the offscreen drawing buffer.
-
surface
protected PSurface surface
Surface object that we're talking to
-
calcR
protected float calcR
-
calcG
protected float calcG
-
calcB
protected float calcB
-
calcA
protected float calcA
-
calcRi
protected int calcRi
-
calcGi
protected int calcGi
-
calcBi
protected int calcBi
-
calcAi
protected int calcAi
-
calcColor
protected int calcColor
-
calcAlpha
protected boolean calcAlpha
-
shape
protected int shape
Type of shape passed to beginShape(), zero if no shape is currently being drawn.
-
DEFAULT_VERTICES
public static final int DEFAULT_VERTICES
- See Also:
- Constant Field Values
-
vertices
protected float[][] vertices
-
vertexCount
protected int vertexCount
-
bezierInited
protected boolean bezierInited
-
bezierDetail
public int bezierDetail
-
bezierBasisMatrix
protected PMatrix3D bezierBasisMatrix
-
bezierDrawMatrix
protected PMatrix3D bezierDrawMatrix
-
curveInited
protected boolean curveInited
-
curveDetail
public int curveDetail
-
curveTightness
public float curveTightness
-
curveBasisMatrix
protected PMatrix3D curveBasisMatrix
-
curveDrawMatrix
protected PMatrix3D curveDrawMatrix
-
bezierBasisInverse
protected PMatrix3D bezierBasisInverse
-
curveToBezierMatrix
protected PMatrix3D curveToBezierMatrix
-
curveVertices
protected float[][] curveVertices
-
curveVertexCount
protected int curveVertexCount
-
sinLUT
protected static final float[] sinLUT
-
cosLUT
protected static final float[] cosLUT
-
SINCOS_PRECISION
protected static final float SINCOS_PRECISION
- See Also:
- Constant Field Values
-
SINCOS_LENGTH
protected static final int SINCOS_LENGTH
- See Also:
- Constant Field Values
-
textBuffer
protected char[] textBuffer
Internal buffer used by the text() functions because the String object is slow
-
textWidthBuffer
protected char[] textWidthBuffer
-
textBreakCount
protected int textBreakCount
-
textBreakStart
protected int[] textBreakStart
-
textBreakStop
protected int[] textBreakStop
-
edge
public boolean edge
-
NORMAL_MODE_AUTO
protected static final int NORMAL_MODE_AUTO
- See Also:
- Constant Field Values
-
NORMAL_MODE_SHAPE
protected static final int NORMAL_MODE_SHAPE
- See Also:
- Constant Field Values
-
NORMAL_MODE_VERTEX
protected static final int NORMAL_MODE_VERTEX
- See Also:
- Constant Field Values
-
normalMode
protected int normalMode
-
autoNormal
protected boolean autoNormal
-
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
-
sphereX
protected float[] sphereX
-
sphereY
protected float[] sphereY
-
sphereZ
protected float[] sphereZ
-
sphereDetailU
public int sphereDetailU
-
sphereDetailV
public int sphereDetailV
-
asyncImageSaver
protected static PGraphics.AsyncImageSaver asyncImageSaver
-
-
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(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: this is ignored by the Methods task 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.
-
createSurface
public PSurface createSurface()
-
setCache
public void setCache(PImage image, Object storage)
Store data of some kind for the renderer that requires extra metadata of some kind. Usually this is a renderer-specific representation of the image data, for instance a BufferedImage with tint() settings applied for PGraphicsJava2D, or resized image data and OpenGL texture indices for PGraphicsOpenGL.- Parameters:
image- The image to be storedstorage- The metadata required by the renderer
-
getCache
public Object getCache(PImage image)
Get cache storage data for the specified renderer. Because each renderer will cache data in different formats, it's necessary to store cache data keyed by the renderer object. Otherwise, attempting to draw the same image to both a PGraphicsJava2D and a PGraphicsOpenGL will cause errors.- Returns:
- metadata stored for the specified renderer
-
removeCache
public void removeCache(PImage image)
Remove information associated with this renderer from the cache, if any.- Parameters:
image- The image whose cache data should be removed
-
beginDraw
public void beginDraw()
( begin auto-generated from PGraphics_beginDraw.xml ) Sets the default properties for a PGraphics object. It should be called before anything is drawn into the object. ( end auto-generated )Advanced
When creating your own PGraphics, you should call this before drawing anything.
-
endDraw
public void endDraw()
( begin auto-generated from PGraphics_endDraw.xml ) Finalizes the rendering of a PGraphics object so that it can be shown on screen. ( end auto-generated )Advanced
When creating your own PGraphics, you should call this when you're finished drawing.
-
beginPGL
public PGL beginPGL()
-
endPGL
public void endPGL()
-
flush
public void flush()
-
checkSettings
protected void checkSettings()
-
defaultSettings
protected void defaultSettings()
Set engine's default values. This has to be called by PApplet, somewhere inside setup() or draw() because it talks to the graphics buffer, meaning that for subclasses like OpenGL, there needs to be a valid graphics context to mess with otherwise you'll get some good crashing action. This is currently called by checkSettings(), during beginDraw().
-
reapplySettings
protected void reapplySettings()
Re-apply current settings. Some methods, such as textFont(), require that their methods be called (rather than simply setting the textFont variable) because they affect the graphics context, or they require parameters from the context (e.g. getting native fonts for text). This will only be called from an allocate(), which is only called from size(), which is safely called from inside beginDraw(). And it cannot be called before defaultSettings(), so we should be safe.
-
hint
public void hint(int which)
( begin auto-generated from hint.xml ) Set various hints and hacks for the renderer. This is used to handle obscure rendering features that cannot be implemented in a consistent manner across renderers. Many options will often graduate to standard features instead of hints over time.
hint(ENABLE_OPENGL_4X_SMOOTH) - Enable 4x anti-aliasing for P3D. This can help force anti-aliasing if it has not been enabled by the user. On some graphics cards, this can also be set by the graphics driver's control panel, however not all cards make this available. This hint must be called immediately after the size() command because it resets the renderer, obliterating any settings and anything drawn (and like size(), re-running the code that came before it again).
hint(DISABLE_OPENGL_2X_SMOOTH) - In Processing 1.0, Processing always enables 2x smoothing when the P3D renderer is used. This hint disables the default 2x smoothing and returns the smoothing behavior found in earlier releases, where smooth() and noSmooth() could be used to enable and disable smoothing, though the quality was inferior.
hint(ENABLE_NATIVE_FONTS) - Use the native version fonts when they are installed, rather than the bitmapped version from a .vlw file. This is useful with the default (or JAVA2D) renderer setting, as it will improve font rendering speed. This is not enabled by default, because it can be misleading while testing because the type will look great on your machine (because you have the font installed) but lousy on others' machines if the identical font is unavailable. This option can only be set per-sketch, and must be called before any use of textFont().
hint(DISABLE_DEPTH_TEST) - Disable the zbuffer, allowing you to draw on top of everything at will. When depth testing is disabled, items will be drawn to the screen sequentially, like a painting. This hint is most often used to draw in 3D, then draw in 2D on top of it (for instance, to draw GUI controls in 2D on top of a 3D interface). Starting in release 0149, this will also clear the depth buffer. Restore the default with hint(ENABLE_DEPTH_TEST), but note that with the depth buffer cleared, any 3D drawing that happens later in draw() will ignore existing shapes on the screen.
hint(ENABLE_DEPTH_SORT) - Enable primitive z-sorting of triangles and lines in P3D and OPENGL. This can slow performance considerably, and the algorithm is not yet perfect. Restore the default with hint(DISABLE_DEPTH_SORT).
hint(DISABLE_OPENGL_ERROR_REPORT) - Speeds up the P3D renderer setting by not checking for errors while running. Undo with hint(ENABLE_OPENGL_ERROR_REPORT).
hint(ENABLE_BUFFER_READING) - Depth and stencil buffers in P2D/P3D will be downsampled to make PGL#readPixels work with multisampling. Enabling this introduces some overhead, so if you experience bad performance, disable multisampling with noSmooth() instead. This hint is not intended to be enabled and disabled repeatedely, so call this once in setup() or after creating your PGraphics2D/3D. You can restore the default with hint(DISABLE_BUFFER_READING) if you don't plan to read depth from this PGraphics anymore.
hint(ENABLE_KEY_REPEAT) - Auto-repeating key events are discarded by default (works only in P2D/P3D); use this hint to get all the key events (including auto-repeated). Call hint(DISABLE_KEY_REPEAT) to get events only when the key goes physically up or down.
hint(DISABLE_ASYNC_SAVEFRAME) - P2D/P3D only - save() and saveFrame() will not use separate threads for saving and will block until the image is written to the drive. This was the default behavior in 3.0b7 and before. To enable, call hint(ENABLE_ASYNC_SAVEFRAME).
As of release 0149, unhint() has been removed in favor of adding additional ENABLE/DISABLE constants to reset the default behavior. This prevents the double negatives, and also reinforces which hints can be enabled or disabled. ( end auto-generated )- Parameters:
which- name of the hint to be enabled or disabled- See Also:
PGraphics,PApplet.createGraphics(int, int, String, String),PApplet.size(int, int)
-
beginShape
public void beginShape()
Start a new shape of type POLYGON
-
beginShape
public void beginShape(int kind)
( begin auto-generated from beginShape.xml ) Using the beginShape() and endShape() functions allow creating more complex forms. beginShape() begins recording vertices for a shape and endShape() stops recording. The value of the MODE parameter tells it which types of shapes to create from the provided vertices. With no mode specified, the shape can be any irregular polygon. The parameters available for beginShape() are POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, and QUAD_STRIP. After calling the beginShape() function, a series of vertex() commands must follow. To stop drawing the shape, call endShape(). The vertex() function with two parameters specifies a position in 2D and the vertex() function with three parameters specifies a position in 3D. Each shape will be outlined with the current stroke color and filled with the fill color.
Transformations such as translate(), rotate(), and scale() do not work within beginShape(). It is also not possible to use other shapes, such as ellipse() or rect() within beginShape().
The P3D renderer settings allow stroke() and fill() settings to be altered per-vertex, however the default P2D renderer does not. Settings such as strokeWeight(), strokeCap(), and strokeJoin() cannot be changed while inside a beginShape()/endShape() block with any renderer. ( end auto-generated )- Parameters:
kind- Either POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, or QUAD_STRIP- See Also:
PShape,endShape(),vertex(float, float, float, float, float),curveVertex(float, float, float),bezierVertex(float, float, float, float, float, float, float, float, float)
-
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)( begin auto-generated from normal.xml ) Sets the current normal vector. This is for drawing three dimensional shapes and surfaces and specifies a vector perpendicular to the surface of the shape which determines how lighting affects it. Processing attempts to automatically assign normals to shapes, but since that's imperfect, this is a better option when you want more control. This function is identical to glNormal3f() in OpenGL. ( end auto-generated )- Parameters:
nx- x directionny- y directionnz- z direction- See Also:
beginShape(int),endShape(int),lights()
-
attribPosition
public void attribPosition(String name, float x, float y, float z)
-
attribNormal
public void attribNormal(String name, float nx, float ny, float nz)
-
attribColor
public void attribColor(String name, int color)
-
attrib
public void attrib(String name, float... values)
-
attrib
public void attrib(String name, int... values)
-
attrib
public void attrib(String name, boolean... values)
-
textureMode
public void textureMode(int mode)
( begin auto-generated from textureMode.xml ) Sets the coordinate space for texture mapping. There are two options, IMAGE, which refers to the actual coordinates of the image, and NORMAL, which refers to a normalized space of values ranging from 0 to 1. The default mode is IMAGE. In IMAGE, if an image is 100 x 200 pixels, mapping the image onto the entire size of a quad would require the points (0,0) (0,100) (100,200) (0,200). The same mapping in NORMAL_SPACE is (0,0) (0,1) (1,1) (0,1). ( end auto-generated )- Parameters:
mode- either IMAGE or NORMAL- See Also:
texture(PImage),textureWrap(int)
-
textureWrap
public void textureWrap(int wrap)
( begin auto-generated from textureWrap.xml ) Description to come... ( end auto-generated from textureWrap.xml )- Parameters:
wrap- Either CLAMP (default) or REPEAT- See Also:
texture(PImage),textureMode(int)
-
texture
public void texture(PImage image)
( begin auto-generated from texture.xml ) Sets a texture to be applied to vertex points. The texture() function must be called between beginShape() and endShape() and before any calls to vertex().
When textures are in use, the fill color is ignored. Instead, use tint() to specify the color of the texture as it is applied to the shape. ( end auto-generated )- Parameters:
image- reference to a PImage object- See Also:
textureMode(int),textureWrap(int),beginShape(int),endShape(int),vertex(float, float, float, float, float)
-
noTexture
public void noTexture()
Removes texture image for current shape. Needs to be called between beginShape and endShape
-
vertexCheck
protected void vertexCheck()
-
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)( begin auto-generated from vertex.xml ) All shapes are constructed by connecting a series of vertices. vertex() is used to specify the vertex coordinates for points, lines, triangles, quads, and polygons and is used exclusively within the beginShape() and endShape() function.
Drawing a vertex in 3D using the z parameter requires the P3D parameter in combination with size as shown in the above example.
This function is also used to map a texture onto the geometry. The texture() function declares the texture to apply to the geometry and the u and v coordinates set define the mapping of this texture to the form. By default, the coordinates used for u and v are specified in relation to the image's size in pixels, but this relation can be changed with textureMode(). ( end auto-generated )- Parameters:
x- x-coordinate of the vertexy- y-coordinate of the vertexz- z-coordinate of the vertexu- horizontal coordinate for the texture mappingv- vertical coordinate for the texture mapping- See Also:
beginShape(int),endShape(int),bezierVertex(float, float, float, float, float, float, float, float, float),quadraticVertex(float, float, float, float, float, float),curveVertex(float, float, float),texture(PImage)
-
vertexTexture
protected void vertexTexture(float u, float v)Set (U, V) coords for the next vertex in the current shape. This is ugly as its own function, and will (almost?) always be coincident with a call to vertex. As of beta, this was moved to the protected method you see here, and called from an optional param of and overloaded vertex(). The parameters depend on the current textureMode. When using textureMode(IMAGE), the coordinates will be relative to the size of the image texture, when used with textureMode(NORMAL), they'll be in the range 0..1. Used by both PGraphics2D (for images) and PGraphics3D.
-
beginContour
public void beginContour()
-
endContour
public void endContour()
-
endShape
public void endShape()
-
endShape
public void endShape(int mode)
( begin auto-generated from endShape.xml ) The endShape() function is the companion to beginShape() and may only be called after beginShape(). When endshape() is called, all of image data defined since the previous call to beginShape() is written into the image buffer. The constant CLOSE as the value for the MODE parameter to close the shape (to connect the beginning and the end). ( end auto-generated )- Parameters:
mode- use CLOSE to close the shape- See Also:
PShape,beginShape(int)
-
loadShape
public PShape loadShape(String filename)
- Parameters:
filename- name of file to load, can be .svg or .obj- See Also:
PShape,PApplet.createShape()
-
createShape
public PShape createShape()
- See Also:
PShape,PShape.endShape(),PApplet.loadShape(String)
-
createShape
public PShape createShape(int type)
-
createShapeFamily
protected PShape createShapeFamily(int type)
Override this method to return an appropriate shape for your renderer
-
createShape
public PShape createShape(int kind, float... p)
- Parameters:
kind- either POINT, LINE, TRIANGLE, QUAD, RECT, ELLIPSE, ARC, BOX, SPHEREp- parameters that match the kind of shape
-
createShapePrimitive
protected PShape createShapePrimitive(int kind, float... p)
Override this to have a custom shape object used by your renderer.
-
loadShader
public PShader loadShader(String fragFilename)
( begin auto-generated from loadShader.xml ) This is a new reference entry for Processing 2.0. It will be updated shortly. ( end auto-generated )- Parameters:
fragFilename- name of fragment shader file
-
loadShader
public PShader loadShader(String fragFilename, String vertFilename)
- Parameters:
vertFilename- name of vertex shader file
-
shader
public void shader(PShader shader)
( begin auto-generated from shader.xml ) This is a new reference entry for Processing 2.0. It will be updated shortly. ( end auto-generated )- Parameters:
shader- name of shader file
-
shader
public void shader(PShader shader, int kind)
- Parameters:
kind- type of shader, either POINTS, LINES, or TRIANGLES
-
resetShader
public void resetShader()
( begin auto-generated from resetShader.xml ) This is a new reference entry for Processing 2.0. It will be updated shortly. ( end auto-generated )
-
resetShader
public void resetShader(int kind)
- Parameters:
kind- type of shader, either POINTS, LINES, or TRIANGLES
-
filter
public void filter(PShader shader)
- Parameters:
shader- the fragment shader to apply
-
clip
public void clip(float a, float b, float c, float d)( begin auto-generated from clip.xml ) Limits the rendering to the boundaries of a rectangle defined by the parameters. The boundaries are drawn based on the state of the imageMode() fuction, either CORNER, CORNERS, or CENTER. ( end auto-generated )- Parameters:
a- x-coordinate of the rectangle, by defaultb- y-coordinate of the rectangle, by defaultc- width of the rectangle, by defaultd- height of the rectangle, by default
-
clipImpl
protected void clipImpl(float x1, float y1, float x2, float y2)
-
noClip
public void noClip()
( begin auto-generated from noClip.xml ) Disables the clipping previously started by the clip() function. ( end auto-generated )
-
blendMode
public void blendMode(int mode)
( begin auto-generated from blendMode.xml ) This is a new reference entry for Processing 2.0. It will be updated shortly. ( end auto-generated )- Parameters:
mode- the blending mode to use
-
blendModeImpl
protected void blendModeImpl()
-
bezierVertexCheck
protected void bezierVertexCheck()
-
bezierVertexCheck
protected void bezierVertexCheck(int shape, int vertexCount)
-
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)( begin auto-generated from bezierVertex.xml ) Specifies vertex coordinates for Bezier curves. Each call to bezierVertex() defines the position of two control points and one anchor point of a Bezier curve, adding a new segment to a line or shape. The first time bezierVertex() is used within a beginShape() call, it must be prefaced with a call to vertex() to set the first anchor point. This function must be used between beginShape() and endShape() and only when there is no MODE parameter specified to beginShape(). Using the 3D version requires rendering with P3D (see the Environment reference for more information). ( end auto-generated )- Parameters:
x2- the x-coordinate of the 1st control pointy2- the y-coordinate of the 1st control pointz2- the z-coordinate of the 1st control pointx3- the x-coordinate of the 2nd control pointy3- the y-coordinate of the 2nd control pointz3- the z-coordinate of the 2nd control pointx4- the x-coordinate of the anchor pointy4- the y-coordinate of the anchor pointz4- the z-coordinate of the anchor point- See Also:
curveVertex(float, float, float),vertex(float, float, float, float, float),quadraticVertex(float, float, float, float, float, float),bezier(float, float, float, float, float, float, float, float, float, float, float, float)
-
quadraticVertex
public void quadraticVertex(float cx, float cy, float x3, float y3)- Parameters:
cx- the x-coordinate of the control pointcy- the y-coordinate of the control pointx3- the x-coordinate of the anchor pointy3- the y-coordinate of the anchor point- See Also:
curveVertex(float, float, float),vertex(float, float, float, float, float),bezierVertex(float, float, float, float, float, float),bezier(float, float, float, float, float, float, float, float, float, float, float, float)
-
quadraticVertex
public void quadraticVertex(float cx, float cy, float cz, float x3, float y3, float z3)- Parameters:
cz- the z-coordinate of the control pointz3- the z-coordinate of the anchor point
-
curveVertexCheck
protected void curveVertexCheck()
-
curveVertexCheck
protected void curveVertexCheck(int shape)
Perform initialization specific to curveVertex(), and handle standard error modes. Can be overridden by subclasses that need the flexibility.
-
curveVertex
public void curveVertex(float x, float y)( begin auto-generated from curveVertex.xml ) Specifies vertex coordinates for curves. This function may only be used between beginShape() and endShape() and only when there is no MODE parameter specified to beginShape(). The first and last points in a series of curveVertex() lines will be used to guide the beginning and end of a the curve. A minimum of four points is required to draw a tiny curve between the second and third points. Adding a fifth point with curveVertex() will draw the curve between the second, third, and fourth points. The curveVertex() function is an implementation of Catmull-Rom splines. Using the 3D version requires rendering with P3D (see the Environment reference for more information). ( end auto-generated )- Parameters:
x- the x-coordinate of the vertexy- the y-coordinate of the vertex- See Also:
curve(float, float, float, float, float, float, float, float, float, float, float, float),beginShape(int),endShape(int),vertex(float, float, float, float, float),bezier(float, float, float, float, float, float, float, float, float, float, float, float),quadraticVertex(float, float, float, float, float, float)
-
curveVertex
public void curveVertex(float x, float y, float z)- Parameters:
z- the z-coordinate of the vertex
-
curveVertexSegment
protected void curveVertexSegment(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)Handle emitting a specific segment of Catmull-Rom curve. This can be overridden by subclasses that need more efficient rendering options.
-
curveVertexSegment
protected void curveVertexSegment(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)Handle emitting a specific segment of Catmull-Rom curve. This can be overridden by subclasses that need more efficient rendering options.
-
point
public void point(float x, float y)( begin auto-generated from point.xml ) Draws a point, a coordinate in space at the dimension of one pixel. The first parameter is the horizontal value for the point, the second value is the vertical value for the point, and the optional third value is the depth value. Drawing this shape in 3D with the z parameter requires the P3D parameter in combination with size() as shown in the above example. ( end auto-generated )- Parameters:
x- x-coordinate of the pointy- y-coordinate of the point- See Also:
stroke(int)
-
point
public void point(float x, float y, float z)- Parameters:
z- z-coordinate of the point
-
line
public void line(float x1, float y1, float x2, float y2)( begin auto-generated from line.xml ) Draws a line (a direct path between two points) to the screen. The version of line() with four parameters draws the line in 2D. To color a line, use the stroke() function. A line cannot be filled, therefore the fill() function will not affect the color of a line. 2D lines are drawn with a width of one pixel by default, but this can be changed with the strokeWeight() function. The version with six parameters allows the line to be placed anywhere within XYZ space. Drawing this shape in 3D with the z parameter requires the P3D parameter in combination with size() as shown in the above example. ( end auto-generated )- Parameters:
x1- x-coordinate of the first pointy1- y-coordinate of the first pointx2- x-coordinate of the second pointy2- y-coordinate of the second point- See Also:
strokeWeight(float),strokeJoin(int),strokeCap(int),beginShape()
-
line
public void line(float x1, float y1, float z1, float x2, float y2, float z2)- Parameters:
z1- z-coordinate of the first pointz2- z-coordinate of the second point
-
triangle
public void triangle(float x1, float y1, float x2, float y2, float x3, float y3)( begin auto-generated from triangle.xml ) A triangle is a plane created by connecting three points. The first two arguments specify the first point, the middle two arguments specify the second point, and the last two arguments specify the third point. ( end auto-generated )- Parameters:
x1- x-coordinate of the first pointy1- y-coordinate of the first pointx2- x-coordinate of the second pointy2- y-coordinate of the second pointx3- x-coordinate of the third pointy3- y-coordinate of the third point- See Also:
PApplet.beginShape()
-
quad
public void quad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)( begin auto-generated from quad.xml ) A quad is a quadrilateral, a four sided polygon. It is similar to a rectangle, but the angles between its edges are not constrained to ninety degrees. The first pair of parameters (x1,y1) sets the first vertex and the subsequent pairs should proceed clockwise or counter-clockwise around the defined shape. ( end auto-generated )- Parameters:
x1- x-coordinate of the first cornery1- y-coordinate of the first cornerx2- x-coordinate of the second cornery2- y-coordinate of the second cornerx3- x-coordinate of the third cornery3- y-coordinate of the third cornerx4- x-coordinate of the fourth cornery4- y-coordinate of the fourth corner
-
rectMode
public void rectMode(int mode)
( begin auto-generated from rectMode.xml ) Modifies the location from which rectangles draw. The default mode is rectMode(CORNER), which specifies the location to be the upper left corner of the shape and uses the third and fourth parameters of rect() to specify the width and height. The syntax rectMode(CORNERS) uses the first and second parameters of rect() to set the location of one corner and uses the third and fourth parameters to set the opposite corner. The syntax rectMode(CENTER) draws the image from its center point and uses the third and forth parameters of rect() to specify the image's width and height. The syntax rectMode(RADIUS) draws the image from its center point and uses the third and forth parameters of rect() to specify half of the image's width and height. The parameter must be written in ALL CAPS because Processing is a case sensitive language. Note: In version 125, the mode named CENTER_RADIUS was shortened to RADIUS. ( end auto-generated )- Parameters:
mode- either CORNER, CORNERS, CENTER, or RADIUS- See Also:
rect(float, float, float, float)
-
rect
public void rect(float a, float b, float c, float d)( begin auto-generated from rect.xml ) Draws a rectangle to the screen. A rectangle is a four-sided shape with every angle at ninety degrees. By default, the first two parameters set the location of the upper-left corner, the third sets the width, and the fourth sets the height. These parameters may be changed with the rectMode() function. ( end auto-generated )- Parameters:
a- x-coordinate of the rectangle by defaultb- y-coordinate of the rectangle by defaultc- width of the rectangle by defaultd- height of the rectangle by default- See Also:
rectMode(int),quad(float, float, float, float, float, float, float, float)
-
rectImpl
protected void rectImpl(float x1, float y1, float x2, float y2)
-
rect
public void rect(float a, float b, float c, float d, float r)- Parameters:
r- radii for all four corners
-
rect
public void rect(float a, float b, float c, float d, float tl, float tr, float br, float bl)- Parameters:
tl- radius for top-left cornertr- radius for top-right cornerbr- radius for bottom-right cornerbl- radius for bottom-left corner
-
rectImpl
protected void rectImpl(float x1, float y1, float x2, float y2, float tl, float tr, float br, float bl)
-
square
public void square(float x, float y, float extent)( begin auto-generated from square.xml ) Draws a square to the screen. A square is a four-sided shape with every angle at ninety degrees and each side is the same length. By default, the first two parameters set the location of the upper-left corner, the third sets the width and height. The way these parameters are interpreted, however, may be changed with the rectMode() function. ( end auto-generated )- Parameters:
x- x-coordinate of the rectangle by defaulty- y-coordinate of the rectangle by defaultextent- width and height of the rectangle by default- See Also:
rect(float, float, float, float),rectMode(int)
-
ellipseMode
public void ellipseMode(int mode)
( begin auto-generated from ellipseMode.xml ) The origin of the ellipse is modified by the ellipseMode() function. The default configuration is ellipseMode(CENTER), which specifies the location of the ellipse as the center of the shape. The RADIUS mode is the same, but the width and height parameters to ellipse() specify the radius of the ellipse, rather than the diameter. The CORNER mode draws the shape from the upper-left corner of its bounding box. The CORNERS mode uses the four parameters to ellipse() to set two opposing corners of the ellipse's bounding box. The parameter must be written in ALL CAPS because Processing is a case-sensitive language. ( end auto-generated )- Parameters:
mode- either CENTER, RADIUS, CORNER, or CORNERS- See Also:
PApplet.ellipse(float, float, float, float),PApplet.arc(float, float, float, float, float, float)
-
ellipse
public void ellipse(float a, float b, float c, float d)( begin auto-generated from ellipse.xml ) Draws an ellipse (oval) in the display window. An ellipse with an equal width and height is a circle. The first two parameters set the location, the third sets the width, and the fourth sets the height. The origin may be changed with the ellipseMode() function. ( end auto-generated )- Parameters:
a- x-coordinate of the ellipseb- y-coordinate of the ellipsec- width of the ellipse by defaultd- height of the ellipse by default- See Also:
PApplet.ellipseMode(int),PApplet.arc(float, float, float, float, float, float)
-
ellipseImpl
protected void ellipseImpl(float x, float y, float w, float h)
-
arc
public void arc(float a, float b, float c, float d, float start, float stop)( begin auto-generated from arc.xml ) Draws an arc in the display window. Arcs are drawn along the outer edge of an ellipse defined by the x, y, width and height parameters. The origin or the arc's ellipse may be changed with the ellipseMode() function. The start and stop parameters specify the angles at which to draw the arc. ( end auto-generated )- Parameters:
a- x-coordinate of the arc's ellipseb- y-coordinate of the arc's ellipsec- width of the arc's ellipse by defaultd- height of the arc's ellipse by defaultstart- angle to start the arc, specified in radiansstop- angle to stop the arc, specified in radians- See Also:
PApplet.ellipse(float, float, float, float),PApplet.ellipseMode(int),PApplet.radians(float),PApplet.degrees(float)
-
arc
public void arc(float a, float b, float c, float d, float start, float stop, int mode)
-
arcImpl
protected void arcImpl(float x, float y, float w, float h, float start, float stop, int mode)Start and stop are in radians, converted by the parent function. Note that the radians can be greater (or less) than TWO_PI. This is so that an arc can be drawn that crosses zero mark, and the user will still collect $200.
-
circle
public void circle(float x, float y, float extent)( begin auto-generated from circle.xml ) Draws a circle to the screen. By default, the first two parameters set the location of the center, and the third sets the shape's width and height. The origin may be changed with the ellipseMode() function. ( end auto-generated )- Parameters:
x- x-coordinate of the ellipsey- y-coordinate of the ellipseextent- width and height of the ellipse by default- See Also:
PApplet.ellipse(float, float, float, float),PApplet.ellipseMode(int)
-
box
public void box(float size)
( begin auto-generated from box.xml ) A box is an extruded rectangle. A box with equal dimension on all sides is a cube. ( end auto-generated )- Parameters:
size- dimension of the box in all dimensions (creates a cube)- See Also:
sphere(float)
-
box
public void box(float w, float h, float d)- Parameters:
w- dimension of the box in the x-dimensionh- dimension of the box in the y-dimensiond- dimension of the box in the z-dimension
-
sphereDetail
public void sphereDetail(int res)
( begin auto-generated from sphereDetail.xml ) Controls the detail used to render a sphere by adjusting the number of vertices of the sphere mesh. The default resolution is 30, which creates a fairly detailed sphere definition with vertices every 360/30 = 12 degrees. If you're going to render a great number of spheres per frame, it is advised to reduce the level of detail using this function. The setting stays active until sphereDetail() is called again with a new parameter and so should not be called prior to every sphere() statement, unless you wish to render spheres with different settings, e.g. using less detail for smaller spheres or ones further away from the camera. To control the detail of the horizontal and vertical resolution independently, use the version of the functions with two parameters. ( end auto-generated )Advanced
Code for sphereDetail() submitted by toxi [031031]. Code for enhanced u/v version from davbol [080801].- Parameters:
res- number of segments (minimum 3) used per full circle revolution- See Also:
sphere(float)
-
sphereDetail
public void sphereDetail(int ures, int vres)- Parameters:
ures- number of segments used longitudinally per full circle revolutoinvres- number of segments used latitudinally from top to bottom
-
sphere
public void sphere(float r)
( begin auto-generated from sphere.xml ) A sphere is a hollow ball made from tessellated triangles. ( end auto-generated )Advanced
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
- Parameters:
r- the radius of the sphere- See Also:
sphereDetail(int)
-
bezierPoint
public float bezierPoint(float a, float b, float c, float d, float t)( begin auto-generated from bezierPoint.xml ) Evaluates the Bezier at point t for points a, b, c, d. The parameter t varies between 0 and 1, a and d are points on the curve, and 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. ( end auto-generated )Advanced
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();- Parameters:
a- coordinate of first point on the curveb- coordinate of first control pointc- coordinate of second control pointd- coordinate of second point on the curvet- value between 0 and 1- See Also:
bezier(float, float, float, float, float, float, float, float, float, float, float, float),bezierVertex(float, float, float, float, float, float),curvePoint(float, float, float, float, float)
-
bezierTangent
public float bezierTangent(float a, float b, float c, float d, float t)( begin auto-generated from bezierTangent.xml ) Calculates the tangent of a point on a Bezier curve. There is a good definition of tangent on Wikipedia. ( end auto-generated )Advanced
Code submitted by Dave Bollinger (davol) for release 0136.- Parameters:
a- coordinate of first point on the curveb- coordinate of first control pointc- coordinate of second control pointd- coordinate of second point on the curvet- value between 0 and 1- See Also:
bezier(float, float, float, float, float, float, float, float, float, float, float, float),bezierVertex(float, float, float, float, float, float),curvePoint(float, float, float, float, float)
-
bezierInitCheck
protected void bezierInitCheck()
-
bezierInit
protected void bezierInit()
-
bezierDetail
public void bezierDetail(int detail)
( begin auto-generated from bezierDetail.xml ) Sets the resolution at which Beziers display. The default value is 20. This function is only useful when using the P3D renderer as the default P2D renderer does not use this information. ( end auto-generated )- Parameters:
detail- resolution of the curves- See Also:
curve(float, float, float, float, float, float, float, float, float, float, float, float),curveVertex(float, float, float),curveTightness(float)
-
bezier
public void bezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
-
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)( begin auto-generated from bezier.xml ) Draws a Bezier curve on the screen. These curves are defined by a series of anchor and control points. The first two parameters specify the first anchor point and the last two parameters specify the other anchor point. The middle parameters specify the control points which define the shape of the curve. Bezier curves were developed by French engineer Pierre Bezier. Using the 3D version requires rendering with P3D (see the Environment reference for more information). ( end auto-generated )Advanced
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);
- Parameters:
x1- coordinates for the first anchor pointy1- coordinates for the first anchor pointz1- coordinates for the first anchor pointx2- coordinates for the first control pointy2- coordinates for the first control pointz2- coordinates for the first control pointx3- coordinates for the second control pointy3- coordinates for the second control pointz3- coordinates for the second control pointx4- coordinates for the second anchor pointy4- coordinates for the second anchor pointz4- coordinates for the second anchor point- See Also:
bezierVertex(float, float, float, float, float, float),curve(float, float, float, float, float, float, float, float, float, float, float, float)
-
curvePoint
public float curvePoint(float a, float b, float c, float d, float t)( begin auto-generated from curvePoint.xml ) Evalutes the curve at point t for points a, b, c, d. The parameter t varies between 0 and 1, a and d are points on the curve, and 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 curve at t. ( end auto-generated )- Parameters:
a- coordinate of first point on the curveb- coordinate of second point on the curvec- coordinate of third point on the curved- coordinate of fourth point on the curvet- value between 0 and 1- See Also:
curve(float, float, float, float, float, float, float, float, float, float, float, float),curveVertex(float, float),bezierPoint(float, float, float, float, float)
-
curveTangent
public float curveTangent(float a, float b, float c, float d, float t)( begin auto-generated from curveTangent.xml ) Calculates the tangent of a point on a curve. There's a good definition of tangent on Wikipedia. ( end auto-generated )Advanced
Code thanks to Dave Bollinger (Bug #715)- Parameters:
a- coordinate of first point on the curveb- coordinate of first control pointc- coordinate of second control pointd- coordinate of second point on the curvet- value between 0 and 1- See Also:
curve(float, float, float, float, float, float, float, float, float, float, float, float),curveVertex(float, float),curvePoint(float, float, float, float, float),bezierTangent(float, float, float, float, float)
-
curveDetail
public void curveDetail(int detail)
( begin auto-generated from curveDetail.xml ) Sets the resolution at which curves display. The default value is 20. This function is only useful when using the P3D renderer as the default P2D renderer does not use this information. ( end auto-generated )- Parameters:
detail- resolution of the curves- See Also:
curve(float, float, float, float, float, float, float, float, float, float, float, float),curveVertex(float, float),curveTightness(float)
-
curveTightness
public void curveTightness(float tightness)
( begin auto-generated from curveTightness.xml ) Modifies the quality of forms created with curve() and curveVertex(). The parameter squishy determines how the curve fits to the vertex points. The value 0.0 is the default value for squishy (this value defines the curves to be Catmull-Rom splines) and the value 1.0 connects all the points with straight lines. Values within the range -5.0 and 5.0 will deform the curves but will leave them recognizable and as values increase in magnitude, they will continue to deform. ( end auto-generated )- Parameters:
tightness- amount of deformation from the original vertices- See Also:
curve(float, float, float, float, float, float, float, float, float, float, float, float),curveVertex(float, float)
-
curveInitCheck
protected void curveInitCheck()
-
curveInit
protected void curveInit()
Set the number of segments to use when drawing a Catmull-Rom curve, and setting the s parameter, which defines how tightly the curve fits to each vertex. Catmull-Rom curves are actually a subset of this curve type where the s is set to zero.(This function is not optimized, since it's not expected to be called all that often. there are many juicy and obvious opimizations in here, but it's probably better to keep the code more readable)
-
curve
public void curve(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)( begin auto-generated from curve.xml ) Draws a curved line on the screen. The first and second parameters specify the beginning control point and the last two parameters specify the ending control point. The middle parameters specify the start and stop of the curve. Longer curves can be created by putting a series of curve() functions together or using curveVertex(). An additional function called curveTightness() provides control for the visual quality of the curve. The curve() function is an implementation of Catmull-Rom splines. Using the 3D version requires rendering with P3D (see the Environment reference for more information). ( end auto-generated )Advanced
As of revision 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();
- Parameters:
x1- coordinates for the beginning control pointy1- coordinates for the beginning control pointx2- coordinates for the first pointy2- coordinates for the first pointx3- coordinates for the second pointy3- coordinates for the second pointx4- coordinates for the ending control pointy4- coordinates for the ending control point- See Also:
curveVertex(float, float),curveTightness(float),bezier(float, float, float, float, float, float, float, float, float, float, float, float)
-
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)- Parameters:
z1- coordinates for the beginning control pointz2- coordinates for the first pointz3- coordinates for the second pointz4- coordinates for the ending control point
-
splineForward
protected void splineForward(int segments, PMatrix3D matrix)Setup forward-differencing matrix to be used for speedy curve rendering. It's based on using a specific number of curve segments and just doing incremental adds for each vertex of the segment, rather than running the mathematically expensive cubic equation.- Parameters:
segments- number of curve segments to use when drawingmatrix- target object for the new matrix
-
smooth
public void smooth()
-
smooth
public void smooth(int quality)
-
noSmooth
public void noSmooth()
-
imageMode
public void imageMode(int mode)
( begin auto-generated from imageMode.xml ) Modifies the location from which images draw. The default mode is imageMode(CORNER), which specifies the location to be the upper left corner and uses the fourth and fifth parameters of image() to set the image's width and height. The syntax imageMode(CORNERS) uses the second and third parameters of image() to set the location of one corner of the image and uses the fourth and fifth parameters to set the opposite corner. Use imageMode(CENTER) to draw images centered at the given x and y position.
The parameter to imageMode() must be written in ALL CAPS because Processing is a case-sensitive language. ( end auto-generated )- Parameters:
mode- either CORNER, CORNERS, or CENTER- See Also:
PApplet.loadImage(String, String),PImage,image(PImage, float, float, float, float),background(float, float, float, float)
-
image
public void image(PImage img, float a, float b)
( begin auto-generated from image.xml ) Displays images to the screen. The images must be in the sketch's "data" directory to load correctly. Select "Add file..." from the "Sketch" menu to add the image. Processing currently works with GIF, JPEG, and Targa images. The img parameter specifies the image to display and the x and y parameters define the location of the image from its upper-left corner. The image is displayed at its original size unless the width and height parameters specify a different size.
The imageMode() function changes the way the parameters work. For example, a call to imageMode(CORNERS) will change the width and height parameters to define the x and y values of the opposite corner of the image.
The color of an image may be modified with the tint() function. This function will maintain transparency for GIF and PNG images. ( end auto-generated )Advanced
Starting with release 0124, when using the default (JAVA2D) renderer, smooth() will also improve image quality of resized images.- Parameters:
img- the image to displaya- x-coordinate of the image by defaultb- y-coordinate of the image by default- See Also:
PApplet.loadImage(String, String),PImage,imageMode(int),tint(float),background(float, float, float, float),alpha(int)
-
image
public void image(PImage img, float a, float b, float c, float d)
- Parameters:
c- width to display the image by defaultd- height to display the image by default
-
image
public void image(PImage img, 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().
-
imageImpl
protected void imageImpl(PImage img, float x1, float y1, float x2, float y2, int u1, int v1, int u2, int v2)
Expects x1, y1, x2, y2 coordinates where (x2 >= x1) and (y2 >= y1). If tint() has been called, the image will be colored. The default implementation draws an image as a textured quad. The (u, v) coordinates are in image space (they're ints, after all..)
-
shapeMode
public void shapeMode(int mode)
( begin auto-generated from shapeMode.xml ) Modifies the location from which shapes draw. The default mode is shapeMode(CORNER), which specifies the location to be the upper left corner of the shape and uses the third and fourth parameters of shape() to specify the width and height. The syntax shapeMode(CORNERS) uses the first and second parameters of shape() to set the location of one corner and uses the third and fourth parameters to set the opposite corner. The syntax shapeMode(CENTER) draws the shape from its center point and uses the third and forth parameters of shape() to specify the width and height. The parameter must be written in "ALL CAPS" because Processing is a case sensitive language. ( end auto-generated )- Parameters:
mode- either CORNER, CORNERS, CENTER- See Also:
PShape,shape(PShape),rectMode(int)
-
shape
public void shape(PShape shape)
-
shape
public void shape(PShape shape, float x, float y)
( begin auto-generated from shape.xml ) Displays shapes to the screen. The shapes must be in the sketch's "data" directory to load correctly. Select "Add file..." from the "Sketch" menu to add the shape. Processing currently works with SVG shapes only. The sh parameter specifies the shape to display and the x and y parameters define the location of the shape from its upper-left corner. The shape is displayed at its original size unless the width and height parameters specify a different size. The shapeMode() function changes the way the parameters work. A call to shapeMode(CORNERS), for example, will change the width and height parameters to define the x and y values of the opposite corner of the shape.
Note complex shapes may draw awkwardly with P3D. This renderer does not yet support shapes that have holes or complicated breaks. ( end auto-generated )- Parameters:
shape- the shape to displayx- x-coordinate of the shapey- y-coordinate of the shape- See Also:
PShape,PApplet.loadShape(String),Convenience method to draw at a particular location.
-
shape
protected void shape(PShape shape, float x, float y, float z)
-
shape
public void shape(PShape shape, float a, float b, float c, float d)
- Parameters:
a- x-coordinate of the shapeb- y-coordinate of the shapec- width to display the shaped- height to display the shape
-
shape
protected void shape(PShape shape, float x, float y, float z, float c, float d, float e)
-
createDefaultFont
protected PFont createDefaultFont(float size)
Used by PGraphics to remove the requirement for loading a font.
-
textAlign
public void textAlign(int alignX)
-
textAlign
public void textAlign(int alignX, int alignY)( begin auto-generated from textAlign.xml ) Sets the current alignment for drawing text. The parameters LEFT, CENTER, and RIGHT set the display characteristics of the letters in relation to the values for the x and y parameters of the text() function.
In Processing 0125 and later, an optional second parameter can be used to vertically align the text. BASELINE is the default, and the vertical alignment will be reset to BASELINE if the second parameter is not used. The TOP and CENTER parameters are straightforward. The BOTTOM parameter offsets the line based on the current textDescent(). For multiple lines, the final line will be aligned to the bottom, with the previous lines appearing above it.
When using text() with width and height parameters, BASELINE is ignored, and treated as TOP. (Otherwise, text would by default draw outside the box, since BASELINE is the default setting. BASELINE is not a useful drawing mode for text drawn in a rectangle.)
The vertical alignment is based on the value of textAscent(), which many fonts do not specify correctly. It may be necessary to use a hack and offset by a few pixels by hand so that the offset looks correct. To do this as less of a hack, use some percentage of textAscent() or textDescent() so that the hack works even if you change the size of the font. ( end auto-generated )- Parameters:
alignX- horizontal alignment, either LEFT, CENTER, or RIGHTalignY- vertical alignment, either TOP, BOTTOM, CENTER, or BASELINE- See Also:
PApplet.loadFont(String),PFont,text(String, float, float),textSize(float),textAscent(),textDescent()
-
textAscent
public float textAscent()
( begin auto-generated from textAscent.xml ) Returns ascent of the current font at its current size. This information is useful for determining the height of the font above the baseline. For example, adding the textAscent() and textDescent() values will give you the total height of the line. ( end auto-generated )- See Also:
textDescent()
-
textDescent
public float textDescent()
( begin auto-generated from textDescent.xml ) Returns descent of the current font at its current size. This information is useful for determining the height of the font below the baseline. For example, adding the textAscent() and textDescent() values will give you the total height of the line. ( end auto-generated )- See Also:
textAscent()
-
textFont
public void textFont(PFont which)
( begin auto-generated from textFont.xml ) Sets the current font that will be drawn with the text() function. Fonts must be loaded with loadFont() before it can be used. This font will be used in all subsequent calls to the text() function. If no size parameter is input, the font will appear at its original size (the size it was created at with the "Create Font..." tool) until it is changed with textSize().
Because fonts are usually bitmaped, you should create fonts at the sizes that will be used most commonly. Using textFont() without the size parameter will result in the cleanest-looking text.
With the default (JAVA2D) and PDF renderers, it's also possible to enable the use of native fonts via the command hint(ENABLE_NATIVE_FONTS). This will produce vector text in JAVA2D sketches and PDF output in cases where the vector data is available: when the font is still installed, or the font is created via the createFont() function (rather than the Create Font tool). ( end auto-generated )- Parameters:
which- any variable of the type PFont- See Also:
PApplet.createFont(String, float, boolean),PApplet.loadFont(String),PFont,text(String, float, float),textSize(float)
-
textFont
public void textFont(PFont which, float size)
- Parameters:
size- the size of the letters in units of pixels
-
textFontImpl
protected void textFontImpl(PFont which, float size)
Called from textFont. Check the validity of args and print possible errors to the user before calling this. Subclasses will want to override this one.- Parameters:
which- font to set, not nullsize- size to set, greater than zero
-
textLeading
public void textLeading(float leading)
( begin auto-generated from textLeading.xml ) Sets the spacing between lines of text in units of pixels. This setting will be used in all subsequent calls to the text() function. ( end auto-generated )- Parameters:
leading- the size in pixels for spacing between lines- See Also:
PApplet.loadFont(String),PFont(java.io.InputStream),text(String, float, float),textFont(PFont),textSize(float)
-
textMode
public void textMode(int mode)
( begin auto-generated from textMode.xml ) Sets the way text draws to the screen. In the default configuration, the MODEL mode, it's possible to rotate, scale, and place letters in two and three dimensional space.
The SHAPE mode draws text using the the glyph outlines of individual characters rather than as textures. This mode is only supported with the PDF and P3D renderer settings. With the PDF renderer, you must call textMode(SHAPE) before any other drawing occurs. If the outlines are not available, then textMode(SHAPE) will be ignored and textMode(MODEL) will be used instead.
The textMode(SHAPE) option in P3D can be combined with beginRaw() to write vector-accurate text to 2D and 3D output files, for instance DXF or PDF. The SHAPE mode is not currently optimized for P3D, so if recording shape data, use textMode(MODEL) until you're ready to capture the geometry with beginRaw(). ( end auto-generated )- Parameters:
mode- either MODEL or SHAPE- See Also:
PApplet.loadFont(String),PFont(java.io.InputStream),text(String, float, float),textFont(PFont),beginRaw(PGraphics),PApplet.createFont(String, float, boolean)
-
textModeCheck
protected boolean textModeCheck(int mode)
-
textSize
public void textSize(float size)
( begin auto-generated from textSize.xml ) Sets the current font size. This size will be used in all subsequent calls to the text() function. Font size is measured in units of pixels. ( end auto-generated )- Parameters:
size- the size of the letters in units of pixels- See Also:
PApplet.loadFont(String),PFont(java.io.InputStream),text(String, float, float),textFont(PFont)
-
textSizeImpl
protected void textSizeImpl(float size)
Called from textSize() after validating size. Subclasses will want to override this one.- Parameters:
size- size of the text, greater than zero
-
handleTextSize
protected void handleTextSize(float size)
Sets the actual size. Called from textSizeImpl and from textFontImpl after setting the font.- Parameters:
size- size of the text, greater than zero
-
textWidth
public float textWidth(char c)
- Parameters:
c- the character to measure
-
textWidth
public float textWidth(String str)
( begin auto-generated from textWidth.xml ) Calculates and returns the width of any character or text string. ( end auto-generated )- Parameters:
str- the String of characters to measure- See Also:
PApplet.loadFont(String),PFont(java.io.InputStream),text(String, float, float),textFont(PFont),textSize(float)
-
textWidth
public float textWidth(char[] chars, int start, int length)
-
textWidthImpl
protected float textWidthImpl(char[] buffer, int start, int stop)Implementation of returning the text width of the chars [start, stop) in the buffer. Unlike the previous version that was inside PFont, this will return the size not of a 1 pixel font, but the actual current size.
-
text
public void text(char c, float x, float y)( begin auto-generated from text.xml ) Draws text to the screen. Displays the information specified in the data or stringdata parameters on the screen in the position specified by the x and y parameters and the optional z parameter. A default font will be used unless a font is set with the textFont() function. Change the color of the text with the fill() function. The text displays in relation to the textAlign() function, which gives the option to draw to the left, right, and center of the coordinates.
The x2 and y2 parameters define a rectangular area to display within and may only be used with string data. For text drawn inside a rectangle, the coordinates are interpreted based on the current rectMode() setting. ( end auto-generated )- Parameters:
c- the alphanumeric character to be displayedx- x-coordinate of texty- y-coordinate of text- See Also:
textAlign(int, int),textFont(PFont),textMode(int),textSize(float),textLeading(float),textWidth(String),textAscent(),textDescent(),rectMode(int),fill(int, float)
-
text
public void text(char c, float x, float y, float z)- Parameters:
z- z-coordinate of text
-
text
public void text(String str, float x, float y)
Advanced
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)Advanced
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.- Parameters:
chars- the alphanumberic symbols to be displayedstart- array index at which to start writing charactersstop- array index at which to stop writing characters
-
text
public void text(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(String str, float x1, float y1, float x2, float y2)
Advanced
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.- Parameters:
x1- by default, the x-coordinate of text, see rectMode() for more infoy1- by default, the y-coordinate of text, see rectMode() for more infox2- by default, the width of the text box, see rectMode() for more infoy2- by default, the height of the text box, see rectMode() for more info
-
textSentence
protected boolean textSentence(char[] buffer, int start, int stop, float boxWidth, float spaceWidth)Emit a sentence of text, defined as a chunk of text without any newlines.- Parameters:
stop- non-inclusive, the end of the text in question- Returns:
- false if cannot fit
-
textSentenceBreak
protected void textSentenceBreak(int start, int stop)
-
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.- Parameters:
num- the numeric value to be displayed
-
text
public void text(float num, float x, float y, float z)
-
textLineAlignImpl
protected void textLineAlignImpl(char[] buffer, int start, int stop, float x, float y)Handles placement of a text line, then calls textLineImpl to actually render at the specific point.
-
textLineImpl
protected void textLineImpl(char[] buffer, int start, int stop, float x, float y)Implementation of actual drawing for a line of text.
-
textCharImpl
protected void textCharImpl(char ch, float x, float y)
-
textCharModelImpl
protected void textCharModelImpl(PImage glyph, float x1, float y1, float x2, float y2, int u2, int v2)
-
push
public void push()
( begin auto-generated from push.xml ) The push() function saves the current drawing style settings and transformations, while pop() restores these settings. Note that these functions are always used together. They allow you to change the style and transformation settings and later return to what you had. When a new state is started with push(), it builds on the current style and transform information.
push() stores information related to the current transformation state and style settings controlled by the following functions: rotate(), translate(), scale(), fill(), stroke(), tint(), strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), colorMode(), textAlign(), textFont(), textMode(), textSize(), textLeading().
The push() and pop() functions were added with Processing 3.5. They can be used in place of pushMatrix(), popMatrix(), pushStyles(), and popStyles(). The difference is that push() and pop() control both the transformations (rotate, scale, translate) and the drawing styles at the same time. ( end auto-generated )- See Also:
pop()
-
pop
public void pop()
( begin auto-generated from pop.xml ) The pop() function restores the previous drawing style settings and transformations after push() has changed them. Note that these functions are always used together. They allow you to change the style and transformation settings and later return to what you had. When a new state is started with push(), it builds on the current style and transform information.
push() stores information related to the current transformation state and style settings controlled by the following functions: rotate(), translate(), scale(), fill(), stroke(), tint(), strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), colorMode(), textAlign(), textFont(), textMode(), textSize(), textLeading().
The push() and pop() functions were added with Processing 3.5. They can be used in place of pushMatrix(), popMatrix(), pushStyles(), and popStyles(). The difference is that push() and pop() control both the transformations (rotate, scale, translate) and the drawing styles at the same time. ( end auto-generated )- See Also:
push()
-
pushMatrix
public void pushMatrix()
( begin auto-generated from pushMatrix.xml ) Pushes the current transformation matrix onto the matrix stack. Understanding pushMatrix() and popMatrix() requires understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate system to the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are used in conjuction with the other transformation functions and may be embedded to control the scope of the transformations. ( end auto-generated )
-
popMatrix
public void popMatrix()
( begin auto-generated from popMatrix.xml ) Pops the current transformation matrix off the matrix stack. Understanding pushing and popping requires understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate system to the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are used in conjuction with the other transformation functions and may be embedded to control the scope of the transformations. ( end auto-generated )- See Also:
pushMatrix()
-
translate
public void translate(float x, float y)( begin auto-generated from translate.xml ) Specifies an amount to displace objects within the display window. The x parameter specifies left/right translation, the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. Using this function with the z parameter requires using P3D as a parameter in combination with size as shown in the above example. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). If translate() is called within draw(), the transformation is reset when the loop begins again. This function can be further controlled by the pushMatrix() and popMatrix(). ( end auto-generated )- Parameters:
x- left/right translationy- up/down translation- See Also:
popMatrix(),pushMatrix(),rotate(float),rotateX(float),rotateY(float),rotateZ(float),scale(float, float, float)
-
translate
public void translate(float x, float y, float z)- Parameters:
z- forward/backward translation
-
rotate
public void rotate(float angle)
( begin auto-generated from rotate.xml ) Rotates a shape the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() function.
Objects are always rotated around their relative position to the origin and positive numbers rotate objects in a clockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). All tranformations are reset when draw() begins again.
Technically, rotate() multiplies the current transformation matrix by a rotation matrix. This function can be further controlled by the pushMatrix() and popMatrix(). ( end auto-generated )- Parameters:
angle- angle of rotation specified in radians- See Also:
popMatrix(),pushMatrix(),rotateX(float),rotateY(float),rotateZ(float),scale(float, float, float),PApplet.radians(float)
-
rotateX
public void rotateX(float angle)
( begin auto-generated from rotateX.xml ) Rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always rotated around their relative position to the origin and positive numbers rotate objects in a counterclockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling rotateX(PI/2) and then rotateX(PI/2) is the same as rotateX(PI). If rotateX() is called within the draw(), the transformation is reset when the loop begins again. This function requires using P3D as a third parameter to size() as shown in the example above. ( end auto-generated )- Parameters:
angle- angle of rotation specified in radians- See Also:
popMatrix(),pushMatrix(),rotate(float),rotateY(float),rotateZ(float),scale(float, float, float),translate(float, float, float)
-
rotateY
public void rotateY(float angle)
( begin auto-generated from rotateY.xml ) Rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always rotated around their relative position to the origin and positive numbers rotate objects in a counterclockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling rotateY(PI/2) and then rotateY(PI/2) is the same as rotateY(PI). If rotateY() is called within the draw(), the transformation is reset when the loop begins again. This function requires using P3D as a third parameter to size() as shown in the examples above. ( end auto-generated )- Parameters:
angle- angle of rotation specified in radians- See Also:
popMatrix(),pushMatrix(),rotate(float),rotateX(float),rotateZ(float),scale(float, float, float),translate(float, float, float)
-
rotateZ
public void rotateZ(float angle)
( begin auto-generated from rotateZ.xml ) Rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always rotated around their relative position to the origin and positive numbers rotate objects in a counterclockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling rotateZ(PI/2) and then rotateZ(PI/2) is the same as rotateZ(PI). If rotateZ() is called within the draw(), the transformation is reset when the loop begins again. This function requires using P3D as a third parameter to size() as shown in the examples above. ( end auto-generated )- Parameters:
angle- angle of rotation specified in radians- See Also:
popMatrix(),pushMatrix(),rotate(float),rotateX(float),rotateY(float),scale(float, float, float),translate(float, float, float)
-
rotate
public void rotate(float angle, float x, float y, float z)Advanced
Rotate about a vector in space. Same as the glRotatef() function.- Parameters:
x-y-z-
-
scale
public void scale(float s)
( begin auto-generated from scale.xml ) Increases or decreases the size of a shape by expanding and contracting vertices. Objects always scale from their relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the function call scale(2.0) increases the dimension of a shape by 200%. Transformations apply to everything that happens after and subsequent calls to the function multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0). If scale() is called within draw(), the transformation is reset when the loop begins again. Using this fuction with the z parameter requires using P3D as a parameter for size() as shown in the example above. This function can be further controlled by pushMatrix() and popMatrix(). ( end auto-generated )- Parameters:
s- percentage to scale the object- See Also:
pushMatrix(),popMatrix(),translate(float, float, float),rotate(float),rotateX(float),rotateY(float),rotateZ(float)
-
scale
public void scale(float x, float y)Advanced
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.- Parameters:
x- percentage to scale the object in the x-axisy- percentage to scale the object in the y-axis
-
scale
public void scale(float x, float y, float z)- Parameters:
z- percentage to scale the object in the z-axis
-
shearX
public void shearX(float angle)
( begin auto-generated from shearX.xml ) Shears a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always sheared around their relative position to the origin and positive numbers shear objects in a clockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling shearX(PI/2) and then shearX(PI/2) is the same as shearX(PI). If shearX() is called within the draw(), the transformation is reset when the loop begins again.
Technically, shearX() multiplies the current transformation matrix by a rotation matrix. This function can be further controlled by the pushMatrix() and popMatrix() functions. ( end auto-generated )- Parameters:
angle- angle of shear specified in radians- See Also:
popMatrix(),pushMatrix(),shearY(float),scale(float, float, float),translate(float, float, float),PApplet.radians(float)
-
shearY
public void shearY(float angle)
( begin auto-generated from shearY.xml ) Shears a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always sheared around their relative position to the origin and positive numbers shear objects in a clockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling shearY(PI/2) and then shearY(PI/2) is the same as shearY(PI). If shearY() is called within the draw(), the transformation is reset when the loop begins again.
Technically, shearY() multiplies the current transformation matrix by a rotation matrix. This function can be further controlled by the pushMatrix() and popMatrix() functions. ( end auto-generated )- Parameters:
angle- angle of shear specified in radians- See Also:
popMatrix(),pushMatrix(),shearX(float),scale(float, float, float),translate(float, float, float),PApplet.radians(float)
-
resetMatrix
public void resetMatrix()
( begin auto-generated from resetMatrix.xml ) Replaces the current matrix with the identity matrix. The equivalent function in OpenGL is glLoadIdentity(). ( end auto-generated )- See Also:
pushMatrix(),popMatrix(),applyMatrix(PMatrix),printMatrix()
-
applyMatrix
public void applyMatrix(PMatrix source)
( begin auto-generated from applyMatrix.xml ) Multiplies the current matrix by the one specified through the parameters. This is very slow because it will try to calculate the inverse of the transform, so avoid it whenever possible. The equivalent function in OpenGL is glMultMatrix(). ( end auto-generated )- See Also:
pushMatrix(),popMatrix(),resetMatrix(),printMatrix()
-
applyMatrix
public void applyMatrix(PMatrix2D source)
-
applyMatrix
public void applyMatrix(float n00, float n01, float n02, float n10, float n11, float n12)- Parameters:
n00- numbers which define the 4x4 matrix to be multipliedn01- numbers which define the 4x4 matrix to be multipliedn02- numbers which define the 4x4 matrix to be multipliedn10- numbers which define the 4x4 matrix to be multipliedn11- numbers which define the 4x4 matrix to be multipliedn12- numbers which define the 4x4 matrix to be multiplied
-
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)- Parameters:
n03- numbers which define the 4x4 matrix to be multipliedn13- numbers which define the 4x4 matrix to be multipliedn20- numbers which define the 4x4 matrix to be multipliedn21- numbers which define the 4x4 matrix to be multipliedn22- numbers which define the 4x4 matrix to be multipliedn23- numbers which define the 4x4 matrix to be multipliedn30- numbers which define the 4x4 matrix to be multipliedn31- numbers which define the 4x4 matrix to be multipliedn32- numbers which define the 4x4 matrix to be multipliedn33- numbers which define the 4x4 matrix to be multiplied
-
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()
( begin auto-generated from printMatrix.xml ) Prints the current matrix to the Console (the text window at the bottom of Processing). ( end auto-generated )- See Also:
pushMatrix(),popMatrix(),resetMatrix(),applyMatrix(PMatrix)
-
beginCamera
public void beginCamera()
( begin auto-generated from beginCamera.xml ) The beginCamera() and endCamera() functions enable advanced customization of the camera space. The functions are useful if you want to more control over camera movement, however for most users, the camera() function will be sufficient.
The camera functions will replace any transformations (such as rotate() or translate()) that occur before them in draw(), but they will not automatically replace the camera transform itself. For this reason, camera functions should be placed at the beginning of draw() (so that transformations happen afterwards), and the camera() function can be used after beginCamera() if you want to reset the camera before applying transformations.
This function sets the matrix mode to the camera matrix so calls such as translate(), rotate(), applyMatrix() and resetMatrix() affect the camera. beginCamera() should always be used with a following endCamera() and pairs of beginCamera() and endCamera() cannot be nested. ( end auto-generated )
-
endCamera
public void endCamera()
( begin auto-generated from endCamera.xml ) The beginCamera() and endCamera() functions enable advanced customization of the camera space. Please see the reference for beginCamera() for a description of how the functions are used. ( end auto-generated )
-
camera
public void camera()
( begin auto-generated from camera.xml ) Sets the position of the camera through setting the eye position, the center of the scene, and which axis is facing upward. Moving the eye position and the direction it is pointing (the center of the scene) allows the images to be seen from different angles. The version without any parameters sets the camera to the default position, pointing to the center of the display window with the Y axis as up. The default values are camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0). This function is similar to gluLookAt() in OpenGL, but it first clears the current camera settings. ( end auto-generated )
-
camera
public void camera(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)- Parameters:
eyeX- x-coordinate for the eyeeyeY- y-coordinate for the eyeeyeZ- z-coordinate for the eyecenterX- x-coordinate for the center of the scenecenterY- y-coordinate for the center of the scenecenterZ- z-coordinate for the center of the sceneupX- usually 0.0, 1.0, or -1.0upY- usually 0.0, 1.0, or -1.0upZ- usually 0.0, 1.0, or -1.0
-
printCamera
public void printCamera()
( begin auto-generated from printCamera.xml ) Prints the current camera matrix to the Console (the text window at the bottom of Processing). ( end auto-generated )
-
ortho
public void ortho()
( begin auto-generated from ortho.xml ) Sets an orthographic projection and defines a parallel clipping volume. All objects with the same dimension appear the same size, regardless of whether they are near or far from the camera. The parameters to this function specify the clipping volume where left and right are the minimum and maximum x values, top and bottom are the minimum and maximum y values, and near and far are the minimum and maximum z values. If no parameters are given, the default is used: ortho(0, width, 0, height, -10, 10). ( end auto-generated )
-
ortho
public void ortho(float left, float right, float bottom, float top)- Parameters:
left- left plane of the clipping volumeright- right plane of the clipping volumebottom- bottom plane of the clipping volumetop- top plane of the clipping volume
-
ortho
public void ortho(float left, float right, float bottom, float top, float near, float far)- Parameters:
near- maximum distance from the origin to the viewerfar- maximum distance from the origin away from the viewer
-
perspective
public void perspective()
( begin auto-generated from perspective.xml ) Sets a perspective projection applying foreshortening, making distant objects appear smaller than closer ones. The parameters define a viewing volume with the shape of truncated pyramid. Objects near to the front of the volume appear their actual size, while farther objects appear smaller. This projection simulates the perspective of the world more accurately than orthographic projection. The version of perspective without parameters sets the default perspective and the version with four parameters allows the programmer to set the area precisely. The default values are: perspective(PI/3.0, width/height, cameraZ/10.0, cameraZ*10.0) where cameraZ is ((height/2.0) / tan(PI*60.0/360.0)); ( end auto-generated )
-
perspective
public void perspective(float fovy, float aspect, float zNear, float zFar)- Parameters:
fovy- field-of-view angle (in radians) for vertical directionaspect- ratio of width to heightzNear- z-position of nearest clipping planezFar- z-position of farthest clipping plane
-
frustum
public void frustum(float left, float right, float bottom, float top, float near, float far)( begin auto-generated from frustum.xml ) Sets a perspective matrix defined through the parameters. Works like glFrustum, except it wipes out the current perspective matrix rather than muliplying itself with it. ( end auto-generated )- Parameters:
left- left coordinate of the clipping planeright- right coordinate of the clipping planebottom- bottom coordinate of the clipping planetop- top coordinate of the clipping planenear- near component of the clipping plane; must be greater than zerofar- far component of the clipping plane; must be greater than the near value- See Also:
camera(float, float, float, float, float, float, float, float, float),beginCamera(),endCamera(),perspective(float, float, float, float)
-
printProjection
public void printProjection()
( begin auto-generated from printProjection.xml ) Prints the current projection matrix to the Console (the text window at the bottom of Processing). ( end auto-generated )
-
screenX
public float screenX(float x, float y)( begin auto-generated from screenX.xml ) Takes a three-dimensional X, Y, Z position and returns the X value for where it will appear on a (two-dimensional) screen. ( end auto-generated )- Parameters:
x- 3D x-coordinate to be mappedy- 3D y-coordinate to be mapped- See Also:
screenY(float, float, float),screenZ(float, float, float)
-
screenY
public float screenY(float x, float y)( begin auto-generated from screenY.xml ) Takes a three-dimensional X, Y, Z position and returns the Y value for where it will appear on a (two-dimensional) screen. ( end auto-generated )- Parameters:
x- 3D x-coordinate to be mappedy- 3D y-coordinate to be mapped- See Also:
screenX(float, float, float),screenZ(float, float, float)
-
screenX
public float screenX(float x, float y, float z)- Parameters:
z- 3D z-coordinate to be mapped
-
screenY
public float screenY(float x, float y, float z)- Parameters:
z- 3D z-coordinate to be mapped
-
screenZ
public float screenZ(float x, float y, float z)( begin auto-generated from screenZ.xml ) Takes a three-dimensional X, Y, Z position and returns the Z value for where it will appear on a (two-dimensional) screen. ( end auto-generated )- Parameters:
x- 3D x-coordinate to be mappedy- 3D y-coordinate to be mappedz- 3D z-coordinate to be mapped- See Also:
screenX(float, float, float),screenY(float, float, float)
-
modelX
public float modelX(float x, float y, float z)( begin auto-generated from modelX.xml ) Returns the three-dimensional X, Y, Z position in model space. This returns the X value for a given coordinate based on the current set of transformations (scale, rotate, translate, etc.) The X value can be used to place an object in space relative to the location of the original point once the transformations are no longer in use.
In the example, the modelX(), modelY(), and modelZ() functions record the location of a box in space after being placed using a series of translate and rotate commands. After popMatrix() is called, those transformations no longer apply, but the (x, y, z) coordinate returned by the model functions is used to place another box in the same location. ( end auto-generated )- Parameters:
x- 3D x-coordinate to be mappedy- 3D y-coordinate to be mappedz- 3D z-coordinate to be mapped- See Also:
modelY(float, float, float),modelZ(float, float, float)
-
modelY
public float modelY(float x, float y, float z)( begin auto-generated from modelY.xml ) Returns the three-dimensional X, Y, Z position in model space. This returns the Y value for a given coordinate based on the current set of transformations (scale, rotate, translate, etc.) The Y value can be used to place an object in space relative to the location of the original point once the transformations are no longer in use.
In the example, the modelX(), modelY(), and modelZ() functions record the location of a box in space after being placed using a series of translate and rotate commands. After popMatrix() is called, those transformations no longer apply, but the (x, y, z) coordinate returned by the model functions is used to place another box in the same location. ( end auto-generated )- Parameters:
x- 3D x-coordinate to be mappedy- 3D y-coordinate to be mappedz- 3D z-coordinate to be mapped- See Also:
modelX(float, float, float),modelZ(float, float, float)
-
modelZ
public float modelZ(float x, float y, float z)( begin auto-generated from modelZ.xml ) Returns the three-dimensional X, Y, Z position in model space. This returns the Z value for a given coordinate based on the current set of transformations (scale, rotate, translate, etc.) The Z value can be used to place an object in space relative to the location of the original point once the transformations are no longer in use.
In the example, the modelX(), modelY(), and modelZ() functions record the location of a box in space after being placed using a series of translate and rotate commands. After popMatrix() is called, those transformations no longer apply, but the (x, y, z) coordinate returned by the model functions is used to place another box in the same location. ( end auto-generated )- Parameters:
x- 3D x-coordinate to be mappedy- 3D y-coordinate to be mappedz- 3D z-coordinate to be mapped- See Also:
modelX(float, float, float),modelY(float, float, float)
-
pushStyle
public void pushStyle()
( begin auto-generated from pushStyle.xml ) The pushStyle() function saves the current style settings and popStyle() restores the prior settings. Note that these functions are always used together. They allow you to change the style settings and later return to what you had. When a new style is started with pushStyle(), it builds on the current style information. The pushStyle() and popStyle() functions can be embedded to provide more control (see the second example above for a demonstration.)
The style information controlled by the following functions are included in the style: fill(), stroke(), tint(), strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), shapeMode(), colorMode(), textAlign(), textFont(), textMode(), textSize(), textLeading(), emissive(), specular(), shininess(), ambient() ( end auto-generated )- See Also:
popStyle()
-
popStyle
public void popStyle()
( begin auto-generated from popStyle.xml ) The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these functions are always used together. They allow you to change the style settings and later return to what you had. When a new style is started with pushStyle(), it builds on the current style information. The pushStyle() and popStyle() functions can be embedded to provide more control (see the second example above for a demonstration.) ( end auto-generated )- See Also:
pushStyle()
-
style
public void style(PStyle s)
-
getStyle
public PStyle getStyle()
-
strokeWeight
public void strokeWeight(float weight)
( begin auto-generated from strokeWeight.xml ) Sets the width of the stroke used for lines, points, and the border around shapes. All widths are set in units of pixels.
When drawing with P3D, series of connected lines (such as the stroke around a polygon, triangle, or ellipse) produce unattractive results when a thick stroke weight is set (see Issue 123). With P3D, the minimum and maximum values for strokeWeight() are controlled by the graphics card and the operating system's OpenGL implementation. For instance, the thickness may not go higher than 10 pixels. ( end auto-generated )- Parameters:
weight- the weight (in pixels) of the stroke- See Also:
stroke(int, float),strokeJoin(int),strokeCap(int)
-
strokeJoin
public void strokeJoin(int join)
( begin auto-generated from strokeJoin.xml ) Sets the style of the joints which connect line segments. These joints are either mitered, beveled, or rounded and specified with the corresponding parameters MITER, BEVEL, and ROUND. The default joint is MITER.
This function is not available with the P3D renderer, (see Issue 123). More information about the renderers can be found in the size() reference. ( end auto-generated )- Parameters:
join- either MITER, BEVEL, ROUND- See Also:
stroke(int, float),strokeWeight(float),strokeCap(int)
-
strokeCap
public void strokeCap(int cap)
( begin auto-generated from strokeCap.xml ) Sets the style for rendering line endings. These ends are either squared, extended, or rounded and specified with the corresponding parameters SQUARE, PROJECT, and ROUND. The default cap is ROUND.
This function is not available with the P3D renderer (see Issue 123). More information about the renderers can be found in the size() reference. ( end auto-generated )- Parameters:
cap- either SQUARE, PROJECT, or ROUND- See Also:
stroke(int, float),strokeWeight(float),strokeJoin(int),PApplet.size(int, int, String, String)
-
noStroke
public void noStroke()
( begin auto-generated from noStroke.xml ) Disables drawing the stroke (outline). If both noStroke() and noFill() are called, nothing will be drawn to the screen. ( end auto-generated )
-
stroke
public void stroke(int rgb)
( begin auto-generated from stroke.xml ) Sets the color used to draw lines and borders around shapes. This color is either specified in terms of the RGB or HSB color depending on the current colorMode() (the default color space is RGB, with each value in the range from 0 to 255).
When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.
The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255. ( end auto-generated )- Parameters:
rgb- color value in hexadecimal notation- See Also:
noStroke(),strokeWeight(float),strokeJoin(int),strokeCap(int),fill(int, float),noFill(),tint(int, float),background(float, float, float, float),colorMode(int, float, float, float, float)
-
stroke
public void stroke(int rgb, float alpha)- Parameters:
alpha- opacity of the stroke
-
stroke
public void stroke(float gray)
- Parameters:
gray- specifies a value between white and black
-
stroke
public void stroke(float gray, float alpha)
-
stroke
public void stroke(float v1, float v2, float v3)- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)
-
stroke
public void stroke(float v1, float v2, float v3, float alpha)
-
strokeFromCalc
protected void strokeFromCalc()
-
noTint
public void noTint()
( begin auto-generated from noTint.xml ) Removes the current fill value for displaying images and reverts to displaying images with their original hues. ( end auto-generated )
-
tint
public void tint(int rgb)
( begin auto-generated from tint.xml ) Sets the fill value for displaying images. Images can be tinted to specified colors or made transparent by setting the alpha.
To make an image transparent, but not change it's color, use white as the tint color and specify an alpha value. For instance, tint(255, 128) will make an image 50% transparent (unless colorMode() has been used).
When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.
The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.
The tint() function is also used to control the coloring of textures in 3D. ( end auto-generated )- Parameters:
rgb- color value in hexadecimal notation- See Also:
noTint(),image(PImage, float, float, float, float)
-
tint
public void tint(int rgb, float alpha)- Parameters:
alpha- opacity of the image
-
tint
public void tint(float gray)
- Parameters:
gray- specifies a value between white and black
-
tint
public void tint(float gray, float alpha)
-
tint
public void tint(float v1, float v2, float v3)- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)
-
tint
public void tint(float v1, float v2, float v3, float alpha)
-
tintFromCalc
protected void tintFromCalc()
-
noFill
public void noFill()
( begin auto-generated from noFill.xml ) Disables filling geometry. If both noStroke() and noFill() are called, nothing will be drawn to the screen. ( end auto-generated )
-
fill
public void fill(int rgb)
( begin auto-generated from fill.xml ) Sets the color used to fill shapes. For example, if you run fill(204, 102, 0), all subsequent shapes will be filled with orange. This color is either specified in terms of the RGB or HSB color depending on the current colorMode() (the default color space is RGB, with each value in the range from 0 to 255).
When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.
The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.
To change the color of an image (or a texture), use tint(). ( end auto-generated )- Parameters:
rgb- color variable or hex value- See Also:
noFill(),stroke(int, float),noStroke(),tint(int, float),background(float, float, float, float),colorMode(int, float, float, float, float)
-
fill
public void fill(int rgb, float alpha)- Parameters:
alpha- opacity of the fill
-
fill
public void fill(float gray)
- Parameters:
gray- number specifying value between white and black
-
fill
public void fill(float gray, float alpha)
-
fill
public void fill(float v1, float v2, float v3)- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)
-
fill
public void fill(float v1, float v2, float v3, float alpha)
-
fillFromCalc
protected void fillFromCalc()
-
ambient
public void ambient(int rgb)
( begin auto-generated from ambient.xml ) Sets the ambient reflectance for shapes drawn to the screen. This is combined with the ambient light component of environment. The color components set through the parameters define the reflectance. For example in the default color mode, setting v1=255, v2=126, v3=0, would cause all the red light to reflect and half of the green light to reflect. Used in combination with emissive(), specular(), and shininess() in setting the material properties of shapes. ( end auto-generated )- Parameters:
rgb- any value of the color datatype- See Also:
emissive(float, float, float),specular(float, float, float),shininess(float)
-
ambient
public void ambient(float gray)
- Parameters:
gray- number specifying value between white and black
-
ambient
public void ambient(float v1, float v2, float v3)- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)
-
ambientFromCalc
protected void ambientFromCalc()
-
specular
public void specular(int rgb)
( begin auto-generated from specular.xml ) Sets the specular color of the materials used for shapes drawn to the screen, which sets the color of hightlights. Specular refers to light which bounces off a surface in a perferred direction (rather than bouncing in all directions like a diffuse light). Used in combination with emissive(), ambient(), and shininess() in setting the material properties of shapes. ( end auto-generated )- Parameters:
rgb- color to set- See Also:
lightSpecular(float, float, float),ambient(float, float, float),emissive(float, float, float),shininess(float)
-
specular
public void specular(float gray)
gray number specifying value between white and black
-
specular
public void specular(float v1, float v2, float v3)- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)
-
specularFromCalc
protected void specularFromCalc()
-
shininess
public void shininess(float shine)
( begin auto-generated from shininess.xml ) Sets the amount of gloss in the surface of shapes. Used in combination with ambient(), specular(), and emissive() in setting the material properties of shapes. ( end auto-generated )- Parameters:
shine- degree of shininess- See Also:
emissive(float, float, float),ambient(float, float, float),specular(float, float, float)
-
emissive
public void emissive(int rgb)
( begin auto-generated from emissive.xml ) Sets the emissive color of the material used for drawing shapes drawn to the screen. Used in combination with ambient(), specular(), and shininess() in setting the material properties of shapes. ( end auto-generated )- Parameters:
rgb- color to set- See Also:
ambient(float, float, float),specular(float, float, float),shininess(float)
-
emissive
public void emissive(float gray)
gray number specifying value between white and black
-
emissive
public void emissive(float v1, float v2, float v3)- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)
-
emissiveFromCalc
protected void emissiveFromCalc()
-
lights
public void lights()
( begin auto-generated from lights.xml ) Sets the default ambient light, directional light, falloff, and specular values. The defaults are ambientLight(128, 128, 128) and directionalLight(128, 128, 128, 0, 0, -1), lightFalloff(1, 0, 0), and lightSpecular(0, 0, 0). Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop. ( end auto-generated )
-
noLights
public void noLights()
( begin auto-generated from noLights.xml ) Disable all lighting. Lighting is turned off by default and enabled with the lights() function. This function can be used to disable lighting so that 2D geometry (which does not require lighting) can be drawn after a set of lighted 3D geometry. ( end auto-generated )- See Also:
lights()
-
ambientLight
public void ambientLight(float v1, float v2, float v3)( begin auto-generated from ambientLight.xml ) Adds an ambient light. Ambient light doesn't come from a specific direction, the rays have light have bounced around so much that objects are evenly lit from all sides. Ambient lights are almost always used in combination with other types of lights. Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop. The effect of the parameters is determined by the current color mode. ( end auto-generated )- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)- See Also:
lights(),directionalLight(float, float, float, float, float, float),pointLight(float, float, float, float, float, float),spotLight(float, float, float, float, float, float, float, float, float, float, float)
-
ambientLight
public void ambientLight(float v1, float v2, float v3, float x, float y, float z)- Parameters:
x- x-coordinate of the lighty- y-coordinate of the lightz- z-coordinate of the light
-
directionalLight
public void directionalLight(float v1, float v2, float v3, float nx, float ny, float nz)( begin auto-generated from directionalLight.xml ) Adds a directional light. Directional light comes from one direction and is stronger when hitting a surface squarely and weaker if it hits at a a gentle angle. After hitting a surface, a directional lights scatters in all directions. Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop. The affect of the v1, v2, and v3 parameters is determined by the current color mode. The nx, ny, and nz parameters specify the direction the light is facing. For example, setting ny to -1 will cause the geometry to be lit from below (the light is facing directly upward). ( end auto-generated )- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)nx- direction along the x-axisny- direction along the y-axisnz- direction along the z-axis- See Also:
lights(),ambientLight(float, float, float, float, float, float),pointLight(float, float, float, float, float, float),spotLight(float, float, float, float, float, float, float, float, float, float, float)
-
pointLight
public void pointLight(float v1, float v2, float v3, float x, float y, float z)( begin auto-generated from pointLight.xml ) Adds a point light. Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop. The affect of the v1, v2, and v3 parameters is determined by the current color mode. The x, y, and z parameters set the position of the light. ( end auto-generated )- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)x- x-coordinate of the lighty- y-coordinate of the lightz- z-coordinate of the light- See Also:
lights(),directionalLight(float, float, float, float, float, float),ambientLight(float, float, float, float, float, float),spotLight(float, float, float, float, float, float, float, float, float, float, float)
-
spotLight
public void spotLight(float v1, float v2, float v3, float x, float y, float z, float nx, float ny, float nz, float angle, float concentration)( begin auto-generated from spotLight.xml ) Adds a spot light. Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop. The affect of the v1, v2, and v3 parameters is determined by the current color mode. The x, y, and z parameters specify the position of the light and nx, ny, nz specify the direction or light. The angle parameter affects angle of the spotlight cone. ( end auto-generated )- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)x- x-coordinate of the lighty- y-coordinate of the lightz- z-coordinate of the lightnx- direction along the x axisny- direction along the y axisnz- direction along the z axisangle- angle of the spotlight coneconcentration- exponent determining the center bias of the cone- See Also:
lights(),directionalLight(float, float, float, float, float, float),pointLight(float, float, float, float, float, float),ambientLight(float, float, float, float, float, float)
-
lightFalloff
public void lightFalloff(float constant, float linear, float quadratic)( begin auto-generated from lightFalloff.xml ) Sets the falloff rates for point lights, spot lights, and ambient lights. The parameters are used to determine the falloff with the following equation:
d = distance from light position to vertex position
falloff = 1 / (CONSTANT + d * LINEAR + (d*d) * QUADRATIC)
Like fill(), it affects only the elements which are created after it in the code. The default value if LightFalloff(1.0, 0.0, 0.0). Thinking about an ambient light with a falloff can be tricky. It is used, for example, if you wanted a region of your scene to be lit ambiently one color and another region to be lit ambiently by another color, you would use an ambient light with location and falloff. You can think of it as a point light that doesn't care which direction a surface is facing. ( end auto-generated )- Parameters:
constant- constant value or determining fallofflinear- linear value for determining falloffquadratic- quadratic value for determining falloff- See Also:
lights(),ambientLight(float, float, float, float, float, float),pointLight(float, float, float, float, float, float),spotLight(float, float, float, float, float, float, float, float, float, float, float),lightSpecular(float, float, float)
-
lightSpecular
public void lightSpecular(float v1, float v2, float v3)( begin auto-generated from lightSpecular.xml ) Sets the specular color for lights. Like fill(), it affects only the elements which are created after it in the code. Specular refers to light which bounces off a surface in a perferred direction (rather than bouncing in all directions like a diffuse light) and is used for creating highlights. The specular quality of a light interacts with the specular material qualities set through the specular() and shininess() functions. ( end auto-generated )- Parameters:
v1- red or hue value (depending on current color mode)v2- green or saturation value (depending on current color mode)v3- blue or brightness value (depending on current color mode)- See Also:
specular(float, float, float),lights(),ambientLight(float, float, float, float, float, float),pointLight(float, float, float, float, float, float),spotLight(float, float, float, float, float, float, float, float, float, float, float)
-
background
public void background(int rgb)
( begin auto-generated from background.xml ) The background() function sets the color used for the background of the Processing window. The default background is light gray. In the draw() function, the background color is used to clear the display window at the beginning of each frame.
An image can also be used as the background for a sketch, however its width and height must be the same size as the sketch window. To resize an image 'b' to the size of the sketch window, use b.resize(width, height).
Images used as background will ignore the current tint() setting.
It is not possible to use transparency (alpha) in background colors with the main drawing surface, however they will work properly with createGraphics(). ( end auto-generated )Advanced
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.
- Parameters:
rgb- any value of the color datatype- See Also:
stroke(float),fill(float),tint(float),colorMode(int)
-
background
public void background(int rgb, float alpha)- Parameters:
alpha- opacity of the background
-
background
public void background(float gray)
- Parameters:
gray- specifies a value between white and black
-
background
public void background(float gray, float alpha)
-
background
public void background(float v1, float v2, float v3)- Parameters:
v1- red or hue value (depending on the current color mode)v2- green or saturation value (depending on the current color mode)v3- blue or brightness value (depending on the current color mode)
-
background
public void background(float v1, float v2, float v3, float alpha)
-
clear
public void clear()
-
backgroundFromCalc
protected void backgroundFromCalc()
-
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. Use image.filter(OPAQUE) to handle this easily.
When using 3D, this will also clear the zbuffer (if it exists).- Parameters:
image- PImage to set as background (must be same size as the sketch window)
-
backgroundImpl
protected void backgroundImpl(PImage image)
Actually set the background image. This is separated from the error handling and other semantic goofiness that is shared across renderers.
-
backgroundImpl
protected void backgroundImpl()
Actual implementation of clearing the background, now that the internal variables for background color have been set. Called by the backgroundFromCalc() method, which is what all the other background() methods call once the work is done.
-
colorMode
public void colorMode(int mode)
( begin auto-generated from colorMode.xml ) Changes the way Processing interprets color data. By default, the parameters for fill(), stroke(), background(), and color() are defined by values between 0 and 255 using the RGB color model. The colorMode() function is used to change the numerical range used for specifying colors and to switch color systems. For example, calling colorMode(RGB, 1.0) will specify that values are specified between 0 and 1. The limits for defining colors are altered by setting the parameters range1, range2, range3, and range 4. ( end auto-generated )- Parameters:
mode- Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness- See Also:
background(float),fill(float),stroke(float)
-
colorMode
public void colorMode(int mode, float max)- Parameters:
max- range for all color elements
-
colorMode
public void colorMode(int mode, float max1, float max2, float max3)- Parameters:
max1- range for the red or hue depending on the current color modemax2- range for the green or saturation depending on the current color modemax3- range for the blue or brightness depending on the current color mode
-
colorMode
public void colorMode(int mode, float max1, float max2, float max3, float maxA)- Parameters:
maxA- range for the alpha
-
colorCalc
protected void colorCalc(int rgb)
Set the fill to either a grayscale value or an ARGB int.The problem with this code is that it has to detect between these two situations automatically. This is done by checking to see if the high bits (the alpha for 0xAA000000) is set, and if not, whether the color value that follows is less than colorModeX (first param passed to colorMode).
This auto-detect would break in the following situation:
size(256, 256); for (int i = 0; i < 256; i++) { color c = color(0, 0, 0, i); stroke(c); line(i, 0, i, 256); }...on the first time through the loop, where (i == 0), since the color itself is zero (black) then it would appear indistinguishable from code that reads "fill(0)". The solution is to use the four parameter versions of stroke or fill to more directly specify the desired result.
-
colorCalc
protected void colorCalc(int rgb, float alpha)
-
colorCalc
protected void colorCalc(float gray)
-
colorCalc
protected void colorCalc(float gray, float alpha)
-
colorCalc
protected void colorCalc(float x, float y, float z)
-
colorCalc
protected void colorCalc(float x, float y, float z, float a)
-
colorCalcARGB
protected void colorCalcARGB(int argb, float alpha)Unpacks AARRGGBB color for direct use with colorCalc.Handled here with its own function since this is indepenent of the color mode.
Strangely the old version of this code ignored the alpha value. not sure if that was a bug or what.
Note, no need for a bounds check for 'argb' since it's a 32 bit number. Bounds now checked on alpha, however (rev 0225).
-
color
public final int color(int c)
-
color
public final int color(float gray)
-
color
public final int color(int c, int alpha)- Parameters:
c- can be packed ARGB or a gray in this case
-
color
public final int color(int c, float alpha)- Parameters:
c- 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 v1, int v2, int v3)
-
color
public final int color(float v1, float v2, float v3)
-
color
public final int color(int v1, int v2, int v3, int a)
-
color
public final int color(float v1, float v2, float v3, float a)
-
alpha
public final float alpha(int rgb)
( begin auto-generated from alpha.xml ) Extracts the alpha value from a color. ( end auto-generated )- Parameters:
rgb- any value of the color datatype- See Also:
red(int),green(int),blue(int),hue(int),saturation(int),brightness(int)
-
red
public final float red(int rgb)
( begin auto-generated from red.xml ) Extracts the red value from a color, scaled to match current colorMode(). This value is always returned as a float so be careful not to assign it to an int value.
The red() function is easy to use and undestand, but is slower than another technique. To achieve the same results when working in colorMode(RGB, 255), but with greater speed, use the >> (right shift) operator with a bit mask. For example, the following two lines of code are equivalent:float r1 = red(myColor);
( end auto-generated )
float r2 = myColor >> 16 & 0xFF;- Parameters:
rgb- any value of the color datatype- See Also:
green(int),blue(int),alpha(int),hue(int),saturation(int),brightness(int)
-
green
public final float green(int rgb)
( begin auto-generated from green.xml ) Extracts the green value from a color, scaled to match current colorMode(). This value is always returned as a float so be careful not to assign it to an int value.
The green() function is easy to use and undestand, but is slower than another technique. To achieve the same results when working in colorMode(RGB, 255), but with greater speed, use the >> (right shift) operator with a bit mask. For example, the following two lines of code are equivalent:float r1 = green(myColor);
( end auto-generated )
float r2 = myColor >> 8 & 0xFF;- Parameters:
rgb- any value of the color datatype- See Also:
red(int),blue(int),alpha(int),hue(int),saturation(int),brightness(int)
-
blue
public final float blue(int rgb)
( begin auto-generated from blue.xml ) Extracts the blue value from a color, scaled to match current colorMode(). This value is always returned as a float so be careful not to assign it to an int value.
The blue() function is easy to use and undestand, but is slower than another technique. To achieve the same results when working in colorMode(RGB, 255), but with greater speed, use a bit mask to remove the other color components. For example, the following two lines of code are equivalent:float r1 = blue(myColor);
( end auto-generated )
float r2 = myColor & 0xFF;- Parameters:
rgb- any value of the color datatype- See Also:
red(int),green(int),alpha(int),hue(int),saturation(int),brightness(int)
-
hue
public final float hue(int rgb)
( begin auto-generated from hue.xml ) Extracts the hue value from a color. ( end auto-generated )- Parameters:
rgb- any value of the color datatype- See Also:
red(int),green(int),blue(int),alpha(int),saturation(int),brightness(int)
-
saturation
public final float saturation(int rgb)
( begin auto-generated from saturation.xml ) Extracts the saturation value from a color. ( end auto-generated )- Parameters:
rgb- any value of the color datatype- See Also:
red(int),green(int),blue(int),alpha(int),hue(int),brightness(int)
-
brightness
public final float brightness(int rgb)
( begin auto-generated from brightness.xml ) Extracts the brightness value from a color. ( end auto-generated )- Parameters:
rgb- any value of the color datatype- See Also:
red(int),green(int),blue(int),alpha(int),hue(int),saturation(int)
-
lerpColor
public int lerpColor(int c1, int c2, float amt)( begin auto-generated from lerpColor.xml ) Calculates a color or colors between two color at a specific increment. The amt parameter is the amount to interpolate between the two values where 0.0 equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. ( end auto-generated )- Parameters:
c1- interpolate from this colorc2- interpolate to this coloramt- between 0.0 and 1.0- See Also:
PImage.blendColor(int, int, int),color(float, float, float, float),PApplet.lerp(float, float, float)
-
lerpColor
public static int lerpColor(int c1, int c2, float amt, int mode)
-
beginRaw
public void beginRaw(PGraphics rawGraphics)
Record individual lines and triangles by echoing them to another renderer.
-
endRaw
public void endRaw()
-
haveRaw
public boolean haveRaw()
-
getRaw
public PGraphics getRaw()
-
showWarning
public static void showWarning(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)
-
showWarning
public static void showWarning(String msg, Object... args)
Version of showWarning() that takes a parsed String.
-
showDepthWarning
public static void showDepthWarning(String method)
Display a warning that the specified method is only available with 3D.- Parameters:
method- The method name (no parentheses)
-
showDepthWarningXYZ
public static void showDepthWarningXYZ(String method)
Display a warning that the specified method that takes x, y, z parameters can only be used with x and y parameters in this renderer.- Parameters:
method- The method name (no parentheses)
-
showMethodWarning
public static void showMethodWarning(String method)
Display a warning that the specified method is simply unavailable.
-
showVariationWarning
public static void showVariationWarning(String str)
Error that a particular variation of a method is unavailable (even though other variations are). For instance, if vertex(x, y, u, v) is not available, but vertex(x, y) is just fine.
-
showMissingWarning
public static void showMissingWarning(String method)
Display a warning that the specified method is not implemented, meaning that it could be either a completely missing function, although other variations of it may still work properly.
-
showException
public static void showException(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.
-
defaultFontOrDeath
protected void defaultFontOrDeath(String method)
Same as below, but defaults to a 12 point font, just as MacWrite intended.
-
defaultFontOrDeath
protected void defaultFontOrDeath(String method, float size)
First try to create a default font, but if that's not possible, throw an exception that halts the program because textFont() has not been used prior to the specified method.
-
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 3D drawing. Defaults to false.
-
isGL
public boolean isGL()
Return true if this renderer does rendering through OpenGL. Defaults to false.
-
is2X
public boolean is2X()
-
save
public boolean save(String filename)
Description copied from class:PImage( begin auto-generated from PImage_save.xml ) Saves the image into a file. Append a file extension to the name of the file, to indicate the file format to be used: either TIFF (.tif), TARGA (.tga), JPEG (.jpg), or PNG (.png). If no extension is included in the filename, the image will save in TIFF format and .tif will be added to the name. These files are saved to the sketch's folder, which may be opened by selecting "Show sketch folder" from the "Sketch" menu.
To save an image created within the code, rather than through loading, it's necessary to make the image with the createImage() function so it is aware of the location of the program and can therefore save the file to the right place. See the createImage() reference for more information. ( end auto-generated )Advanced
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.
-
processImageBeforeAsyncSave
protected void processImageBeforeAsyncSave(PImage image)
-
awaitAsyncSaveCompletion
protected void awaitAsyncSaveCompletion(String filename)
If there is running async save task for this file, blocks until it completes. Has to be called on main thread because OpenGL overrides this and calls GL.- Parameters:
filename-
-
-