processing.core
Class PShape

java.lang.Object
  extended by processing.core.PShape
All Implemented Interfaces:
PConstants
Direct Known Subclasses:
PShapeSVG

public class PShape
extends java.lang.Object
implements PConstants

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:

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().


Field Summary
static int BEZIER_VERTEX
           
static int BREAK
           
static int CURVE_VERTEX
           
static int GEOMETRY
          Collections of vertices created with beginShape().
static int GROUP
          Generic, only draws its child objects.
 float height
           
static int PATH
          A series of vertex, curveVertex, and bezierVertex calls.
static int PRIMITIVE
          A line, ellipse, arc, image, etc.
static int VERTEX
           
 float width
           
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
PShape()
           
PShape(int family)
           
 
Method Summary
 void addChild(PShape who)
           
 void apply(PMatrix3D source)
           
 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 disableStyle()
          Overrides this shape's style information and uses PGraphics styles and colors.
 void draw(PGraphics g)
          Called by the following (the shape() command adds the g) PShape s = loadShapes("blah.svg"); shape(s);
 void drawImpl(PGraphics g)
          Draws the SVG document.
 void enableStyle()
          Re-enables style information (fill and stroke) set in the shape.
 PShape findChild(java.lang.String target)
          Same as getChild(name), except that it first walks all the way up the hierarchy to the farthest parent, so that children can be found anywhere.
 PShape getChild(int index)
           
 PShape getChild(java.lang.String target)
           
 int getChildCount()
           
 float getHeight()
          Get the height of the drawing area (not necessarily the shape boundary).
 java.lang.String getName()
           
 float getWidth()
          Get the width of the drawing area (not necessarily the shape boundary).
 boolean isVisible()
           
 void post(PGraphics g)
           
 void resetMatrix()
           
 void rotate(float angle)
           
 void rotate(float angle, float v0, float v1, float v2)
           
 void rotateX(float angle)
           
 void rotateY(float angle)
           
 void rotateZ(float angle)
           
 void scale(float s)
           
 void scale(float sx, float sy)
           
 void scale(float x, float y, float z)
           
 void setName(java.lang.String name)
           
 void setVisible(boolean visible)
           
 void translate(float tx, float ty)
           
 void translate(float tx, float ty, float tz)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GROUP

public static final int GROUP
Generic, only draws its child objects.

See Also:
Constant Field Values

PRIMITIVE

public static final int PRIMITIVE
A line, ellipse, arc, image, etc.

See Also:
Constant Field Values

PATH

public static final int PATH
A series of vertex, curveVertex, and bezierVertex calls.

See Also:
Constant Field Values

GEOMETRY

public static final int GEOMETRY
Collections of vertices created with beginShape().

See Also:
Constant Field Values

width

public float width

height

public float height

VERTEX

public static final int VERTEX
See Also:
Constant Field Values

BEZIER_VERTEX

public static final int BEZIER_VERTEX
See Also:
Constant Field Values

CURVE_VERTEX

public static final int CURVE_VERTEX
See Also:
Constant Field Values

BREAK

public static final int BREAK
See Also:
Constant Field Values
Constructor Detail

PShape

public PShape()

PShape

public PShape(int family)
Method Detail

setName

public void setName(java.lang.String name)

getName

public java.lang.String getName()

isVisible

public boolean isVisible()

setVisible

public void setVisible(boolean visible)

disableStyle

public void disableStyle()
Overrides this shape's style information and uses PGraphics styles and colors. Identical to ignoreStyles(true). Also disables styles for all child shapes.


enableStyle

public void enableStyle()
Re-enables style information (fill and stroke) set in the shape.


getWidth

public float getWidth()
Get the width of the drawing area (not necessarily the shape boundary).


getHeight

public float getHeight()
Get the height of the drawing area (not necessarily the shape boundary).


post

public void post(PGraphics g)

draw

public void draw(PGraphics g)
Called by the following (the shape() command adds the g) PShape s = loadShapes("blah.svg"); shape(s);


drawImpl

public void drawImpl(PGraphics g)
Draws the SVG document.


getChildCount

public int getChildCount()

getChild

public PShape getChild(int index)

getChild

public PShape getChild(java.lang.String target)

findChild

public PShape findChild(java.lang.String target)
Same as getChild(name), except that it first walks all the way up the hierarchy to the farthest parent, so that children can be found anywhere.


addChild

public void addChild(PShape who)

translate

public void translate(float tx,
                      float ty)

translate

public void translate(float tx,
                      float ty,
                      float tz)

rotateX

public void rotateX(float angle)

rotateY

public void rotateY(float angle)

rotateZ

public void rotateZ(float angle)

rotate

public void rotate(float angle)

rotate

public void rotate(float angle,
                   float v0,
                   float v1,
                   float v2)

scale

public void scale(float s)

scale

public void scale(float sx,
                  float sy)

scale

public void scale(float x,
                  float y,
                  float z)

resetMatrix

public void resetMatrix()

applyMatrix

public void applyMatrix(PMatrix source)

applyMatrix

public void applyMatrix(PMatrix2D source)

applyMatrix

public void applyMatrix(float n00,
                        float n01,
                        float n02,
                        float n10,
                        float n11,
                        float n12)

apply

public void apply(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)