Class SdlRect


  • public final class SdlRect
    extends Object
    Definitions from file SDL_rect.h

    Header file for SDL_rect definition and management functions.

    • 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 rectangle
        b - 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 rectangle
        b - an SDL_Rect structure representing the second rectangle
        result - an SDL_Rect structure filled in with the intersection of rectangles a and b
        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 rectangle
        b - an SDL_Rect structure representing the second rectangle
        result - an SDL_Rect structure filled in with the union of rectangles a and b
        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 - a ContiguousArrayList of SDL_Point structures representing points to be enclosed
        clip - an SDL_Rect used for clipping or null to enclose all points
        result - 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/or lineY2 as necessary.

        Parameters:
        rect - an SDL_Rect structure representing the rectangle to intersect
        lineX1 - a pointer to the starting X-coordinate of the line
        lineY1 - a pointer to the starting Y-coordinate of the line
        lineX2 - a pointer to the ending X-coordinate of the line
        lineY2 - 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 rectangle
        b - 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 rectangle
        b - an SDL_FRect structure representing the second rectangle
        result - an SDL_FRect structure filled in with the intersection of rectangles a and b
        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 rectangle
        b - an SDL_FRect structure representing the second rectangle
        result - an SDL_FRect structure filled in with the union of rectangles a and b
        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 - a List of SDL_FPoint structures representing points to be enclosed
        clip - an SDL_FRect used for clipping or null to enclose all points
        result - 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/or lineY2 as necessary.

        Parameters:
        rect - an SDL_FRect structure representing the rectangle to intersect
        lineX1 - a pointer to the starting X-coordinate of the line
        lineY1 - a pointer to the starting Y-coordinate of the line
        lineX2 - a pointer to the ending X-coordinate of the line
        lineY2 - 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.