Package processing.core
Class PShape
java.lang.Object
processing.core.PShape
- All Implemented Interfaces:
- PConstants
- Direct Known Subclasses:
- PShapeOBJ,- PShapeOpenGL,- PShapeSVG
Datatype for storing shapes. Before a shape is used, it must be loaded with
 the loadShape() or created with the createShape(). The
 shape() function is used to draw the shape to the display window.
 Processing can currently load and display SVG (Scalable Vector Graphics) and
 OBJ shapes. OBJ files can only be opened using the P3D renderer. The
 loadShape() function supports SVG files created with Inkscape and
 Adobe Illustrator. It is not a full SVG implementation, but offers some
 straightforward support for handling vector data. 
 
The PShape object contains a group of methods that can operate on the shape data. Some of the methods are listed below, but the full list used for creating and modifying shapes is available here in the Processing Javadoc.
 
To create a new shape, use the createShape() function. Do not use the syntax new PShape().
The PShape object contains a group of methods that can operate on the shape data. Some of the methods are listed below, but the full list used for creating and modifying shapes is available here in the Processing Javadoc.
To create a new shape, use the createShape() function. Do not use the syntax new PShape().
Advanced
In-progress class to handle shape data, currently to be considered of alpha or beta quality. Major structural work may be performed on this class after the release of Processing 1.0. Such changes may include:- addition of proper accessors to read shape vertex and coloring data (this is the second most important part of having a PShape class after all).
- a means of creating PShape objects ala beginShape() and endShape().
- load(), update(), and cache methods ala PImage, so that shapes can have renderer-specific optimizations, such as vertex arrays in OpenGL.
- splitting this class into multiple classes to handle different varieties of shape data (primitives vs collections of vertices vs paths)
- change of package declaration, for instance moving the code into package processing.shape (if the code grows too much).
For the time being, this class and its shape() and loadShape() friends in PApplet exist as placeholders for more exciting things to come. If you'd like to work with this class, make a subclass (see how PShapeSVG works) and you can play with its internal methods all you like.
Library developers are encouraged to create PShape objects when loading shape data, so that they can eventually hook into the bounty that will be the PShape interface, and the ease of loadShape() and shape().
- See Also:
- Usage:
- Web & Application
- 
Field SummaryFieldsModifier and TypeFieldDescriptionintThe current colorModefloatMax value for alpha set by colorModefloatMax value for red (or hue) set by colorModefloatMax value for green (or saturation) set by colorModefloatMax value for blue (or value) set by colorModefloatstatic final intCollections of vertices created with beginShape().floatThe height of the PShape document.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intA series of vertex, curveVertex, and bezierVertex calls.static final Stringstatic final intA line, ellipse, arc, image, etc.floatThe width of the PShape document.Fields inherited from interface processing.core.PConstantsADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BICUBIC, BILINEAR, 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, MACOS, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NEAREST_NEIGHBOR, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, 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 SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds a child PShape to a parent PShape that is defined as a GROUP.voidvoidAdd a shape to the name lookup table.voidambient(float gray) voidambient(float x, float y, float z) voidambient(int rgb) 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) voidapplyMatrix(PMatrix2D source) voidapplyMatrix(PMatrix3D source) voidvoidvoidvoidattribColor(String name, int color) voidattribNormal(String name, float nx, float ny, float nz) voidattribPosition(String name, float x, float y, float z) voidThe beginContour() and endContour() methods make it possible to define shapes with other shapes cut out of them.voidThis method is used to start a custom shape created with the createShape() function.voidbeginShape(int kind) voidvoidbeginTessellation(int kind) voidbezierDetail(int detail) 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) voidcolorMode(int mode) voidcolorMode(int mode, float max) voidcolorMode(int mode, float maxX, float maxY, float maxZ) voidcolorMode(int mode, float maxX, float maxY, float maxZ, float maxA) booleancontains(float x, float y) Return true if this x, y coordinate is part of this shape.voidcurveDetail(int detail) voidcurveTightness(float tightness) voidcurveVertex(float x, float y) voidcurveVertex(float x, float y, float z) voidDisables the shape's style data and uses Processing's current styles.voidCalled by the following (the shape() command adds the g) PShape s = loadShape("blah.svg"); shape(s);voidemissive(float gray) voidemissive(float x, float y, float z) voidemissive(int rgb) voidEnables the shape's style data and ignores Processing's current styles.voidThe beginContour() and endContour() methods make it possible to define shapes with other shapes cut out of them.voidendShape()This method is used to complete a custom shape created with the createShape() function.voidendShape(int mode) voidvoidfill(float gray) voidfill(float gray, float alpha) voidfill(float x, float y, float z) voidfill(float x, float y, float z, float a) voidfill(int rgb) voidfill(int rgb, float alpha) Same as getChild(name), except that it first walks all the way up the hierarchy to the eldest grandparent, so that children can be found anywhere.intgetAmbient(int index) getChild(int index) Extracts a child shape from a parent shape.intReturns the number of children within the PShape.intgetChildIndex(PShape who) Returns the index of child who.PShape[]floatgetDepth()Get the depth of the shape area (not necessarily the shape boundary).intgetEmissive(int index) intThe shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY.intgetFill(int index) floatGet the height of the drawing area (not necessarily the shape boundary).intgetKind()getName()getNormal(int index) floatgetNormalX(int index) floatgetNormalY(int index) floatgetNormalZ(int index) floatgetParam(int index) float[]float[]getParams(float[] target) floatgetShininess(int index) intgetSpecular(int index) intgetStroke(int index) floatgetStrokeWeight(int index) Returns a PShape holding the tessellated geometry of this shape, composed entirely of triangles.floatgetTextureU(int index) floatgetTextureV(int index) intgetTint(int index) getVertex(int index) The getVertex() method returns a PVector with the coordinates of the vertex point located at the position defined by the index parameter.intgetVertexCode(int index) One of VERTEX, BEZIER_VERTEX, CURVE_VERTEX, or BREAK.intint[]intintgetVertexCount(boolean includeChildren) The getVertexCount() method returns the number of vertices (with an option to count children by passing true as boolean parameter to method call) that make up a PShape.floatgetVertexX(int index) floatgetVertexY(int index) floatgetVertexZ(int index) floatgetWidth()Get the width of the drawing area (not necessarily the shape boundary).booleanis2D()Return true if this shape is 2D.booleanis3D()Return true if this shape is 3D.booleanisClosed()booleanReturns a boolean value true if the image is set to be visible, false if not.voidnoFill()voidnormal(float nx, float ny, float nz) voidnoStroke()voidvoidnoTint()voidquadraticVertex(float cx, float cy, float x3, float y3) voidquadraticVertex(float cx, float cy, float cz, float x3, float y3, float z3) voidremoveChild(int idx) Remove the child shape with index idx.voidReplaces the current matrix of a shape with the identity matrix.voidrotate(float angle) Rotates a shape the amount specified by the angle parameter.voidrotate(float angle, float v0, float v1, float v2) voidrotateX(float angle) Rotates a shape around the x-axis the amount specified by the angle parameter.voidrotateY(float angle) Rotates a shape around the y-axis the amount specified by the angle parameter.voidrotateZ(float angle) Rotates a shape around the z-axis the amount specified by the angle parameter.voidscale(float s) Increases or decreases the size of a shape by expanding and contracting vertices.voidscale(float x, float y) voidscale(float x, float y, float z) voidset3D(boolean val) voidsetAmbient(int ambient) voidsetAmbient(int index, int ambient) voidsetEmissive(int emissive) voidsetEmissive(int index, int emissive) voidsetFamily(int family) voidsetFill(boolean fill) voidsetFill(int fill) The setFill() method defines the fill color of a PShape.voidsetFill(int index, int fill) voidsetKind(int kind) voidvoidsetNormal(int index, float nx, float ny, float nz) voidsetPath(int vcount, float[][] verts) voidsetShininess(float shine) voidsetShininess(int index, float shine) voidsetSpecular(int specular) voidsetSpecular(int index, int specular) voidsetStroke(boolean stroke) voidsetStroke(int stroke) The setStroke() method defines the outline color of a PShape.voidsetStroke(int index, int stroke) voidsetStrokeCap(int cap) voidsetStrokeJoin(int join) voidsetStrokeWeight(float weight) voidsetStrokeWeight(int index, float weight) voidsetTexture(PImage tex) voidsetTextureMode(int mode) voidsetTextureUV(int index, float u, float v) voidsetTint(boolean tint) voidsetTint(int fill) voidsetTint(int index, int tint) voidsetVertex(int index, float x, float y) The setVertex() method defines the coordinates of the vertex point located at the position defined by the index parameter.voidsetVertex(int index, float x, float y, float z) voidvoidsetVisible(boolean visible) Sets the shape to be visible or invisible.voidshininess(float shine) voidspecular(float gray) voidspecular(float x, float y, float z) voidspecular(int rgb) voidstroke(float gray) voidstroke(float gray, float alpha) voidstroke(float x, float y, float z) voidstroke(float x, float y, float z, float alpha) voidstroke(int rgb) voidstroke(int rgb, float alpha) voidstrokeCap(int cap) voidstrokeJoin(int join) voidstrokeWeight(float weight) voidvoidtextureMode(int mode) voidtint(float gray) voidtint(float gray, float alpha) voidtint(float x, float y, float z) voidtint(float x, float y, float z, float alpha) voidtint(int rgb) voidtint(int rgb, float alpha) voidtranslate(float x, float y) Specifies an amount to displace the shape.voidtranslate(float x, float y, float z) 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) 
- 
Field Details- 
PRIMITIVEpublic static final int PRIMITIVEA line, ellipse, arc, image, etc.- See Also:
 
- 
PATHpublic static final int PATHA series of vertex, curveVertex, and bezierVertex calls.- See Also:
 
- 
GEOMETRYpublic static final int GEOMETRYCollections of vertices created with beginShape().- See Also:
 
- 
OUTSIDE_BEGIN_END_ERROR- See Also:
 
- 
INSIDE_BEGIN_END_ERROR- See Also:
 
- 
NO_SUCH_VERTEX_ERROR- See Also:
 
- 
NO_VERTICES_ERROR- See Also:
 
- 
NOT_A_SIMPLE_VERTEX- See Also:
 
- 
PER_VERTEX_UNSUPPORTED- See Also:
 
- 
widthpublic float widthThe width of the PShape document.- See Also:
- Usage:
- web_application
 
- 
heightpublic float heightThe height of the PShape document.- See Also:
- Usage:
- web_application
 
- 
depthpublic float depth
- 
colorModepublic int colorModeThe current colorMode
- 
colorModeXpublic float colorModeXMax value for red (or hue) set by colorMode
- 
colorModeYpublic float colorModeYMax value for green (or saturation) set by colorMode
- 
colorModeZpublic float colorModeZMax value for blue (or value) set by colorMode
- 
colorModeApublic float colorModeAMax value for alpha set by colorMode
 
- 
- 
Constructor Details- 
PShapepublic PShape()
- 
PShapepublic PShape(int family) 
- 
PShape
- 
PShape
 
- 
- 
Method Details- 
setFamilypublic void setFamily(int family) 
- 
setKindpublic void setKind(int kind) 
- 
setName
- 
getName
- 
isVisiblepublic boolean isVisible()Returns a boolean value true if the image is set to be visible, false if not. This value can be modified with the setVisible() method.
 
 The default visibility of a shape is usually controlled by whatever program created the SVG file. For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator.- See Also:
- Usage:
- web_application
 
- 
setVisiblepublic void setVisible(boolean visible) Sets the shape to be visible or invisible. This is determined by the value of the visible parameter.
 
 The default visibility of a shape is usually controlled by whatever program created the SVG file. For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator.- Parameters:
- visible- "false" makes the shape invisible and "true" makes it visible
- See Also:
- Usage:
- web_application
 
- 
disableStylepublic void disableStyle()Disables the shape's style data and uses Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints.AdvancedOverrides this shape's style information and uses PGraphics styles and colors. Identical to ignoreStyles(true). Also disables styles for all child shapes.- See Also:
- Usage:
- web_application
 
- 
enableStylepublic void enableStyle()Enables the shape's style data and ignores Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints.- See Also:
- Usage:
- web_application
 
- 
getWidthpublic float getWidth()Get the width of the drawing area (not necessarily the shape boundary).
- 
getHeightpublic float getHeight()Get the height of the drawing area (not necessarily the shape boundary).
- 
getDepthpublic float getDepth()Get the depth of the shape area (not necessarily the shape boundary). Only makes sense for 3D PShape subclasses, such as PShape3D.
- 
is2Dpublic boolean is2D()Return true if this shape is 2D. Defaults to true.
- 
is3Dpublic boolean is3D()Return true if this shape is 3D. Defaults to false.
- 
set3Dpublic void set3D(boolean val) 
- 
textureModepublic void textureMode(int mode) 
- 
texture
- 
noTexturepublic void noTexture()
- 
beginContourpublic void beginContour()The beginContour() and endContour() methods make it possible to define shapes with other shapes cut out of them. For example, the inside of a letter 'O'. These two functions are always used together, you'll never use one without the other. Between them, define the geometry you want to create. As you'll see when you run the example above, the second smaller shape is cut out of the first larger shape.
 
 The exterior shape and the interior contour must wind in opposite directions. This means that if the points of the geometry for the exterior shape are described in a clockwise order, the points on the interior shape are defined in a counterclockwise order.- See Also:
 
- 
endContourpublic void endContour()The beginContour() and endContour() methods make it possible to define shapes with other shapes cut out of them. For example, the inside of a letter 'O'. These two functions are always used together, you'll never use one without the other. Between them, define the geometry you want to create. As you'll see when you run the example above, the second smaller shape is cut out of the first larger shape.
 
 The exterior shape and the interior contour must wind in opposite directions. This means that if the points of the geometry for the exterior shape are described in a clockwise order, the points on the interior shape are defined in a counterclockwise order.- See Also:
 
- 
vertexpublic void vertex(float x, float y) 
- 
vertexpublic void vertex(float x, float y, float u, float v) 
- 
vertexpublic void vertex(float x, float y, float z) 
- 
vertexpublic void vertex(float x, float y, float z, float u, float v) 
- 
normalpublic void normal(float nx, float ny, float nz) 
- 
attribPosition
- 
attribNormal
- 
attribColor
- 
attrib
- 
attrib
- 
attrib
- 
beginShapepublic void beginShape()This method is used to start a custom shape created with the createShape() function. It's always and only used with createShape().- See Also:
 
- 
beginShapepublic void beginShape(int kind) 
- 
endShapepublic void endShape()This method is used to complete a custom shape created with the createShape() function. It's always and only used with createShape().- See Also:
 
- 
endShapepublic void endShape(int mode) 
- 
strokeWeightpublic void strokeWeight(float weight) 
- 
strokeJoinpublic void strokeJoin(int join) 
- 
strokeCappublic void strokeCap(int cap) 
- 
noFillpublic void noFill()
- 
fillpublic void fill(int rgb) 
- 
fillpublic void fill(int rgb, float alpha) 
- 
fillpublic void fill(float gray) 
- 
fillpublic void fill(float gray, float alpha) 
- 
fillpublic void fill(float x, float y, float z) 
- 
fillpublic void fill(float x, float y, float z, float a) 
- 
noStrokepublic void noStroke()
- 
strokepublic void stroke(int rgb) 
- 
strokepublic void stroke(int rgb, float alpha) 
- 
strokepublic void stroke(float gray) 
- 
strokepublic void stroke(float gray, float alpha) 
- 
strokepublic void stroke(float x, float y, float z) 
- 
strokepublic void stroke(float x, float y, float z, float alpha) 
- 
noTintpublic void noTint()
- 
tintpublic void tint(int rgb) 
- 
tintpublic void tint(int rgb, float alpha) 
- 
tintpublic void tint(float gray) 
- 
tintpublic void tint(float gray, float alpha) 
- 
tintpublic void tint(float x, float y, float z) 
- 
tintpublic void tint(float x, float y, float z, float alpha) 
- 
ambientpublic void ambient(int rgb) 
- 
ambientpublic void ambient(float gray) 
- 
ambientpublic void ambient(float x, float y, float z) 
- 
specularpublic void specular(int rgb) 
- 
specularpublic void specular(float gray) 
- 
specularpublic void specular(float x, float y, float z) 
- 
emissivepublic void emissive(int rgb) 
- 
emissivepublic void emissive(float gray) 
- 
emissivepublic void emissive(float x, float y, float z) 
- 
shininesspublic void shininess(float shine) 
- 
bezierDetailpublic void bezierDetail(int detail) 
- 
bezierVertexpublic void bezierVertex(float x2, float y2, float x3, float y3, float x4, float y4) 
- 
bezierVertexpublic void bezierVertex(float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4) 
- 
quadraticVertexpublic void quadraticVertex(float cx, float cy, float x3, float y3) 
- 
quadraticVertexpublic void quadraticVertex(float cx, float cy, float cz, float x3, float y3, float z3) 
- 
curveDetailpublic void curveDetail(int detail) 
- 
curveTightnesspublic void curveTightness(float tightness) 
- 
curveVertexpublic void curveVertex(float x, float y) 
- 
curveVertexpublic void curveVertex(float x, float y, float z) 
- 
drawCalled by the following (the shape() command adds the g) PShape s = loadShape("blah.svg"); shape(s);
- 
getParent
- 
getChildCountpublic int getChildCount()Returns the number of children within the PShape.
- 
getChildren
- 
getChildExtracts a child shape from a parent shape. Specify the name of the shape with the target parameter. The shape is returned as a PShape object, or null is returned if there is an error.- Parameters:
- index- the layer position of the shape to get
- See Also:
- Usage:
- web_application
 
- 
getChild- Parameters:
- target- the name of the shape to get
 
- 
findChildSame as getChild(name), except that it first walks all the way up the hierarchy to the eldest grandparent, so that children can be found anywhere.
- 
addChildAdds a child PShape to a parent PShape that is defined as a GROUP. In the example, the three shapes path, rectangle, and circle are added to a parent PShape variable named house that is a GROUP.- Parameters:
- who- any variable of type PShape
- See Also:
 
- 
addChild- Parameters:
- idx- the layer position in which to insert the new child
 
- 
removeChildpublic void removeChild(int idx) Remove the child shape with index idx.
- 
addNameAdd a shape to the name lookup table.
- 
getChildIndexReturns the index of child who.
- 
getTessellationReturns a PShape holding the tessellated geometry of this shape, composed entirely of triangles.
- 
beginTessellationpublic void beginTessellation()
- 
beginTessellationpublic void beginTessellation(int kind) 
- 
endTessellationpublic void endTessellation()
- 
getFamilypublic int getFamily()The shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY.
- 
getKindpublic int getKind()
- 
getParamspublic float[] getParams()
- 
getParamspublic float[] getParams(float[] target) 
- 
getParampublic float getParam(int index) 
- 
setPathpublic void setPath(int vcount, float[][] verts) 
- 
getVertexCountpublic int getVertexCount(boolean includeChildren) The getVertexCount() method returns the number of vertices (with an option to count children by passing true as boolean parameter to method call) that make up a PShape. By default, it does not count child vertices for GROUP shapes. To include child vertices, pass true as a boolean parameter. In the above example, the value 4 is returned by the getVertexCount() method because 4 vertices are defined in setup().- See Also:
 
- 
getVertexCountpublic int getVertexCount()
- 
getVertexThe getVertex() method returns a PVector with the coordinates of the vertex point located at the position defined by the index parameter. This method works when shapes are created as shown in the example above, but won't work properly when a shape is defined explicitly (e.g. createShape(RECT, 20, 20, 80, 80).- Parameters:
- index- the location of the vertex
- See Also:
 
- 
getVertex- Parameters:
- vec- PVector to assign the data to
 
- 
getVertexXpublic float getVertexX(int index) 
- 
getVertexYpublic float getVertexY(int index) 
- 
getVertexZpublic float getVertexZ(int index) 
- 
setVertexpublic void setVertex(int index, float x, float y) The setVertex() method defines the coordinates of the vertex point located at the position defined by the index parameter. This method works when shapes are created as shown in the example above, but won't work properly when a shape is defined explicitly (e.g. createShape(RECT, 20, 20, 80, 80).- Parameters:
- index- the location of the vertex
- x- the x value for the vertex
- y- the y value for the vertex
- See Also:
 
- 
setVertexpublic void setVertex(int index, float x, float y, float z) - Parameters:
- z- the z value for the vertex
 
- 
setVertex- Parameters:
- vec- the PVector to define the x, y, z coordinates
 
- 
getNormal
- 
getNormal
- 
getNormalXpublic float getNormalX(int index) 
- 
getNormalYpublic float getNormalY(int index) 
- 
getNormalZpublic float getNormalZ(int index) 
- 
setNormalpublic void setNormal(int index, float nx, float ny, float nz) 
- 
getTextureUpublic float getTextureU(int index) 
- 
getTextureVpublic float getTextureV(int index) 
- 
setTextureUVpublic void setTextureUV(int index, float u, float v) 
- 
setTextureModepublic void setTextureMode(int mode) 
- 
setTexture
- 
getFillpublic int getFill(int index) 
- 
setFillpublic void setFill(boolean fill) 
- 
setFillpublic void setFill(int fill) The setFill() method defines the fill color of a PShape. This method is used after shapes are created or when a shape is defined explicitly (e.g. createShape(RECT, 20, 20, 80, 80)) as shown in the above example. When a shape is created with beginShape() and endShape(), its attributes may be changed with fill() and stroke() within beginShape() and endShape(). However, after the shape is created, only the setFill() method can define a new fill value for the PShape.
- 
setFillpublic void setFill(int index, int fill) 
- 
getTintpublic int getTint(int index) 
- 
setTintpublic void setTint(boolean tint) 
- 
setTintpublic void setTint(int fill) 
- 
setTintpublic void setTint(int index, int tint) 
- 
getStrokepublic int getStroke(int index) 
- 
setStrokepublic void setStroke(boolean stroke) 
- 
setStrokepublic void setStroke(int stroke) The setStroke() method defines the outline color of a PShape. This method is used after shapes are created or when a shape is defined explicitly (e.g. createShape(RECT, 20, 20, 80, 80)) as shown in the above example. When a shape is created with beginShape() and endShape(), its attributes may be changed with fill() and stroke() within beginShape() and endShape(). However, after the shape is created, only the setStroke() method can define a new stroke value for the PShape.
- 
setStrokepublic void setStroke(int index, int stroke) 
- 
getStrokeWeightpublic float getStrokeWeight(int index) 
- 
setStrokeWeightpublic void setStrokeWeight(float weight) 
- 
setStrokeWeightpublic void setStrokeWeight(int index, float weight) 
- 
setStrokeJoinpublic void setStrokeJoin(int join) 
- 
setStrokeCappublic void setStrokeCap(int cap) 
- 
getAmbientpublic int getAmbient(int index) 
- 
setAmbientpublic void setAmbient(int ambient) 
- 
setAmbientpublic void setAmbient(int index, int ambient) 
- 
getSpecularpublic int getSpecular(int index) 
- 
setSpecularpublic void setSpecular(int specular) 
- 
setSpecularpublic void setSpecular(int index, int specular) 
- 
getEmissivepublic int getEmissive(int index) 
- 
setEmissivepublic void setEmissive(int emissive) 
- 
setEmissivepublic void setEmissive(int index, int emissive) 
- 
getShininesspublic float getShininess(int index) 
- 
setShininesspublic void setShininess(float shine) 
- 
setShininesspublic void setShininess(int index, float shine) 
- 
getVertexCodespublic int[] getVertexCodes()
- 
getVertexCodeCountpublic int getVertexCodeCount()
- 
getVertexCodepublic int getVertexCode(int index) One of VERTEX, BEZIER_VERTEX, CURVE_VERTEX, or BREAK.
- 
isClosedpublic boolean isClosed()
- 
containspublic boolean contains(float x, float y) Return true if this x, y coordinate is part of this shape. Only works with PATH shapes or GROUP shapes that contain other GROUPs or PATHs. This method is not imperfect and doesn't account for all cases (not all complex shapes: concave shapes or holes may have issues).
- 
translatepublic void translate(float x, float y) Specifies an amount to displace the shape. 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. Subsequent calls to the method accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
 Using this method with the z parameter requires using the P3D parameter in combination with size.- Parameters:
- x- left/right translation
- y- up/down translation
- See Also:
- Usage:
- web_application
 
- 
translatepublic void translate(float x, float y, float z) - Parameters:
- z- forward/back translation
 
- 
rotateXpublic void rotateX(float angle) Rotates a shape around the x-axis 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() method.
 Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the same as rotateX(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
 This method requires a 3D renderer. You need to use P3D as a third parameter for the size() function as shown in the example above.- Parameters:
- angle- angle of rotation specified in radians
- See Also:
- Usage:
- web_application
 
- 
rotateYpublic void rotateY(float angle) Rotates a shape around the y-axis 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() method.
 Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the same as rotateY(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
 This method requires a 3D renderer. You need to use P3D as a third parameter for the size() function as shown in the example above.- Parameters:
- angle- angle of rotation specified in radians
- See Also:
- Usage:
- web_application
 
- 
rotateZpublic void rotateZ(float angle) Rotates a shape around the z-axis 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() method.
 Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the same as rotateZ(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
 This method requires a 3D renderer. You need to use P3D as a third parameter for the size() function as shown in the example above.- Parameters:
- angle- angle of rotation specified in radians
- See Also:
- Usage:
- web_application
 
- 
rotatepublic void rotate(float angle) 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() method.
 Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.- Parameters:
- angle- angle of rotation specified in radians
- See Also:
- Usage:
- web_application
 
- 
rotatepublic void rotate(float angle, float v0, float v1, float v2) 
- 
scalepublic void scale(float s) Increases or decreases the size of a shape by expanding and contracting vertices. Shapes always scale from the relative origin of their bounding box. Scale values are specified as decimal percentages. For example, the method call scale(2.0) increases the dimension of a shape by 200%. Subsequent calls to the method multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
 Using this method with the z parameter requires using the P3D parameter in combination with size.- Parameters:
- s- percentage to scale the object
- See Also:
- Usage:
- web_application
 
- 
scalepublic void scale(float x, float y) 
- 
scalepublic void scale(float x, float y, float z) - Parameters:
- x- percentage to scale the object in the x-axis
- y- percentage to scale the object in the y-axis
- z- percentage to scale the object in the z-axis
 
- 
resetMatrixpublic void resetMatrix()Replaces the current matrix of a shape with the identity matrix. The equivalent function in OpenGL is glLoadIdentity().- See Also:
- Usage:
- web_application
 
- 
applyMatrix
- 
applyMatrix
- 
applyMatrixpublic void applyMatrix(float n00, float n01, float n02, float n10, float n11, float n12) 
- 
applyMatrix
- 
applyMatrixpublic 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) 
- 
colorModepublic void colorMode(int mode) 
- 
colorModepublic void colorMode(int mode, float max) - Parameters:
- max- range for all color elements
 
- 
colorModepublic void colorMode(int mode, float maxX, float maxY, float maxZ) - Parameters:
- maxX- range for the red or hue depending on the current color mode
- maxY- range for the green or saturation depending on the current color mode
- maxZ- range for the blue or brightness depending on the current color mode
 
- 
colorModepublic void colorMode(int mode, float maxX, float maxY, float maxZ, float maxA) - Parameters:
- maxA- range for the alpha
 
 
-