- java.lang.Object
-
- processing.core.PShape
-
- All Implemented Interfaces:
PConstants
- Direct Known Subclasses:
PShapeOBJ,PShapeOpenGL,PShapeSVG
public class PShape extends Object implements PConstants
( begin auto-generated from PShape.xml ) Datatype for storing shapes. Processing can currently load and display SVG (Scalable Vector Graphics) shapes. Before a shape is used, it must be loaded with the loadShape() function. The shape() function is used to draw the shape to the display window. The PShape object contain a group of methods, linked below, that can operate on the shape data.
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. ( end auto-generated )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().
-
-
Field Summary
Fields Modifier and Type Field Description protected intambientColorprotected floatcalcAprotected intcalcAiprotected booleancalcAlphaprotected floatcalcBprotected intcalcBiprotected intcalcColorprotected floatcalcGprotected intcalcGiprotected floatcalcRprotected intcalcRiprotected intchildCountprotected PShape[]childrenprotected booleancloseTrue if this is a closed path.intcolorModeThe 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 colorModefloatdepthprotected intellipseModeprotected intemissiveColorprotected intfamilyThe shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY.protected booleanfillprotected intfillColorstatic intGEOMETRYCollections of vertices created with beginShape().floatheight( begin auto-generated from PShape_height.xml ) The height of the PShape document.protected PImageimageTexture or image data associated with this shape.protected StringimagePathstatic StringINSIDE_BEGIN_END_ERRORprotected booleanis3DTrue if contains 3D dataprotected intkindELLIPSE, LINE, QUAD; TRIANGLE_FAN, QUAD_STRIP; etc.protected PMatrixmatrixprotected Stringnameprotected Map<String,PShape>nameTablestatic StringNO_SUCH_VERTEX_ERRORstatic StringNO_VERTICES_ERRORstatic StringNOT_A_SIMPLE_VERTEXprotected booleanopenContourprotected booleanopenShapeRetained shape being created with beginShape/endShapestatic StringOUTSIDE_BEGIN_END_ERRORprotected float[]paramsFor primitive shapes in particular, params like x/y/w/h or x1/y1/x2/y2.protected PShapeparentstatic intPATHA series of vertex, curveVertex, and bezierVertex calls.static StringPER_VERTEX_UNSUPPORTEDprotected booleanperVertexStylesstatic intPRIMITIVEA line, ellipse, arc, image, etc.protected intrectModeprotected booleansetAmbientprotected floatshininessprotected intspecularColorprotected intsphereDetailUprotected intsphereDetailVprotected booleanstrokeprotected intstrokeCapprotected intstrokeColorprotected intstrokeJoinprotected floatstrokeWeightprotected booleanstyleTemporary toggle for whether styles should be honored.protected inttextureModeprotected booleantintprotected inttintColorprotected intvertexCodeCountArray of VERTEX, BEZIER_VERTEX, and CURVE_VERTEX calls.protected int[]vertexCodesprotected intvertexCountprotected float[][]verticesWhen drawing POLYGON shapes, the second param is an array of length VERTEX_FIELD_COUNT.protected booleanvisiblefloatwidth( begin auto-generated from PShape_width.xml ) The width of the PShape document.-
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, 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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(PShape who)voidaddChild(PShape who, int idx)voidaddName(String nom, PShape shape)Add 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)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)voidbeginContour()protected voidbeginContourImpl()voidbeginShape()voidbeginShape(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)protected voidcheckMatrix(int dimensions)Make sure that the shape's matrix is 1) not null, and 2) has a matrix that can handle at least the specified number of dimensions.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)protected voidcolorCalc(int rgb, float alpha)protected voidcolorCalcARGB(int argb, float alpha)voidcolorMode(int mode)Set the pivot point for all transformations.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.protected static voidcopyGeometry(PShape src, PShape dest)protected static voidcopyGroup(PApplet parent, PShape src, PShape dest)protected static voidcopyImage(PShape src, PShape dest)protected static voidcopyMatrix(PShape src, PShape dest)protected static voidcopyPath(PShape src, PShape dest)protected static voidcopyPrimitive(PShape src, PShape dest)protected static voidcopyStyles(PShape src, PShape dest)protected static PShapecreateShape(PApplet parent, PShape src)protected voidcrop()Resize the children[] array to be in line with childCountvoidcurveDetail(int detail)voidcurveTightness(float tightness)voidcurveVertex(float x, float y)voidcurveVertex(float x, float y, float z)voiddisableStyle()( begin auto-generated from PShape_disableStyle.xml ) Disables the shape's style data and uses Processing's current styles.voiddraw(PGraphics g)Called by the following (the shape() command adds the g) PShape s = loadShape("blah.svg"); shape(s);protected voiddrawGeometry(PGraphics g)protected voiddrawGroup(PGraphics g)protected voiddrawImpl(PGraphics g)Draws the SVG document.protected voiddrawPath(PGraphics g)protected voiddrawPrimitive(PGraphics g)voidemissive(float gray)voidemissive(float x, float y, float z)voidemissive(int rgb)voidenableStyle()( begin auto-generated from PShape_enableStyle.xml ) Enables the shape's style data and ignores Processing's current styles.voidendContour()protected voidendContourImpl()voidendShape()voidendShape(int mode)voidfill(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)PShapefindChild(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.intgetAmbient(int index)PShapegetChild(int index)( begin auto-generated from PShape_getChild.xml ) Extracts a child shape from a parent shape.PShapegetChild(String target)intgetChildCount()intgetChildIndex(PShape who)Returns the index of child who.PShape[]getChildren()floatgetDepth()Get the depth of the shape area (not necessarily the shape boundary).intgetEmissive(int index)intgetFamily()The shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY.intgetFill(int index)floatgetHeight()Get the height of the drawing area (not necessarily the shape boundary).intgetKind()StringgetName()PVectorgetNormal(int index)PVectorgetNormal(int index, PVector vec)floatgetNormalX(int index)floatgetNormalY(int index)floatgetNormalZ(int index)floatgetParam(int index)float[]getParams()float[]getParams(float[] target)PShapegetParent()floatgetShininess(int index)intgetSpecular(int index)intgetStroke(int index)floatgetStrokeWeight(int index)PShapegetTessellation()floatgetTextureU(int index)floatgetTextureV(int index)intgetTint(int index)PVectorgetVertex(int index)PVectorgetVertex(int index, PVector vec)intgetVertexCode(int index)One of VERTEX, BEZIER_VERTEX, CURVE_VERTEX, or BREAK.intgetVertexCodeCount()int[]getVertexCodes()intgetVertexCount()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()booleanisVisible()( begin auto-generated from PShape_isVisible.xml ) Returns a boolean value "true" if the image is set to be visible, "false" if not.voidnoFill()voidnormal(float nx, float ny, float nz)voidnoStroke()voidnoTexture()voidnoTint()protected voidpost(PGraphics g)protected voidpre(PGraphics g)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.voidresetMatrix()( begin auto-generated from PShape_resetMatrix.xml ) Replaces the current matrix of a shape with the identity matrix.voidrotate(float angle)( begin auto-generated from PShape_rotate.xml ) Rotates a shape the amount specified by the angle parameter.voidrotate(float angle, float v0, float v1, float v2)voidrotateX(float angle)( begin auto-generated from PShape_rotateX.xml ) Rotates a shape around the x-axis the amount specified by the angle parameter.voidrotateY(float angle)( begin auto-generated from PShape_rotateY.xml ) Rotates a shape around the y-axis the amount specified by the angle parameter.voidrotateZ(float angle)( begin auto-generated from PShape_rotateZ.xml ) Rotates a shape around the z-axis the amount specified by the angle parameter.voidscale(float s)( begin auto-generated from PShape_scale.xml ) 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)voidsetAttrib(String name, int index, boolean... values)voidsetAttrib(String name, int index, float... values)voidsetAttrib(String name, int index, int... values)voidsetEmissive(int emissive)voidsetEmissive(int index, int emissive)voidsetFamily(int family)voidsetFill(boolean fill)voidsetFill(int fill)( begin auto-generated from PShape_setFill.xml ) The setFill() method defines the fill color of a PShape.voidsetFill(int index, int fill)voidsetKind(int kind)voidsetName(String name)voidsetNormal(int index, float nx, float ny, float nz)protected voidsetParams(float[] source)voidsetPath(int vcount, float[][] verts)protected voidsetPath(int vcount, float[][] verts, int ccount, int[] codes)voidsetShininess(float shine)voidsetShininess(int index, float shine)voidsetSpecular(int specular)voidsetSpecular(int index, int specular)voidsetStroke(boolean stroke)voidsetStroke(int stroke)( begin auto-generated from PShape_setStroke.xml ) 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)voidsetVertex(int index, float x, float y, float z)voidsetVertex(int index, PVector vec)voidsetVisible(boolean visible)( begin auto-generated from PShape_setVisible.xml ) Sets the shape to be visible or invisible.voidshininess(float shine)protected voidsolid(boolean solid)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)protected voidstyles(PGraphics g)voidtexture(PImage tex)voidtextureMode(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)( begin auto-generated from PShape_translate.xml ) 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 Detail
-
name
protected String name
-
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
-
family
protected int family
The shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY.
-
kind
protected int kind
ELLIPSE, LINE, QUAD; TRIANGLE_FAN, QUAD_STRIP; etc.
-
matrix
protected PMatrix matrix
-
textureMode
protected int textureMode
-
image
protected PImage image
Texture or image data associated with this shape.
-
imagePath
protected String imagePath
-
OUTSIDE_BEGIN_END_ERROR
public static final String OUTSIDE_BEGIN_END_ERROR
- See Also:
- Constant Field Values
-
INSIDE_BEGIN_END_ERROR
public static final String INSIDE_BEGIN_END_ERROR
- See Also:
- Constant Field Values
-
NO_SUCH_VERTEX_ERROR
public static final String NO_SUCH_VERTEX_ERROR
- See Also:
- Constant Field Values
-
NO_VERTICES_ERROR
public static final String NO_VERTICES_ERROR
- See Also:
- Constant Field Values
-
NOT_A_SIMPLE_VERTEX
public static final String NOT_A_SIMPLE_VERTEX
- See Also:
- Constant Field Values
-
PER_VERTEX_UNSUPPORTED
public static final String PER_VERTEX_UNSUPPORTED
- See Also:
- Constant Field Values
-
width
public float width
( begin auto-generated from PShape_width.xml ) The width of the PShape document. ( end auto-generated )- See Also:
height
-
height
public float height
( begin auto-generated from PShape_height.xml ) The height of the PShape document. ( end auto-generated )- See Also:
width
-
depth
public float depth
-
visible
protected boolean visible
-
openShape
protected boolean openShape
Retained shape being created with beginShape/endShape
-
openContour
protected boolean openContour
-
stroke
protected boolean stroke
-
strokeColor
protected int strokeColor
-
strokeWeight
protected float strokeWeight
-
strokeCap
protected int strokeCap
-
strokeJoin
protected int strokeJoin
-
fill
protected boolean fill
-
fillColor
protected int fillColor
-
tint
protected boolean tint
-
tintColor
protected int tintColor
-
ambientColor
protected int ambientColor
-
setAmbient
protected boolean setAmbient
-
specularColor
protected int specularColor
-
emissiveColor
protected int emissiveColor
-
shininess
protected float shininess
-
sphereDetailU
protected int sphereDetailU
-
sphereDetailV
protected int sphereDetailV
-
rectMode
protected int rectMode
-
ellipseMode
protected int ellipseMode
-
style
protected boolean style
Temporary toggle for whether styles should be honored.
-
params
protected float[] params
For primitive shapes in particular, params like x/y/w/h or x1/y1/x2/y2.
-
vertexCount
protected int vertexCount
-
vertices
protected float[][] vertices
When drawing POLYGON shapes, the second param is an array of length VERTEX_FIELD_COUNT. When drawing PATH shapes, the second param has only two variables.
-
parent
protected PShape parent
-
childCount
protected int childCount
-
children
protected PShape[] children
-
vertexCodeCount
protected int vertexCodeCount
Array of VERTEX, BEZIER_VERTEX, and CURVE_VERTEX calls.
-
vertexCodes
protected int[] vertexCodes
-
close
protected boolean close
True if this is a closed path.
-
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
-
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
-
is3D
protected boolean is3D
True if contains 3D data
-
perVertexStyles
protected boolean perVertexStyles
-
-
Method Detail
-
setFamily
public void setFamily(int family)
-
setKind
public void setKind(int kind)
-
setName
public void setName(String name)
-
getName
public String getName()
-
isVisible
public 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. This is modified with the setVisible() parameter.
The 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. ( end auto-generated )- See Also:
setVisible(boolean)
-
setVisible
public void setVisible(boolean visible)
( begin auto-generated from PShape_setVisible.xml ) Sets the shape to be visible or invisible. This is determined by the value of the visible parameter.
The 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. ( end auto-generated )- Parameters:
visible- "false" makes the shape invisible and "true" makes it visible- See Also:
isVisible()
-
disableStyle
public void disableStyle()
( begin auto-generated from PShape_disableStyle.xml ) Disables the shape's style data and uses Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. ( end auto-generated )Advanced
Overrides this shape's style information and uses PGraphics styles and colors. Identical to ignoreStyles(true). Also disables styles for all child shapes.- See Also:
enableStyle()
-
enableStyle
public void enableStyle()
( begin auto-generated from PShape_enableStyle.xml ) Enables the shape's style data and ignores Processing's current styles. Styles include attributes such as colors, stroke weight, and stroke joints. ( end auto-generated )- See Also:
disableStyle()
-
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).
-
getDepth
public float getDepth()
Get the depth of the shape area (not necessarily the shape boundary). Only makes sense for 3D PShape subclasses, such as PShape3D.
-
is2D
public boolean is2D()
Return true if this shape is 2D. Defaults to true.
-
is3D
public boolean is3D()
Return true if this shape is 3D. Defaults to false.
-
set3D
public void set3D(boolean val)
-
textureMode
public void textureMode(int mode)
-
texture
public void texture(PImage tex)
-
noTexture
public void noTexture()
-
solid
protected void solid(boolean solid)
-
beginContour
public void beginContour()
- See Also:
endContour()
-
beginContourImpl
protected void beginContourImpl()
-
endContour
public void endContour()
- See Also:
beginContour()
-
endContourImpl
protected void endContourImpl()
-
vertex
public void vertex(float x, float y)
-
vertex
public void vertex(float x, float y, float u, float v)
-
vertex
public void vertex(float x, float y, float z)
-
vertex
public void vertex(float x, float y, float z, float u, float v)
-
normal
public void normal(float nx, float ny, float nz)
-
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)
-
beginShape
public void beginShape()
- See Also:
PApplet.endShape()
-
beginShape
public void beginShape(int kind)
-
endShape
public void endShape()
- See Also:
PApplet.beginShape()
-
endShape
public void endShape(int mode)
-
strokeWeight
public void strokeWeight(float weight)
-
strokeJoin
public void strokeJoin(int join)
-
strokeCap
public void strokeCap(int cap)
-
noFill
public void noFill()
-
fill
public void fill(int rgb)
-
fill
public void fill(int rgb, float alpha)
-
fill
public void fill(float gray)
-
fill
public void fill(float gray, float alpha)
-
fill
public void fill(float x, float y, float z)
-
fill
public void fill(float x, float y, float z, float a)
-
noStroke
public void noStroke()
-
stroke
public void stroke(int rgb)
-
stroke
public void stroke(int rgb, float alpha)
-
stroke
public void stroke(float gray)
-
stroke
public void stroke(float gray, float alpha)
-
stroke
public void stroke(float x, float y, float z)
-
stroke
public void stroke(float x, float y, float z, float alpha)
-
noTint
public void noTint()
-
tint
public void tint(int rgb)
-
tint
public void tint(int rgb, float alpha)
-
tint
public void tint(float gray)
-
tint
public void tint(float gray, float alpha)
-
tint
public void tint(float x, float y, float z)
-
tint
public void tint(float x, float y, float z, float alpha)
-
ambient
public void ambient(int rgb)
-
ambient
public void ambient(float gray)
-
ambient
public void ambient(float x, float y, float z)
-
specular
public void specular(int rgb)
-
specular
public void specular(float gray)
-
specular
public void specular(float x, float y, float z)
-
emissive
public void emissive(int rgb)
-
emissive
public void emissive(float gray)
-
emissive
public void emissive(float x, float y, float z)
-
shininess
public void shininess(float shine)
-
bezierDetail
public void bezierDetail(int detail)
-
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)
-
quadraticVertex
public void quadraticVertex(float cx, float cy, float x3, float y3)
-
quadraticVertex
public void quadraticVertex(float cx, float cy, float cz, float x3, float y3, float z3)
-
curveDetail
public void curveDetail(int detail)
-
curveTightness
public void curveTightness(float tightness)
-
curveVertex
public void curveVertex(float x, float y)
-
curveVertex
public void curveVertex(float x, float y, float z)
-
pre
protected void pre(PGraphics g)
-
styles
protected void styles(PGraphics g)
-
post
protected void post(PGraphics g)
-
draw
public void draw(PGraphics g)
Called by the following (the shape() command adds the g) PShape s = loadShape("blah.svg"); shape(s);
-
drawImpl
protected void drawImpl(PGraphics g)
Draws the SVG document.
-
drawGroup
protected void drawGroup(PGraphics g)
-
drawPrimitive
protected void drawPrimitive(PGraphics g)
-
drawGeometry
protected void drawGeometry(PGraphics g)
-
drawPath
protected void drawPath(PGraphics g)
-
getParent
public PShape getParent()
-
getChildCount
public int getChildCount()
-
crop
protected void crop()
Resize the children[] array to be in line with childCount
-
getChildren
public PShape[] getChildren()
-
getChild
public PShape getChild(int index)
( begin auto-generated from PShape_getChild.xml ) Extracts 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. ( end auto-generated )- Parameters:
index- the layer position of the shape to get- See Also:
addChild(PShape)
-
findChild
public 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.
-
addChild
public void addChild(PShape who)
- Parameters:
who- any variable of type PShape- See Also:
getChild(int)
-
addChild
public void addChild(PShape who, int idx)
- Parameters:
idx- the layer position in which to insert the new child
-
removeChild
public void removeChild(int idx)
Remove the child shape with index idx.
-
getChildIndex
public int getChildIndex(PShape who)
Returns the index of child who.
-
getTessellation
public PShape getTessellation()
-
getFamily
public int getFamily()
The shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY.
-
getKind
public int getKind()
-
getParams
public float[] getParams()
-
getParams
public float[] getParams(float[] target)
-
getParam
public float getParam(int index)
-
setParams
protected void setParams(float[] source)
-
setPath
public void setPath(int vcount, float[][] verts)
-
setPath
protected void setPath(int vcount, float[][] verts, int ccount, int[] codes)
-
getVertexCount
public int getVertexCount()
- See Also:
getVertex(int),setVertex(int, float, float)
-
getVertex
public PVector getVertex(int index)
- Parameters:
index- the location of the vertex- See Also:
setVertex(int, float, float),getVertexCount()
-
getVertex
public PVector getVertex(int index, PVector vec)
- Parameters:
vec- PVector to assign the data to
-
getVertexX
public float getVertexX(int index)
-
getVertexY
public float getVertexY(int index)
-
getVertexZ
public float getVertexZ(int index)
-
setVertex
public void setVertex(int index, float x, float y)- Parameters:
index- the location of the vertexx- the x value for the vertexy- the y value for the vertex- See Also:
getVertex(int),getVertexCount()
-
setVertex
public void setVertex(int index, float x, float y, float z)- Parameters:
z- the z value for the vertex
-
setVertex
public void setVertex(int index, PVector vec)- Parameters:
vec- the PVector to define the x, y, z coordinates
-
getNormal
public PVector getNormal(int index)
-
getNormalX
public float getNormalX(int index)
-
getNormalY
public float getNormalY(int index)
-
getNormalZ
public float getNormalZ(int index)
-
setNormal
public void setNormal(int index, float nx, float ny, float nz)
-
setAttrib
public void setAttrib(String name, int index, float... values)
-
setAttrib
public void setAttrib(String name, int index, int... values)
-
setAttrib
public void setAttrib(String name, int index, boolean... values)
-
getTextureU
public float getTextureU(int index)
-
getTextureV
public float getTextureV(int index)
-
setTextureUV
public void setTextureUV(int index, float u, float v)
-
setTextureMode
public void setTextureMode(int mode)
-
setTexture
public void setTexture(PImage tex)
-
getFill
public int getFill(int index)
-
setFill
public void setFill(boolean fill)
-
setFill
public void setFill(int fill)
( begin auto-generated from PShape_setFill.xml ) 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. ( end auto-generated )- Parameters:
fill-
-
setFill
public void setFill(int index, int fill)
-
getTint
public int getTint(int index)
-
setTint
public void setTint(boolean tint)
-
setTint
public void setTint(int fill)
-
setTint
public void setTint(int index, int tint)
-
getStroke
public int getStroke(int index)
-
setStroke
public void setStroke(boolean stroke)
-
setStroke
public void setStroke(int stroke)
( begin auto-generated from PShape_setStroke.xml ) 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. ( end auto-generated )- Parameters:
stroke-
-
setStroke
public void setStroke(int index, int stroke)
-
getStrokeWeight
public float getStrokeWeight(int index)
-
setStrokeWeight
public void setStrokeWeight(float weight)
-
setStrokeWeight
public void setStrokeWeight(int index, float weight)
-
setStrokeJoin
public void setStrokeJoin(int join)
-
setStrokeCap
public void setStrokeCap(int cap)
-
getAmbient
public int getAmbient(int index)
-
setAmbient
public void setAmbient(int ambient)
-
setAmbient
public void setAmbient(int index, int ambient)
-
getSpecular
public int getSpecular(int index)
-
setSpecular
public void setSpecular(int specular)
-
setSpecular
public void setSpecular(int index, int specular)
-
getEmissive
public int getEmissive(int index)
-
setEmissive
public void setEmissive(int emissive)
-
setEmissive
public void setEmissive(int index, int emissive)
-
getShininess
public float getShininess(int index)
-
setShininess
public void setShininess(float shine)
-
setShininess
public void setShininess(int index, float shine)
-
getVertexCodes
public int[] getVertexCodes()
-
getVertexCodeCount
public int getVertexCodeCount()
-
getVertexCode
public int getVertexCode(int index)
One of VERTEX, BEZIER_VERTEX, CURVE_VERTEX, or BREAK.
-
isClosed
public boolean isClosed()
-
contains
public 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.
-
translate
public void translate(float x, float y)( begin auto-generated from PShape_translate.xml ) 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. ( end auto-generated )- Parameters:
x- left/right translationy- up/down translation- See Also:
rotate(float),scale(float),resetMatrix()
-
translate
public void translate(float x, float y, float z)- Parameters:
z- forward/back translation
-
rotateX
public 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. 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. ( end auto-generated )- Parameters:
angle- angle of rotation specified in radians- See Also:
rotate(float),rotateY(float),rotateZ(float),scale(float),translate(float, float),resetMatrix()
-
rotateY
public 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. 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. ( end auto-generated )- Parameters:
angle- angle of rotation specified in radians- See Also:
rotate(float),rotateX(float),rotateZ(float),scale(float),translate(float, float),resetMatrix()
-
rotateZ
public 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. 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. ( end auto-generated )- Parameters:
angle- angle of rotation specified in radians- See Also:
rotate(float),rotateX(float),rotateY(float),scale(float),translate(float, float),resetMatrix()
-
rotate
public void rotate(float angle)
( begin auto-generated from PShape_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() 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. ( end auto-generated )- Parameters:
angle- angle of rotation specified in radians- See Also:
rotateX(float),rotateY(float),rotateZ(float),scale(float),translate(float, float),resetMatrix()
-
rotate
public void rotate(float angle, float v0, float v1, float v2)
-
scale
public void scale(float s)
( begin auto-generated from PShape_scale.xml ) 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. ( end auto-generated )- Parameters:
s- percentate to scale the object- See Also:
rotate(float),translate(float, float),resetMatrix()
-
scale
public void scale(float x, float y)
-
scale
public void scale(float x, float y, float z)- Parameters:
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-axis
-
resetMatrix
public void resetMatrix()
( begin auto-generated from PShape_resetMatrix.xml ) Replaces the current matrix of a shape with the identity matrix. The equivalent function in OpenGL is glLoadIdentity(). ( end auto-generated )- See Also:
rotate(float),scale(float),translate(float, float)
-
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)
-
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)
-
checkMatrix
protected void checkMatrix(int dimensions)
Make sure that the shape's matrix is 1) not null, and 2) has a matrix that can handle at least the specified number of dimensions.
-
colorMode
public void colorMode(int mode)
Set the pivot point for all transformations.
-
colorMode
public void colorMode(int mode, float max)- Parameters:
max- range for all color elements
-
colorMode
public void colorMode(int mode, float maxX, float maxY, float maxZ)- Parameters:
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 mode
-
colorMode
public void colorMode(int mode, float maxX, float maxY, float maxZ, float maxA)- Parameters:
maxA- range for the alpha
-
colorCalc
protected void colorCalc(int rgb)
-
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)
-
-