Class SdlRect
- java.lang.Object
-
- io.github.libsdl4j.api.rect.SdlRect
-
public final class SdlRect extends Object
Definitions from file SDL_rect.hHeader file for SDL_rect definition and management functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
SDL_EncloseFPoints(List<SDL_FPoint> points, SDL_FRect clip, SDL_FRect result)
Calculate a minimal rectangle enclosing a set of points with float precision.static boolean
SDL_EnclosePoints(List<SDL_Point> points, SDL_Rect clip, SDL_Rect result)
Calculate a minimal rectangle enclosing a set of points.static boolean
SDL_FRectEmpty(SDL_FRect r)
Returns true if the rectangle has no area.static boolean
SDL_FRectEquals(SDL_FRect a, SDL_FRect b)
Returns true if the two rectangles are equal, using a default epsilon.static boolean
SDL_FRectEqualsEpsilon(SDL_FRect a, SDL_FRect b, float epsilon)
Returns true if the two rectangles are equal, within some given epsilon.static boolean
SDL_HasIntersection(SDL_Rect a, SDL_Rect b)
Determine whether two rectangles intersect.static boolean
SDL_HasIntersectionF(SDL_FRect a, SDL_FRect b)
Determine whether two rectangles intersect with float precision.static boolean
SDL_IntersectFRect(SDL_FRect a, SDL_FRect b, SDL_FRect result)
Calculate the intersection of two rectangles with float precision.static boolean
SDL_IntersectFRectAndLine(SDL_FRect rect, FloatRef lineX1, FloatRef lineY1, FloatRef lineX2, FloatRef lineY2)
Calculate the intersection of a rectangle and line segment with float precision.static boolean
SDL_IntersectRect(SDL_Rect a, SDL_Rect b, SDL_Rect result)
Calculate the intersection of two rectangles.static boolean
SDL_IntersectRectAndLine(SDL_Rect rect, IntRef lineX1, IntRef lineY1, IntRef lineX2, IntRef lineY2)
Calculate the intersection of a rectangle and line segment.static boolean
SDL_PointInFRect(SDL_FPoint p, SDL_FRect r)
Returns true if point resides inside a rectangle.static boolean
SDL_PointInRect(SDL_Point p, SDL_Rect r)
Returns true if point resides inside a rectangle.static boolean
SDL_RectEmpty(SDL_Rect r)
Returns true if the rectangle has no area.static boolean
SDL_RectEquals(SDL_Rect a, SDL_Rect b)
Returns true if the two rectangles are equal.static void
SDL_UnionFRect(SDL_FRect a, SDL_FRect b, SDL_FRect result)
Calculate the union of two rectangles with float precision.static void
SDL_UnionRect(SDL_Rect a, SDL_Rect b, SDL_Rect result)
Calculate the union of two rectangles.
-
-
-
Method Detail
-
SDL_PointInRect
public static boolean SDL_PointInRect(SDL_Point p, SDL_Rect r)
Returns true if point resides inside a rectangle.
-
SDL_RectEmpty
public static boolean SDL_RectEmpty(SDL_Rect r)
Returns true if the rectangle has no area.
-
SDL_RectEquals
public static boolean SDL_RectEquals(SDL_Rect a, SDL_Rect b)
Returns true if the two rectangles are equal.
-
SDL_HasIntersection
public static boolean SDL_HasIntersection(SDL_Rect a, SDL_Rect b)
Determine whether two rectangles intersect.If either pointer is null the function will return false.
- Parameters:
a
- an SDL_Rect structure representing the first rectangleb
- an SDL_Rect structure representing the second rectangle- Returns:
- true if there is an intersection, false otherwise.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_IntersectRect(SDL_Rect, SDL_Rect, SDL_Rect)
-
SDL_IntersectRect
public static boolean SDL_IntersectRect(SDL_Rect a, SDL_Rect b, SDL_Rect result)
Calculate the intersection of two rectangles.If
result
is null then this function will return false.- Parameters:
a
- an SDL_Rect structure representing the first rectangleb
- an SDL_Rect structure representing the second rectangleresult
- an SDL_Rect structure filled in with the intersection of rectanglesa
andb
- Returns:
- true if there is an intersection, false otherwise.
- Since:
- This function is available since SDL 2.0.0.
- See Also:
SDL_HasIntersection(SDL_Rect, SDL_Rect)
-
SDL_UnionRect
public static void SDL_UnionRect(SDL_Rect a, SDL_Rect b, SDL_Rect result)
Calculate the union of two rectangles.- Parameters:
a
- an SDL_Rect structure representing the first rectangleb
- an SDL_Rect structure representing the second rectangleresult
- an SDL_Rect structure filled in with the union of rectanglesa
andb
- Since:
- This function is available since SDL 2.0.0.
-
SDL_EnclosePoints
public static boolean SDL_EnclosePoints(List<SDL_Point> points, SDL_Rect clip, SDL_Rect result)
Calculate a minimal rectangle enclosing a set of points.If
clip
is not null then only points inside of the clipping rectangle are considered.This is a Java-style version of a raw C-style function. Prefer it over the other.
- Parameters:
points
- aContiguousArrayList
of SDL_Point structures representing points to be enclosedclip
- an SDL_Rect used for clipping or null to enclose all pointsresult
- an SDL_Rect structure filled in with the minimal enclosing rectangle- Returns:
- true if any points were enclosed or false if all the points were outside of the clipping rectangle.
- Since:
- This function is available since SDL 2.0.0.
-
SDL_IntersectRectAndLine
public static boolean SDL_IntersectRectAndLine(SDL_Rect rect, IntRef lineX1, IntRef lineY1, IntRef lineX2, IntRef lineY2)
Calculate the intersection of a rectangle and line segment.This function is used to clip a line segment to a rectangle. A line segment contained entirely within the rectangle or that does not intersect will remain unchanged. A line segment that crosses the rectangle at either or both ends will be clipped to the boundary of the rectangle and the new coordinates saved in
lineX1
,lineY1
,lineX2
, and/orlineY2
as necessary.- Parameters:
rect
- an SDL_Rect structure representing the rectangle to intersectlineX1
- a pointer to the starting X-coordinate of the linelineY1
- a pointer to the starting Y-coordinate of the linelineX2
- a pointer to the ending X-coordinate of the linelineY2
- a pointer to the ending Y-coordinate of the line- Returns:
- true if there is an intersection, false otherwise.
- Since:
- This function is available since SDL 2.0.0.
-
SDL_PointInFRect
public static boolean SDL_PointInFRect(SDL_FPoint p, SDL_FRect r)
Returns true if point resides inside a rectangle.
-
SDL_FRectEmpty
public static boolean SDL_FRectEmpty(SDL_FRect r)
Returns true if the rectangle has no area.
-
SDL_FRectEqualsEpsilon
public static boolean SDL_FRectEqualsEpsilon(SDL_FRect a, SDL_FRect b, float epsilon)
Returns true if the two rectangles are equal, within some given epsilon.- Since:
- This function is available since SDL 2.0.22.
-
SDL_FRectEquals
public static boolean SDL_FRectEquals(SDL_FRect a, SDL_FRect b)
Returns true if the two rectangles are equal, using a default epsilon.- Since:
- This function is available since SDL 2.0.22.
-
SDL_HasIntersectionF
public static boolean SDL_HasIntersectionF(SDL_FRect a, SDL_FRect b)
Determine whether two rectangles intersect with float precision.If either pointer is null the function will return false.
- Parameters:
a
- an SDL_FRect structure representing the first rectangleb
- an SDL_FRect structure representing the second rectangle- Returns:
- true if there is an intersection, false otherwise.
- Since:
- This function is available since SDL 2.0.22.
- See Also:
SDL_IntersectRect(SDL_Rect, SDL_Rect, SDL_Rect)
-
SDL_IntersectFRect
public static boolean SDL_IntersectFRect(SDL_FRect a, SDL_FRect b, SDL_FRect result)
Calculate the intersection of two rectangles with float precision.If
result
is null then this function will return false.- Parameters:
a
- an SDL_FRect structure representing the first rectangleb
- an SDL_FRect structure representing the second rectangleresult
- an SDL_FRect structure filled in with the intersection of rectanglesa
andb
- Returns:
- true if there is an intersection, false otherwise.
- Since:
- This function is available since SDL 2.0.22.
- See Also:
SDL_HasIntersectionF(SDL_FRect, SDL_FRect)
-
SDL_UnionFRect
public static void SDL_UnionFRect(SDL_FRect a, SDL_FRect b, SDL_FRect result)
Calculate the union of two rectangles with float precision.- Parameters:
a
- an SDL_FRect structure representing the first rectangleb
- an SDL_FRect structure representing the second rectangleresult
- an SDL_FRect structure filled in with the union of rectanglesa
andb
- Since:
- This function is available since SDL 2.0.22.
-
SDL_EncloseFPoints
public static boolean SDL_EncloseFPoints(List<SDL_FPoint> points, SDL_FRect clip, SDL_FRect result)
Calculate a minimal rectangle enclosing a set of points with float precision.If
clip
is not null then only points inside of the clipping rectangle are considered.This is a Java-style version of a raw C-style function. Prefer it over the other.
- Parameters:
points
- aList
of SDL_FPoint structures representing points to be enclosedclip
- an SDL_FRect used for clipping or null to enclose all pointsresult
- an SDL_FRect structure filled in with the minimal enclosing rectangle- Returns:
- true if any points were enclosed or false if all the points were outside of the clipping rectangle.
- Since:
- This function is available since SDL 2.0.22.
-
SDL_IntersectFRectAndLine
public static boolean SDL_IntersectFRectAndLine(SDL_FRect rect, FloatRef lineX1, FloatRef lineY1, FloatRef lineX2, FloatRef lineY2)
Calculate the intersection of a rectangle and line segment with float precision.This function is used to clip a line segment to a rectangle. A line segment contained entirely within the rectangle or that does not intersect will remain unchanged. A line segment that crosses the rectangle at either or both ends will be clipped to the boundary of the rectangle and the new coordinates saved in
lineX1
,lineY1
,lineX2
, and/orlineY2
as necessary.- Parameters:
rect
- an SDL_FRect structure representing the rectangle to intersectlineX1
- a pointer to the starting X-coordinate of the linelineY1
- a pointer to the starting Y-coordinate of the linelineX2
- a pointer to the ending X-coordinate of the linelineY2
- a pointer to the ending Y-coordinate of the line- Returns:
- true if there is an intersection, false otherwise.
- Since:
- This function is available since SDL 2.0.22.
-
-