Constructor and Description |
---|
Polygon()
Constructs a new polygon with no vertices.
|
Polygon(float[] vertices)
Constructs a new polygon from a float array of parts of vertex points.
|
Modifier and Type | Method and Description |
---|---|
float |
area()
Returns the area contained within the polygon.
|
boolean |
contains(float x,
float y)
Returns whether an x, y pair is contained within the polygon.
|
void |
dirty()
Sets the polygon's world vertices to be recalculated when calling
getTransformedVertices . |
Rectangle |
getBoundingRectangle()
Returns an axis-aligned bounding box of this polygon.
|
float |
getOriginX()
Returns the x-coordinate of the polygon's origin point.
|
float |
getOriginY()
Returns the y-coordinate of the polygon's origin point.
|
float |
getRotation()
Returns the total rotation applied to the polygon.
|
float |
getScaleX()
Returns the total horizontal scaling applied to the polygon.
|
float |
getScaleY()
Returns the total vertical scaling applied to the polygon.
|
float[] |
getTransformedVertices()
Calculates and returns the vertices of the polygon after scaling, rotation, and positional translations have been applied,
as they are position within the world.
|
float[] |
getVertices()
Returns the polygon's local vertices without scaling or rotation and without being offset by the polygon position.
|
float |
getX()
Returns the x-coordinate of the polygon's position within the world.
|
float |
getY()
Returns the y-coordinate of the polygon's position within the world.
|
void |
rotate(float degrees)
Applies additional rotation to the polygon by the supplied degrees.
|
void |
scale(float amount)
Applies additional scaling to the polygon by the supplied amount.
|
void |
setOrigin(float originX,
float originY)
Sets the origin point to which all of the polygon's local vertices are relative to.
|
void |
setPosition(float x,
float y)
Sets the polygon's position within the world.
|
void |
setRotation(float degrees)
Sets the polygon to be rotated by the supplied degrees.
|
void |
setScale(float scaleX,
float scaleY)
Sets the amount of scaling to be applied to the polygon.
|
void |
setVertices(float[] vertices)
Sets the polygon's local vertices relative to the origin point, without any scaling, rotating or translations being applied.
|
void |
translate(float x,
float y)
Translates the polygon's position by the specified horizontal and vertical amounts.
|
public Polygon()
public Polygon(float[] vertices)
vertices
- an array where every even element represents the horizontal part of a point, and the following element
representing the vertical partIllegalArgumentException
- if less than 6 elements, representing 3 points, are providedpublic float[] getVertices()
public float[] getTransformedVertices()
public void setOrigin(float originX, float originY)
public void setPosition(float x, float y)
public void setVertices(float[] vertices)
vertices
- float array where every even element represents the x-coordinate of a vertex, and the proceeding element
representing the y-coordinate.IllegalArgumentException
- if less than 6 elements, representing 3 points, are providedpublic void translate(float x, float y)
public void setRotation(float degrees)
public void rotate(float degrees)
public void setScale(float scaleX, float scaleY)
public void scale(float amount)
public void dirty()
getTransformedVertices
.public float area()
public Rectangle getBoundingRectangle()
Rectangle
public boolean contains(float x, float y)
public float getX()
public float getY()
public float getOriginX()
public float getOriginY()
public float getRotation()
public float getScaleX()
public float getScaleY()
Copyright © 2014. All rights reserved.