public class Rectangle extends Object implements Serializable, Shape2D
Modifier and Type | Field and Description |
---|---|
float |
height |
static Rectangle |
tmp
Static temporary rectangle.
|
static Rectangle |
tmp2
Static temporary rectangle.
|
float |
width |
float |
x |
float |
y |
Constructor and Description |
---|
Rectangle()
Constructs a new rectangle with all values set to zero
|
Rectangle(float x,
float y,
float width,
float height)
Constructs a new rectangle with the given corner point in the bottom left and dimensions.
|
Rectangle(Rectangle rect)
Constructs a rectangle based on the given rectangle
|
Modifier and Type | Method and Description |
---|---|
float |
area() |
boolean |
contains(float x,
float y) |
boolean |
contains(Rectangle rectangle) |
boolean |
contains(Vector2 point) |
boolean |
equals(Object obj) |
Rectangle |
fitInside(Rectangle rect)
Fits this rectangle into another rectangle while maintaining aspect ratio.
|
Rectangle |
fitOutside(Rectangle rect)
Fits this rectangle around another rectangle while maintaining aspect ratio.
|
float |
getAspectRatio()
Calculates the aspect ratio ( width / height ) of this rectangle
|
Vector2 |
getCenter(Vector2 vector)
Calculates the center of the rectangle.
|
float |
getHeight() |
Vector2 |
getPosition(Vector2 position)
return the Vector2 with coordinates of this rectangle
|
Vector2 |
getSize(Vector2 size) |
float |
getWidth() |
float |
getX() |
float |
getY() |
int |
hashCode() |
Rectangle |
merge(float x,
float y)
Merges this rectangle with a point.
|
Rectangle |
merge(Rectangle rect)
Merges this rectangle with the other rectangle.
|
Rectangle |
merge(Vector2 vec)
Merges this rectangle with a point.
|
Rectangle |
merge(Vector2[] vecs)
Merges this rectangle with a list of points.
|
boolean |
overlaps(Rectangle r) |
float |
perimeter() |
Rectangle |
set(float x,
float y,
float width,
float height) |
Rectangle |
set(Rectangle rect)
Sets the values of the given rectangle to this rectangle.
|
Rectangle |
setCenter(float x,
float y)
Moves this rectangle so that its center point is located at a given position
|
Rectangle |
setCenter(Vector2 position)
Moves this rectangle so that its center point is located at a given position
|
Rectangle |
setHeight(float height)
Sets the height of this rectangle
|
Rectangle |
setPosition(float x,
float y)
Sets the x and y-coordinates of the bottom left corner
|
Rectangle |
setPosition(Vector2 position)
Sets the x and y-coordinates of the bottom left corner from vector
|
Rectangle |
setSize(float sizeXY)
Sets the squared size of this rectangle
|
Rectangle |
setSize(float width,
float height)
Sets the width and height of this rectangle
|
Rectangle |
setWidth(float width)
Sets the width of this rectangle
|
Rectangle |
setX(float x)
Sets the x-coordinate of the bottom left corner
|
Rectangle |
setY(float y)
Sets the y-coordinate of the bottom left corner
|
String |
toString() |
public static final Rectangle tmp
public static final Rectangle tmp2
public float x
public float y
public float width
public float height
public Rectangle()
public Rectangle(float x, float y, float width, float height)
x
- The corner point x-coordinatey
- The corner point y-coordinatewidth
- The widthheight
- The heightpublic Rectangle(Rectangle rect)
rect
- The rectanglepublic Rectangle set(float x, float y, float width, float height)
x
- bottom-left x coordinatey
- bottom-left y coordinatewidth
- widthheight
- heightpublic float getX()
public Rectangle setX(float x)
x
- The x-coordinatepublic float getY()
public Rectangle setY(float y)
y
- The y-coordinatepublic float getWidth()
public Rectangle setWidth(float width)
width
- The widthpublic float getHeight()
public Rectangle setHeight(float height)
height
- The heightpublic Vector2 getPosition(Vector2 position)
position
- The Vector2public Rectangle setPosition(Vector2 position)
position
- The position vectorpublic Rectangle setPosition(float x, float y)
x
- The x-coordinatey
- The y-coordinatepublic Rectangle setSize(float width, float height)
width
- The widthheight
- The heightpublic Rectangle setSize(float sizeXY)
sizeXY
- The sizepublic Vector2 getSize(Vector2 size)
size
- The Vector2public boolean contains(float x, float y)
x
- point x coordinatey
- point y coordinatepublic boolean contains(Vector2 point)
point
- The coordinates vectorpublic boolean contains(Rectangle rectangle)
rectangle
- the other Rectangle
.public boolean overlaps(Rectangle r)
r
- the other Rectangle
public Rectangle set(Rectangle rect)
rect
- the other rectanglepublic Rectangle merge(Rectangle rect)
rect
- the other rectanglepublic Rectangle merge(float x, float y)
x
- the x coordinate of the pointy
- the y coordinate of the pointpublic Rectangle merge(Vector2 vec)
vec
- the vector describing the pointpublic Rectangle merge(Vector2[] vecs)
vecs
- the vectors describing the pointspublic float getAspectRatio()
public Vector2 getCenter(Vector2 vector)
vector
- the Vector2 to usepublic Rectangle setCenter(float x, float y)
x
- the position's xy
- the position's ypublic Rectangle setCenter(Vector2 position)
position
- the positionpublic Rectangle fitOutside(Rectangle rect)
rect
- the other rectangle to fit this rectangle aroundpublic Rectangle fitInside(Rectangle rect)
rect
- the other rectangle to fit this rectangle insidepublic float area()
public float perimeter()
Copyright © 2014. All rights reserved.