geomerative
public class RPolygon extends RGeomElem
Modifier and Type | Field and Description |
---|---|
RContour[] |
contours
Array of RContour objects holding the contours of the polygon.
|
static int |
defaultDetail |
int |
type |
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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 between this polygon and the polygon passed in as a parameter.
|
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 this polygon with the polygon passed in as a parameter.
|
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 this polygon with the polygon passed in as a parameter.
|
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 this polygon with the polygon passed in as a parameter.
|
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
public int type
public static int defaultDetail
public RContour[] contours
public RPolygon(RPolygon p)
p
- the object of which to make a copypublic RPolygon(RPoint[] points)
points
- the points for the new polygon.public RPolygon(RContour newcontour)
newcontour
- the contour for the new polygon.public RPolygon()
public static RPolygon createCircle(float x, float y, float radius, int detail)
radius
- the radius of the circledetail
- the number of vertices of the polygonpublic 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 heightpublic 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 polygonpublic 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 ringpublic 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()
public RPoint[] getHandles()
getHandles
in class RGeomElem
public RPoint[] getPoints()
public int getType()
public float getArea()
public void draw(processing.core.PGraphics g)
public RPolygon intersection(RPolygon p)
p
- RPolygon, the polygon with which to perform the intersectionpublic RPolygon union(RPolygon p)
p
- RPolygon, the polygon with which to perform the unionpublic RPolygon xor(RPolygon p)
p
- RPolygon, the polygon with which to perform the xorpublic RPolygon diff(RPolygon p)
p
- RPolygon, the polygon with which to perform the differencepublic RPolygon update()
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 isHole()
java.lang.IllegalStateException
- if called on a complex polygon.Geomerative by Ricard Marxer, http://www.ricardmarxer.com/geomerative/