include/SDL_rect.h
changeset 3407 d3baf5ac4e37
parent 2909 3da0bb421d83
child 3536 0267b8b1595c
equal deleted inserted replaced
3406:8ae607392409 3407:d3baf5ac4e37
    19     Sam Lantinga
    19     Sam Lantinga
    20     slouken@libsdl.org
    20     slouken@libsdl.org
    21 */
    21 */
    22 
    22 
    23 /**
    23 /**
    24  * \file SDL_rect.h
    24  *  \file SDL_rect.h
    25  *
    25  *  
    26  * Header file for SDL_rect definition and management functions
    26  *  Header file for SDL_rect definition and management functions.
    27  */
    27  */
    28 
    28 
    29 #ifndef _SDL_rect_h
    29 #ifndef _SDL_rect_h
    30 #define _SDL_rect_h
    30 #define _SDL_rect_h
    31 
    31 
    41 extern "C" {
    41 extern "C" {
    42 /* *INDENT-ON* */
    42 /* *INDENT-ON* */
    43 #endif
    43 #endif
    44 
    44 
    45 /**
    45 /**
    46  * \struct SDL_Rect
    46  *  \brief A rectangle, with the origin at the upper left.
    47  *
    47  *  
    48  * \brief A rectangle, with the origin at the upper left.
    48  *  \sa SDL_RectEmpty
    49  *
    49  *  \sa SDL_RectEquals
    50  * \sa SDL_RectEmpty
    50  *  \sa SDL_HasIntersection
    51  * \sa SDL_RectEquals
    51  *  \sa SDL_IntersectRect
    52  * \sa SDL_HasIntersection
    52  *  \sa SDL_UnionRect
    53  * \sa SDL_IntersectRect
       
    54  * \sa SDL_UnionRect
       
    55  */
    53  */
    56 typedef struct SDL_Rect
    54 typedef struct SDL_Rect
    57 {
    55 {
    58     int x, y;
    56     int x, y;
    59     int w, h;
    57     int w, h;
    60 } SDL_Rect;
    58 } SDL_Rect;
    61 
    59 
    62 /**
    60 /**
    63  * \def SDL_RectEmpty()
    61  *  \brief Returns true if the rectangle has no area.
    64  *
       
    65  * \brief Returns true if the rectangle has no area.
       
    66  */
    62  */
    67 #define SDL_RectEmpty(X)    (((X)->w <= 0) || ((X)->h <= 0))
    63 #define SDL_RectEmpty(X)    (((X)->w <= 0) || ((X)->h <= 0))
    68 
    64 
    69 /**
    65 /**
    70  * \def SDL_RectEquals()
    66  *  \brief Returns true if the two rectangles are equal.
    71  *
       
    72  * \brief Returns true if the two rectangles are equal.
       
    73  */
    67  */
    74 #define SDL_RectEquals(A, B)   (((A)->x == (B)->x) && ((A)->y == (B)->y) && \
    68 #define SDL_RectEquals(A, B)   (((A)->x == (B)->x) && ((A)->y == (B)->y) && \
    75                                 ((A)->w == (B)->w) && ((A)->h == (B)->h))
    69                                 ((A)->w == (B)->w) && ((A)->h == (B)->h))
    76 
    70 
    77 /**
    71 /**
    78  * \fn SDL_bool SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B);
    72  *  \brief Determine whether two rectangles intersect.
    79  *
    73  *  
    80  * \brief Determine whether two rectangles intersect.
    74  *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
    81  *
       
    82  * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
       
    83  */
    75  */
    84 extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
    76 extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
    85                                                      const SDL_Rect * B);
    77                                                      const SDL_Rect * B);
    86 
    78 
    87 /**
    79 /**
    88  * \fn SDL_bool SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
    80  *  \brief Calculate the intersection of two rectangles.
    89  *
    81  *  
    90  * \brief Calculate the intersection of two rectangles.
    82  *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
    91  *
       
    92  * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
       
    93  */
    83  */
    94 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
    84 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
    95                                                    const SDL_Rect * B,
    85                                                    const SDL_Rect * B,
    96                                                    SDL_Rect * result);
    86                                                    SDL_Rect * result);
    97 
    87 
    98 /**
    88 /**
    99  * \fn void SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result)
    89  *  \brief Calculate the union of two rectangles.
   100  *
       
   101  * \brief Calculate the union of two rectangles
       
   102  */
    90  */
   103 extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
    91 extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
   104                                            const SDL_Rect * B,
    92                                            const SDL_Rect * B,
   105                                            SDL_Rect * result);
    93                                            SDL_Rect * result);
   106 
    94 
   107 /**
    95 /**
   108  * \fn SDL_bool SDL_IntersectRectAndLine(const SDL_Rect *rect, int *X1, int *Y1, int *X2, int *Y2)
    96  *  \brief Calculate the intersection of a rectangle and line segment.
   109  *
    97  *  
   110  * \brief Calculate the intersection of a rectangle and line segment.
    98  *  \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
   111  *
       
   112  * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
       
   113  */
    99  */
   114 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
   100 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
   115                                                           rect, int *X1,
   101                                                           rect, int *X1,
   116                                                           int *Y1, int *X2,
   102                                                           int *Y1, int *X2,
   117                                                           int *Y2);
   103                                                           int *Y2);