public class Rectangle extends Shape
Modifier and Type | Field and Description |
---|---|
protected float |
height
The height of the box
|
protected float |
width
The width of the box
|
boundingCircleRadius, center, maxX, maxY, minX, minY, points, pointsDirty, trianglesDirty, tris, x, y
Constructor and Description |
---|
Rectangle(float x,
float y,
float width,
float height)
Create a new bounding box
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(float xp,
float yp)
Check if this rectangle contains a point
|
static boolean |
contains(float xp,
float yp,
float xr,
float yr,
float widthr,
float heightr)
Check if a rectangle contains a point (static to use it everywhere)
|
protected void |
createPoints()
Subclasses implement this to create the points of the shape.
|
float |
getHeight()
Get the height of the box
|
float |
getWidth()
Get the width of the box
|
void |
grow(float h,
float v)
Grow the rectangle at all edges by the given amounts.
|
boolean |
intersects(Shape shape)
Check if this box touches another
|
void |
scaleGrow(float h,
float v)
Grow the rectangle based on scaling it's size
|
void |
setBounds(float x,
float y,
float width,
float height)
Set the bounds of this rectangle
|
void |
setBounds(Rectangle other)
Set the bounds of this rectangle based on the given rectangle
|
void |
setHeight(float height)
Set the heightof this box
|
void |
setSize(float width,
float height)
Set the size (widtha and height) of this rectangle
|
void |
setWidth(float width)
Set the width of this box
|
java.lang.String |
toString() |
Shape |
transform(Transform transform)
Apply a transformation and return a new shape.
|
calculateRadius, calculateTriangles, checkPoints, closed, contains, findCenter, getBoundingCircleRadius, getCenter, getCenterX, getCenterY, getLocation, getMaxX, getMaxY, getMinX, getMinY, getNormal, getPoint, getPointCount, getPoints, getTriangles, getX, getY, hasVertex, includes, increaseTriangulation, indexOf, preCache, prune, setCenterX, setCenterY, setLocation, setLocation, setX, setY, subtract, union
protected float width
protected float height
public Rectangle(float x, float y, float width, float height)
x
- The x position of the boxy
- The y position of the boxwidth
- The width of the boxheight
- The hieght of the boxpublic boolean contains(float xp, float yp)
public void setBounds(Rectangle other)
other
- The other rectangle whose bounds should be appliedpublic void setBounds(float x, float y, float width, float height)
x
- The x coordinate of this rectangley
- The y coordinate of this rectanglewidth
- The width to set in this rectangleheight
- The height to set in this rectanglepublic void setSize(float width, float height)
width
- The width to set in this rectangleheight
- The height to set in this rectanglepublic float getWidth()
public float getHeight()
public void grow(float h, float v)
h
- The amount to adjust horizontallyv
- The amount to ajust verticallypublic void scaleGrow(float h, float v)
h
- The scale to apply to the horizontalv
- The scale to appy to the verticalpublic void setWidth(float width)
width
- The new width of this boxpublic void setHeight(float height)
height
- The height of this boxpublic boolean intersects(Shape shape)
intersects
in class Shape
shape
- The other shape to check againstprotected void createPoints()
Shape
createPoints
in class Shape
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public static boolean contains(float xp, float yp, float xr, float yr, float widthr, float heightr)
xp
- The x coordinate of the point to checkyp
- The y coordinate of the point to checkxr
- The x coordinate of the rectangleyr
- The y coordinate of the rectanglewidthr
- The width of the rectangleheightr
- The height of the rectangle