Package io.github.srcimon.screwbox.core
Class Bounds
java.lang.Object
io.github.srcimon.screwbox.core.Bounds
- All Implemented Interfaces:
Serializable
Bounds
represents a space in the 2d world. It's defined by its
position()
(center of the area) and its extents()
(the Vector
from the center to it's lower right corner. The origin()
defines the upper left corner.- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic Bounds
$$
(double x, double y, double width, double height) allIntersecting
(List<Bounds> others) static Bounds
atOrigin
(double x, double y, double width, double height) static Bounds
static Bounds
atPosition
(double x, double y, double width, double height) Creates a newBounds
at the givenposition()
.static Bounds
atPosition
(Vector position, double width, double height) Creates a newBounds
at the givenposition()
.boolean
Checks if the given position is within thisBounds
.boolean
extents()
int
hashCode()
double
height()
Returns the height of thisBounds
.inflated
(double inflation) inflatedTop
(int value) intersection
(Bounds other) boolean
intersects
(Bounds other) static Bounds
max()
double
maxX()
double
maxY()
double
minX()
double
minY()
moveBy
(double x, double y) Returns a instance of thisBounds
that was moved by the given X and Y values to a new position.Returns a instance of thisBounds
that was moved to the givenposition
.origin()
double
overlapArea
(Bounds other) position()
size()
Returns the size of theBounds
.topRight()
toString()
boolean
double
width()
Returns the width of thisBounds
.
-
Method Details
-
atPosition
Creates a newBounds
at the givenposition()
.- See Also:
-
atPosition
Creates a newBounds
at the givenposition()
.- See Also:
-
atOrigin
- See Also:
-
$$
- See Also:
-
atOrigin
- See Also:
-
max
-
contains
Checks if the given position is within thisBounds
. -
moveBy
Returns a instance of thisBounds
that was moved by the givenVector
to a new position.width()
andheight()
stay the same.- See Also:
-
moveBy
Returns a instance of thisBounds
that was moved by the given X and Y values to a new position.width()
andheight()
stay the same.- See Also:
-
moveTo
Returns a instance of thisBounds
that was moved to the givenposition
.width()
andheight()
stay the same.- See Also:
-
origin
-
size
Returns the size of theBounds
. -
inflated
Returns a new instance ofBounds
at the sameposition()
but with differentsize()
. Positive values increase thesize()
, negative one decreases thesize()
. -
inflatedTop
-
touches
Checks if thisBounds
touches anotherBounds
. Is alsotrue
if itintersects(Bounds)
the otherBounds
.- See Also:
-
intersects
- See Also:
-
width
public double width()Returns the width of thisBounds
. -
height
public double height()Returns the height of thisBounds
. -
overlapArea
-
extents
-
minX
public double minX() -
maxX
public double maxX() -
minY
public double minY() -
maxY
public double maxY() -
toString
-
position
-
hashCode
public int hashCode() -
equals
-
bottomLeft
-
bottomRight
-
topRight
-
intersection
Returns the intersection area between thisBounds
and the otherBounds
. ReturnsOptional.empty()
if there is no intersection between bothBounds
.- See Also:
-
allIntersecting
-