|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgeomerative.RGeomElem
geomerative.RPolygon
public class RPolygon
RPolygon is a reduced interface for creating, holding and drawing complex polygons. Polygons are groups of one or more contours (RContour). This interface allows to perform binary operations (difference, xor, union and intersection) on polygons.
Field Summary | |
---|---|
RContour[] |
contours
Array of RContour objects holding the contours of the polygon. |
static int |
defaultDetail
|
int |
type
|
Fields inherited from class geomerative.RGeomElem |
---|
COMMAND, CONTOUR, GROUP, height, MESH, name, POLYGON, SHAPE, SUBSHAPE, TRISTRIP, UNKNOWN, width |
Constructor Summary | |
---|---|
RPolygon()
Create an empty polygon. |
|
RPolygon(RContour newcontour)
Create a new polygon given a contour. |
|
RPolygon(RPoint[] points)
Create a new polygon given an array of points. |
|
RPolygon(RPolygon p)
Make a copy of the given polygon. |
Method Summary | |
---|---|
void |
addClose()
|
void |
addContour()
Add an empty contour to the polygon. |
void |
addContour(RContour c)
Add a new contour to the polygon. |
void |
addContour(RPoint[] points)
Add a new contour to the polygon given an array of points. |
void |
addPoint(float x,
float y)
Add a new point to the current contour. |
void |
addPoint(int indContour,
float x,
float y)
Add a new point to the selected contour. |
void |
addPoint(int indContour,
RPoint p)
Add a new point to the selected contour. |
void |
addPoint(RPoint p)
Add a new point to the current contour. |
boolean |
contains(RPoint p)
|
int |
countContours()
Use this method to count the number of contours in the polygon. |
static RPolygon |
createCircle(float radius)
|
static RPolygon |
createCircle(float x,
float y,
float radius)
|
static RPolygon |
createCircle(float x,
float y,
float radius,
int detail)
Use this method to create a new circle polygon. |
static RPolygon |
createCircle(float radius,
int detail)
|
static RPolygon |
createRectangle(float w,
float h)
|
static RPolygon |
createRectangle(float x,
float y,
float w,
float h)
Use this method to create a new rectangle polygon. |
static RPolygon |
createRing(float radiusBig,
float radiusSmall)
|
static RPolygon |
createRing(float x,
float y,
float radiusBig,
float radiusSmall)
|
static RPolygon |
createRing(float x,
float y,
float radiusBig,
float radiusSmall,
int detail)
Use this method to create a new ring polygon. |
static RPolygon |
createRing(float radiusBig,
float radiusSmall,
int detail)
|
static RPolygon |
createStar(float x,
float y,
float radiusBig,
float radiusSmall,
int spikes)
Use this method to create a new starform polygon. |
static RPolygon |
createStar(float radiusBig,
float radiusSmall,
int spikes)
|
RPolygon |
diff(RPolygon p)
Use this method to get the difference of the given polygon with the polygon passed as atribute. |
void |
draw(processing.core.PApplet g)
|
void |
draw(processing.core.PGraphics g)
Use this method to draw the polygon. |
float |
getArea()
Use this method to get the area covered by the polygon. |
RPoint |
getCentroid()
Use this method to get the centroid of the element. |
RPoint[] |
getHandles()
Use this to return the points of the polygon. |
RPoint[][] |
getHandlesInPaths()
|
RPoint |
getPoint(float t)
|
RPoint[] |
getPoints()
Use this to return the points of the polygon. |
RPoint[][] |
getPointsInPaths()
|
RPoint |
getTangent(float t)
|
RPoint[] |
getTangents()
|
RPoint[][] |
getTangentsInPaths()
|
int |
getType()
Use this method to get the type of element this is. |
RPolygon |
intersection(RPolygon p)
Use this method to get the intersection of the given polygon with the polygon passed as atribute. |
boolean |
isHole()
Return true if this polygon is a hole. |
void |
print()
|
void |
setContour(int indContour)
Use this method to set the current contour to which append points. |
RMesh |
toMesh()
Use this method to create a new mesh from a given polygon. |
RPolygon |
toPolygon()
|
RShape |
toShape()
|
RPolygon |
union(RPolygon p)
Use this method to get the union of the given polygon with the polygon passed as atribute. |
RPolygon |
update()
Use this method to get a rebuilt version of a given polygon by removing extra points and solving intersecting contours or holes. |
RPolygon |
xor(RPolygon p)
Use this method to get the xor of the given polygon with the polygon passed as atribute. |
Methods inherited from class geomerative.RGeomElem |
---|
centerIn, centerIn, centerIn, contains, contains, containsBounds, containsHandles, draw, getBottomLeft, getBottomRight, getBounds, getBoundsPoints, getCenter, getCenteringTransf, getCenteringTransf, getCenteringTransf, getCurveLength, getCurveLengths, getHeight, getOrigHeight, getOrigWidth, getStyle, getTopLeft, getTopRight, getWidth, getX, getY, intersects, intersects, intersectsBounds, intersectsHandles, isIn, isIn, rotate, rotate, rotate, scale, scale, scale, scale, scale, scale, setAlpha, setAlpha, setAlpha, setFill, setFill, setFill, setFillAlpha, setFillAlpha, setName, setStroke, setStroke, setStroke, setStrokeAlpha, setStrokeAlpha, setStrokeCap, setStrokeJoin, setStrokeWeight, setStrokeWeight, setStyle, shear, skewX, skewY, transform, transform, transform, translate, translate |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int type
public static int defaultDetail
public RContour[] contours
Constructor Detail |
---|
public RPolygon(RPolygon p)
p
- the object of which to make a copypublic RPolygon(RPoint[] points)
points
- the points of the newly created polygon.public RPolygon(RContour newcontour)
newcontour
- the contour for the new polygon.public RPolygon()
Method Detail |
---|
public static RPolygon createCircle(float x, float y, float radius, int detail)
radius
- the radius of the circledetail
- the number of vertices of the polygon
public static RPolygon createCircle(float radius, int detail)
public static RPolygon createCircle(float x, float y, float radius)
public static RPolygon createCircle(float radius)
public static RPolygon createRectangle(float x, float y, float w, float h)
x
- the upper-left corner x coordinatey
- the upper-left corner y coordinatew
- the widthh
- the height
public static RPolygon createRectangle(float w, float h)
public static RPolygon createStar(float x, float y, float radiusBig, float radiusSmall, int spikes)
radiusBig
- the outter radius of the star polygonradiusSmall
- the inner radius of the star polygonspikes
- the amount of spikes on the star polygon
public static RPolygon createStar(float radiusBig, float radiusSmall, int spikes)
public static RPolygon createRing(float x, float y, float radiusBig, float radiusSmall, int detail)
radiusBig
- the outter radius of the ring polygonradiusSmall
- the inner radius of the ring polygondetail
- the number of vertices on each contour of the ring
public static RPolygon createRing(float radiusBig, float radiusSmall, int detail)
public static RPolygon createRing(float x, float y, float radiusBig, float radiusSmall)
public static RPolygon createRing(float radiusBig, float radiusSmall)
public RPoint getCentroid()
getCentroid
in class RGeomElem
public int countContours()
public void addContour(RContour c)
c
- the contour to be addedpublic void addContour()
public void addContour(RPoint[] points)
points
- the points of the new contour to be addedpublic void setContour(int indContour)
public void addPoint(RPoint p)
p
- the point to be addedpublic void addPoint(float x, float y)
x
- the x coordinate of the point to be addedy
- the y coordinate of the point to be addedpublic void addPoint(int indContour, RPoint p)
indContour
- the index of the contour to which the point will be addedp
- the point to be addedpublic void addPoint(int indContour, float x, float y)
indContour
- the index of the contour to which the point will be addedx
- the x coordinate of the point to be addedy
- the y coordinate of the point to be addedpublic void addClose()
public RMesh toMesh()
toMesh
in class RGeomElem
public void print()
print
in class RGeomElem
public RPolygon toPolygon()
toPolygon
in class RGeomElem
public RShape toShape()
toShape
in class RGeomElem
public RPoint[] getHandles()
getHandles
in class RGeomElem
public RPoint[] getPoints()
getPoints
in class RGeomElem
public int getType()
getType
in class RGeomElem
public float getArea()
getArea
in class RGeomElem
public void draw(processing.core.PGraphics g)
draw
in class RGeomElem
g
- PGraphics, the graphics object on which to draw the polygonpublic void draw(processing.core.PApplet g)
draw
in class RGeomElem
public RPolygon intersection(RPolygon p)
p
- RPolygon, the polygon with which to perform the intersection
public RPolygon union(RPolygon p)
p
- RPolygon, the polygon with which to perform the union
public RPolygon xor(RPolygon p)
p
- RPolygon, the polygon with which to perform the xor
public RPolygon diff(RPolygon p)
p
- RPolygon, the polygon with which to perform the difference
public RPolygon update()
public RPoint getPoint(float t)
getPoint
in class RGeomElem
public RPoint getTangent(float t)
getTangent
in class RGeomElem
public RPoint[] getTangents()
getTangents
in class RGeomElem
public RPoint[][] getPointsInPaths()
getPointsInPaths
in class RGeomElem
public RPoint[][] getHandlesInPaths()
getHandlesInPaths
in class RGeomElem
public RPoint[][] getTangentsInPaths()
getTangentsInPaths
in class RGeomElem
public boolean contains(RPoint p)
contains
in class RGeomElem
public boolean isHole()
java.lang.IllegalStateException
- if called on a complex polygon.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |