|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.badlogic.gdx.math.Rectangle
public class Rectangle
Encapsulates a 2D rectangle defined by it's bottom corner point and its extends in x (width) and y (height).
Field Summary | |
---|---|
float |
height
|
static Rectangle |
tmp
Static temporary rectangle. |
static Rectangle |
tmp2
Static temporary rectangle. |
float |
width
|
float |
x
|
float |
y
|
Constructor Summary | |
---|---|
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 |
Method Summary | |
---|---|
boolean |
contains(float x,
float y)
|
boolean |
contains(Rectangle rectangle)
|
boolean |
contains(Vector2 vector)
|
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 This scales and centers the rectangle to the other rectangle (e.g. |
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()
|
Rectangle |
merge(Rectangle rect)
Merges this rectangle with the other rectangle. |
boolean |
overlaps(Rectangle r)
|
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()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Rectangle tmp
public static final Rectangle tmp2
public float x
public float y
public float width
public float height
Constructor Detail |
---|
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 rectangleMethod Detail |
---|
public Rectangle set(float x, float y, float width, float height)
x
- bottom-left x coordinatey
- bottom-left y coordinatewidth
- widthheight
- height
public float getX()
public Rectangle setX(float x)
x
- The x-coordinate
public float getY()
public Rectangle setY(float y)
y
- The y-coordinate
public float getWidth()
public Rectangle setWidth(float width)
width
- The width
public float getHeight()
public Rectangle setHeight(float height)
height
- The height
public Vector2 getPosition(Vector2 position)
position
- The Vector2public Rectangle setPosition(Vector2 position)
position
- The position vector
public Rectangle setPosition(float x, float y)
x
- The x-coordinatey
- The y-coordinate
public Rectangle setSize(float width, float height)
width
- The widthheight
- The height
public Rectangle setSize(float sizeXY)
sizeXY
- The size
public Vector2 getSize(Vector2 size)
size
- The Vector2
public boolean contains(float x, float y)
x
- point x coordinatey
- point y coordinate
public boolean contains(Vector2 vector)
vector
- The coordinates vector
public 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 rectangle
public Rectangle merge(Rectangle rect)
rect
- the other rectangle
public float getAspectRatio()
public Vector2 getCenter(Vector2 vector)
vector
- the Vector2 to use
public Rectangle setCenter(float x, float y)
x
- the position's xy
- the position's y
public Rectangle setCenter(Vector2 position)
position
- the position
public Rectangle fitOutside(Rectangle rect)
rect
- the other rectangle to fit this rectangle around
public Rectangle fitInside(Rectangle rect)
rect
- the other rectangle to fit this rectangle inside
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |