public class PShape extends java.lang.Object implements PConstants
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().
| Modifier and Type | Field and Description |
|---|---|
int |
colorMode
The current colorMode
|
float |
colorModeA
Max value for alpha set by colorMode
|
float |
colorModeX
Max value for red (or hue) set by colorMode
|
float |
colorModeY
Max value for green (or saturation) set by colorMode
|
float |
colorModeZ
Max value for blue (or value) set by colorMode
|
float |
depth |
static int |
GEOMETRY
Collections of vertices created with beginShape().
|
float |
height
( begin auto-generated from PShape_height.xml )
The height of the PShape document.
|
static int |
PATH
A series of vertex, curveVertex, and bezierVertex calls.
|
static int |
PRIMITIVE
A line, ellipse, arc, image, etc.
|
float |
width
( begin auto-generated from PShape_width.xml )
The width of the PShape document.
|
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_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, 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, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPHERE, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z| Modifier and Type | Method and Description |
|---|---|
void |
addChild(PShape who) |
void |
addChild(PShape who,
int idx) |
void |
addName(java.lang.String nom,
PShape shape)
Add a shape to the name lookup table.
|
void |
ambient(float gray) |
void |
ambient(float x,
float y,
float z) |
void |
ambient(int rgb) |
void |
applyMatrix(float n00,
float n01,
float n02,
float n10,
float n11,
float n12) |
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) |
void |
applyMatrix(PMatrix source) |
void |
applyMatrix(PMatrix2D source) |
void |
applyMatrix(PMatrix3D source) |
void |
beginContour() |
void |
bezierDetail(int detail) |
void |
bezierVertex(float x2,
float y2,
float x3,
float y3,
float x4,
float y4) |
void |
bezierVertex(float x2,
float y2,
float z2,
float x3,
float y3,
float z3,
float x4,
float y4,
float z4) |
void |
colorMode(int mode)
Set the pivot point for all transformations.
|
void |
colorMode(int mode,
float max) |
void |
colorMode(int mode,
float maxX,
float maxY,
float maxZ) |
void |
colorMode(int mode,
float maxX,
float maxY,
float maxZ,
float maxA) |
boolean |
contains(float x,
float y) |
void |
curveDetail(int detail) |
void |
curveTightness(float tightness) |
void |
curveVertex(float x,
float y) |
void |
curveVertex(float x,
float y,
float z) |
void |
disableStyle()
( begin auto-generated from PShape_disableStyle.xml )
Disables the shape's style data and uses Processing's current styles.
|
void |
draw(PGraphics g)
Called by the following (the shape() command adds the g)
PShape s = loadShape("blah.svg");
shape(s);
|
void |
drawImpl(PGraphics g)
Draws the SVG document.
|
void |
emissive(float gray) |
void |
emissive(float x,
float y,
float z) |
void |
emissive(int rgb) |
void |
enableStyle()
( begin auto-generated from PShape_enableStyle.xml )
Enables the shape's style data and ignores Processing's current styles.
|
void |
end() |
void |
end(int mode) |
void |
endContour() |
void |
fill(float gray) |
void |
fill(float gray,
float alpha) |
void |
fill(float x,
float y,
float z) |
void |
fill(float x,
float y,
float z,
float a) |
void |
fill(int rgb) |
void |
fill(int rgb,
float alpha) |
PShape |
findChild(java.lang.String target)
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.
|
PShape |
getChild(int index)
( begin auto-generated from PShape_getChild.xml )
Extracts a child shape from a parent shape.
|
PShape |
getChild(java.lang.String target) |
int |
getChildCount() |
int |
getChildIndex(PShape who)
Returns the index of child who.
|
PShape[] |
getChildren() |
float |
getDepth()
Get the depth of the shape area (not necessarily the shape boundary).
|
int |
getFamily()
The shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY.
|
int |
getFill(int index) |
float |
getHeight()
Get the height of the drawing area (not necessarily the shape boundary).
|
int |
getKind() |
java.lang.String |
getName() |
PVector |
getNormal(int index) |
PVector |
getNormal(int index,
PVector vec) |
float |
getNormalX(int index) |
float |
getNormalY(int index) |
float |
getNormalZ(int index) |
float |
getParam(int index) |
float[] |
getParams() |
float[] |
getParams(float[] target) |
PShape |
getParent() |
int |
getStroke(int index) |
PShape |
getTessellation() |
float |
getTextureU(int index) |
float |
getTextureV(int index) |
PVector |
getVertex(int index) |
PVector |
getVertex(int index,
PVector vec) |
int |
getVertexCode(int index)
One of VERTEX, BEZIER_VERTEX, CURVE_VERTEX, or BREAK.
|
int |
getVertexCodeCount() |
int[] |
getVertexCodes() |
int |
getVertexCount() |
float |
getVertexX(int index) |
float |
getVertexY(int index) |
float |
getVertexZ(int index) |
float |
getWidth()
Get the width of the drawing area (not necessarily the shape boundary).
|
boolean |
is2D()
Return true if this shape is 2D.
|
boolean |
is3D()
Return true if this shape is 3D.
|
void |
is3D(boolean val) |
boolean |
isClosed() |
boolean |
isVisible()
( begin auto-generated from PShape_isVisible.xml )
Returns a boolean value "true" if the image is set to be visible,
"false" if not.
|
void |
noFill() |
void |
normal(float nx,
float ny,
float nz) |
void |
noStroke() |
void |
noTexture() |
void |
noTint() |
void |
quadraticVertex(float cx,
float cy,
float x3,
float y3) |
void |
quadraticVertex(float cx,
float cy,
float cz,
float x3,
float y3,
float z3) |
void |
removeChild(int idx)
Remove the child shape with index idx.
|
void |
resetMatrix()
( begin auto-generated from PShape_resetMatrix.xml )
Replaces the current matrix of a shape with the identity matrix.
|
void |
rotate(float angle)
( begin auto-generated from PShape_rotate.xml )
Rotates a shape the amount specified by the angle parameter.
|
void |
rotate(float angle,
float v0,
float v1,
float v2) |
void |
rotateX(float angle)
( begin auto-generated from PShape_rotateX.xml )
Rotates a shape around the x-axis the amount specified by the
angle parameter.
|
void |
rotateY(float angle)
( begin auto-generated from PShape_rotateY.xml )
Rotates a shape around the y-axis the amount specified by the
angle parameter.
|
void |
rotateZ(float angle)
( begin auto-generated from PShape_rotateZ.xml )
Rotates a shape around the z-axis the amount specified by the
angle parameter.
|
void |
scale(float s)
( begin auto-generated from PShape_scale.xml )
Increases or decreases the size of a shape by expanding and contracting
vertices.
|
void |
scale(float x,
float y) |
void |
scale(float x,
float y,
float z) |
void |
setFill(int index,
int fill) |
void |
setKind(int kind) |
void |
setName(java.lang.String name) |
void |
setNormal(int index,
float nx,
float ny,
float nz) |
void |
setPath(int vcount,
float[][] verts) |
void |
setStroke(int index,
int stroke) |
void |
setTextureUV(int index,
float u,
float v) |
void |
setVertex(int index,
float x,
float y) |
void |
setVertex(int index,
float x,
float y,
float z) |
void |
setVertex(int index,
PVector vec) |
void |
setVisible(boolean visible)
( begin auto-generated from PShape_setVisible.xml )
Sets the shape to be visible or invisible.
|
void |
shininess(float shine) |
void |
specular(float gray) |
void |
specular(float x,
float y,
float z) |
void |
specular(int rgb) |
void |
stroke(float gray) |
void |
stroke(float gray,
float alpha) |
void |
stroke(float x,
float y,
float z) |
void |
stroke(float x,
float y,
float z,
float alpha) |
void |
stroke(int rgb) |
void |
stroke(int rgb,
float alpha) |
void |
strokeCap(int cap) |
void |
strokeJoin(int join) |
void |
strokeWeight(float weight) |
void |
texture(PImage tex) |
void |
tint(float gray) |
void |
tint(float gray,
float alpha) |
void |
tint(float x,
float y,
float z) |
void |
tint(float x,
float y,
float z,
float alpha) |
void |
tint(int rgb) |
void |
tint(int rgb,
float alpha) |
void |
translate(float x,
float y)
( begin auto-generated from PShape_translate.xml )
Specifies an amount to displace the shape.
|
void |
translate(float x,
float y,
float z) |
void |
vertex(float x,
float y) |
void |
vertex(float x,
float y,
float z) |
void |
vertex(float x,
float y,
float u,
float v) |
void |
vertex(float x,
float y,
float z,
float u,
float v) |
public static final int PRIMITIVE
public static final int PATH
public static final int GEOMETRY
public float width
public float height
public float depth
public int colorMode
public float colorModeX
public float colorModeY
public float colorModeZ
public float colorModeA
public void setKind(int kind)
public void setName(java.lang.String name)
public java.lang.String getName()
public boolean isVisible()
public void setVisible(boolean visible)
visible - "false" makes the shape invisible and "true" makes it visiblepublic void disableStyle()
public void enableStyle()
public float getWidth()
public float getHeight()
public float getDepth()
public boolean is2D()
public boolean is3D()
public void is3D(boolean val)
public void texture(PImage tex)
public void noTexture()
public void beginContour()
public void endContour()
public void vertex(float x,
float y)
public void vertex(float x,
float y,
float u,
float v)
public void vertex(float x,
float y,
float z)
public void vertex(float x,
float y,
float z,
float u,
float v)
public void normal(float nx,
float ny,
float nz)
public void end()
public void end(int mode)
public void strokeWeight(float weight)
public void strokeJoin(int join)
public void strokeCap(int cap)
public void noFill()
public void fill(int rgb)
public void fill(int rgb,
float alpha)
public void fill(float gray)
public void fill(float gray,
float alpha)
public void fill(float x,
float y,
float z)
public void fill(float x,
float y,
float z,
float a)
public void noStroke()
public void stroke(int rgb)
public void stroke(int rgb,
float alpha)
public void stroke(float gray)
public void stroke(float gray,
float alpha)
public void stroke(float x,
float y,
float z)
public void stroke(float x,
float y,
float z,
float alpha)
public void noTint()
public void tint(int rgb)
public void tint(int rgb,
float alpha)
public void tint(float gray)
public void tint(float gray,
float alpha)
public void tint(float x,
float y,
float z)
public void tint(float x,
float y,
float z,
float alpha)
public void ambient(int rgb)
public void ambient(float gray)
public void ambient(float x,
float y,
float z)
public void specular(int rgb)
public void specular(float gray)
public void specular(float x,
float y,
float z)
public void emissive(int rgb)
public void emissive(float gray)
public void emissive(float x,
float y,
float z)
public void shininess(float shine)
public void bezierDetail(int detail)
public void bezierVertex(float x2,
float y2,
float x3,
float y3,
float x4,
float y4)
public void bezierVertex(float x2,
float y2,
float z2,
float x3,
float y3,
float z3,
float x4,
float y4,
float z4)
public void quadraticVertex(float cx,
float cy,
float x3,
float y3)
public void quadraticVertex(float cx,
float cy,
float cz,
float x3,
float y3,
float z3)
public void curveDetail(int detail)
public void curveTightness(float tightness)
public void curveVertex(float x,
float y)
public void curveVertex(float x,
float y,
float z)
public void draw(PGraphics g)
public void drawImpl(PGraphics g)
public PShape getParent()
public int getChildCount()
public PShape[] getChildren()
public PShape getChild(int index)
index - the layer position of the shape to getpublic PShape getChild(java.lang.String target)
target - the name of the shape to getpublic PShape findChild(java.lang.String target)
public void addChild(PShape who)
public void addChild(PShape who, int idx)
public void removeChild(int idx)
public void addName(java.lang.String nom,
PShape shape)
public int getChildIndex(PShape who)
public PShape getTessellation()
public int getFamily()
public int getKind()
public float[] getParams()
public float[] getParams(float[] target)
public float getParam(int index)
public void setPath(int vcount,
float[][] verts)
public int getVertexCount()
public PVector getVertex(int index)
index - the location of the vertexpublic PVector getVertex(int index, PVector vec)
vec - PVector to assign the data topublic float getVertexX(int index)
public float getVertexY(int index)
public float getVertexZ(int index)
public void setVertex(int index,
float x,
float y)
index - the location of the vertexx - the x value for the vertexy - the y value for the vertexpublic void setVertex(int index,
float x,
float y,
float z)
z - the z value for the vertexpublic void setVertex(int index,
PVector vec)
vec - the PVector to define the x, y, z coordinatespublic PVector getNormal(int index)
public float getNormalX(int index)
public float getNormalY(int index)
public float getNormalZ(int index)
public void setNormal(int index,
float nx,
float ny,
float nz)
public float getTextureU(int index)
public float getTextureV(int index)
public void setTextureUV(int index,
float u,
float v)
public int getFill(int index)
public void setFill(int index,
int fill)
public int getStroke(int index)
public void setStroke(int index,
int stroke)
public int[] getVertexCodes()
public int getVertexCodeCount()
public int getVertexCode(int index)
public boolean isClosed()
public boolean contains(float x,
float y)
public void translate(float x,
float y)
tx - left/right translationty - up/down translationpublic void translate(float x,
float y,
float z)
tz - forward/back translationpublic void rotateX(float angle)
angle - angle of rotation specified in radianspublic void rotateY(float angle)
angle - angle of rotation specified in radiansrotate(float),
rotateX(float),
rotateZ(float)public void rotateZ(float angle)
angle - angle of rotation specified in radianspublic void rotate(float angle)
angle - angle of rotation specified in radianspublic void rotate(float angle,
float v0,
float v1,
float v2)
public void scale(float s)
s - percentate to scale the objectpublic void scale(float x,
float y)
public void scale(float x,
float y,
float z)
x - percentage to scale the object in the x-axisy - percentage to scale the object in the y-axisz - percentage to scale the object in the z-axispublic void resetMatrix()
public void applyMatrix(PMatrix source)
public void applyMatrix(PMatrix2D source)
public void applyMatrix(float n00,
float n01,
float n02,
float n10,
float n11,
float n12)
public void applyMatrix(PMatrix3D source)
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)
public void colorMode(int mode)
public void colorMode(int mode,
float max)
max - range for all color elementspublic void colorMode(int mode,
float maxX,
float maxY,
float maxZ)
maxX - range for the red or hue depending on the current color modemaxY - range for the green or saturation depending on the current color modemaxZ - range for the blue or brightness depending on the current color modepublic void colorMode(int mode,
float maxX,
float maxY,
float maxZ,
float maxA)
maxA - range for the alpha