public class PShape extends 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().
PApplet.loadShape(String)
,
PApplet.createShape()
,
PApplet.shapeMode(int)
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 String |
INSIDE_BEGIN_END_ERROR |
static String |
NO_SUCH_VERTEX_ERROR |
static String |
NO_VERTICES_ERROR |
static String |
NOT_A_SIMPLE_VERTEX |
static String |
OUTSIDE_BEGIN_END_ERROR |
static int |
PATH
A series of vertex, curveVertex, and bezierVertex calls.
|
static String |
PER_VERTEX_UNSUPPORTED |
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_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, 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 and Description |
---|
PShape() |
PShape(int family) |
PShape(PGraphics g,
int family) |
PShape(PGraphics g,
int kind,
float... params) |
Modifier and Type | Method and Description |
---|---|
void |
addChild(PShape who) |
void |
addChild(PShape who,
int idx) |
void |
addName(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 |
attrib(String name,
boolean... values) |
void |
attrib(String name,
float... values) |
void |
attrib(String name,
int... values) |
void |
attribColor(String name,
int color) |
void |
attribNormal(String name,
float nx,
float ny,
float nz) |
void |
attribPosition(String name,
float x,
float y,
float z) |
void |
beginContour() |
void |
beginShape() |
void |
beginShape(int kind) |
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)
Return true if this x, y coordinate is part of this shape.
|
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 |
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 |
endContour() |
void |
endShape() |
void |
endShape(int mode) |
void |
fill(float gray) |
void |
fill(float gray,
float alpha) |
void |
fill(float x,
float y,
float z) |
void |
fill(float x,
float y,
float z,
float a) |
void |
fill(int rgb) |
void |
fill(int rgb,
float alpha) |
PShape |
findChild(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.
|
int |
getAmbient(int index) |
PShape |
getChild(int index)
( begin auto-generated from PShape_getChild.xml )
Extracts a child shape from a parent shape.
|
PShape |
getChild(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 |
getEmissive(int index) |
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() |
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() |
float |
getShininess(int index) |
int |
getSpecular(int index) |
int |
getStroke(int index) |
float |
getStrokeWeight(int index) |
PShape |
getTessellation() |
float |
getTextureU(int index) |
float |
getTextureV(int index) |
int |
getTint(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.
|
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 |
set3D(boolean val) |
void |
setAmbient(int ambient) |
void |
setAmbient(int index,
int ambient) |
void |
setAttrib(String name,
int index,
boolean... values) |
void |
setAttrib(String name,
int index,
float... values) |
void |
setAttrib(String name,
int index,
int... values) |
void |
setEmissive(int emissive) |
void |
setEmissive(int index,
int emissive) |
void |
setFamily(int family) |
void |
setFill(boolean fill) |
void |
setFill(int fill)
( begin auto-generated from PShape_setFill.xml )
The setFill() method defines the fill color of a PShape.
|
void |
setFill(int index,
int fill) |
void |
setKind(int kind) |
void |
setName(String name) |
void |
setNormal(int index,
float nx,
float ny,
float nz) |
void |
setPath(int vcount,
float[][] verts) |
void |
setShininess(float shine) |
void |
setShininess(int index,
float shine) |
void |
setSpecular(int specular) |
void |
setSpecular(int index,
int specular) |
void |
setStroke(boolean stroke) |
void |
setStroke(int stroke)
( begin auto-generated from PShape_setStroke.xml )
The setStroke() method defines the outline color of a PShape.
|
void |
setStroke(int index,
int stroke) |
void |
setStrokeCap(int cap) |
void |
setStrokeJoin(int join) |
void |
setStrokeWeight(float weight) |
void |
setStrokeWeight(int index,
float weight) |
void |
setTexture(PImage tex) |
void |
setTextureMode(int mode) |
void |
setTextureUV(int index,
float u,
float v) |
void |
setTint(boolean tint) |
void |
setTint(int fill) |
void |
setTint(int index,
int tint) |
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 |
textureMode(int mode) |
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 static final String OUTSIDE_BEGIN_END_ERROR
public static final String INSIDE_BEGIN_END_ERROR
public static final String NO_SUCH_VERTEX_ERROR
public static final String NO_VERTICES_ERROR
public static final String NOT_A_SIMPLE_VERTEX
public static final String PER_VERTEX_UNSUPPORTED
public float width
height
public float height
width
public float depth
public int colorMode
public float colorModeX
public float colorModeY
public float colorModeZ
public float colorModeA
public PShape()
public PShape(int family)
public PShape(PGraphics g, int family)
public PShape(PGraphics g, int kind, float... params)
public void setFamily(int family)
public void setKind(int kind)
public void setName(String name)
public String getName()
public boolean isVisible()
setVisible(boolean)
public void setVisible(boolean visible)
visible
- "false" makes the shape invisible and "true" makes it visibleisVisible()
public void disableStyle()
enableStyle()
public void enableStyle()
disableStyle()
public float getWidth()
public float getHeight()
public float getDepth()
public boolean is2D()
public boolean is3D()
public void set3D(boolean val)
public void textureMode(int mode)
public void texture(PImage tex)
public void noTexture()
public void beginContour()
endContour()
public void endContour()
beginContour()
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 attribPosition(String name, float x, float y, float z)
public void attribNormal(String name, float nx, float ny, float nz)
public void attribColor(String name, int color)
public void attrib(String name, float... values)
public void attrib(String name, int... values)
public void attrib(String name, boolean... values)
public void beginShape()
PApplet.endShape()
public void beginShape(int kind)
public void endShape()
PApplet.beginShape()
public void endShape(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 PShape getParent()
public int getChildCount()
public PShape[] getChildren()
public PShape getChild(int index)
index
- the layer position of the shape to getaddChild(PShape)
public PShape getChild(String target)
target
- the name of the shape to getpublic PShape findChild(String target)
public void addChild(PShape who)
who
- any variable of type PShapegetChild(int)
public void addChild(PShape who, int idx)
idx
- the layer position in which to insert the new childpublic void removeChild(int idx)
public void addName(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()
getVertex(int)
,
setVertex(int, float, float)
public PVector getVertex(int index)
index
- the location of the vertexsetVertex(int, float, float)
,
getVertexCount()
public 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 vertexgetVertex(int)
,
getVertexCount()
public 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 void setAttrib(String name, int index, float... values)
public void setAttrib(String name, int index, int... values)
public void setAttrib(String name, int index, boolean... values)
public float getTextureU(int index)
public float getTextureV(int index)
public void setTextureUV(int index, float u, float v)
public void setTextureMode(int mode)
public void setTexture(PImage tex)
public int getFill(int index)
public void setFill(boolean fill)
public void setFill(int fill)
fill
- public void setFill(int index, int fill)
public int getTint(int index)
public void setTint(boolean tint)
public void setTint(int fill)
public void setTint(int index, int tint)
public int getStroke(int index)
public void setStroke(boolean stroke)
public void setStroke(int stroke)
stroke
- public void setStroke(int index, int stroke)
public float getStrokeWeight(int index)
public void setStrokeWeight(float weight)
public void setStrokeWeight(int index, float weight)
public void setStrokeJoin(int join)
public void setStrokeCap(int cap)
public int getAmbient(int index)
public void setAmbient(int ambient)
public void setAmbient(int index, int ambient)
public int getSpecular(int index)
public void setSpecular(int specular)
public void setSpecular(int index, int specular)
public int getEmissive(int index)
public void setEmissive(int emissive)
public void setEmissive(int index, int emissive)
public float getShininess(int index)
public void setShininess(float shine)
public void setShininess(int index, float shine)
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)
x
- left/right translationy
- up/down translationrotate(float)
,
scale(float)
,
resetMatrix()
public void translate(float x, float y, float z)
z
- forward/back translationpublic void rotateX(float angle)
angle
- angle of rotation specified in radiansrotate(float)
,
rotateY(float)
,
rotateZ(float)
,
scale(float)
,
translate(float, float)
,
resetMatrix()
public void rotateY(float angle)
angle
- angle of rotation specified in radiansrotate(float)
,
rotateX(float)
,
rotateZ(float)
,
scale(float)
,
translate(float, float)
,
resetMatrix()
public void rotateZ(float angle)
angle
- angle of rotation specified in radiansrotate(float)
,
rotateX(float)
,
rotateY(float)
,
scale(float)
,
translate(float, float)
,
resetMatrix()
public void rotate(float angle)
angle
- angle of rotation specified in radiansrotateX(float)
,
rotateY(float)
,
rotateZ(float)
,
scale(float)
,
translate(float, float)
,
resetMatrix()
public void rotate(float angle, float v0, float v1, float v2)
public void scale(float s)
s
- percentate to scale the objectrotate(float)
,
translate(float, float)
,
resetMatrix()
public 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()
rotate(float)
,
scale(float)
,
translate(float, float)
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