SDL Library

Dependents:   H261_decoder

Committer:
miruga27
Date:
Thu Sep 22 00:03:09 2016 +0000
Revision:
0:7fb6877b5d7c
SDL

Who changed what in which revision?

UserRevisionLine numberNew contents of line
miruga27 0:7fb6877b5d7c 1 /*
miruga27 0:7fb6877b5d7c 2 Simple DirectMedia Layer
miruga27 0:7fb6877b5d7c 3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
miruga27 0:7fb6877b5d7c 4
miruga27 0:7fb6877b5d7c 5 This software is provided 'as-is', without any express or implied
miruga27 0:7fb6877b5d7c 6 warranty. In no event will the authors be held liable for any damages
miruga27 0:7fb6877b5d7c 7 arising from the use of this software.
miruga27 0:7fb6877b5d7c 8
miruga27 0:7fb6877b5d7c 9 Permission is granted to anyone to use this software for any purpose,
miruga27 0:7fb6877b5d7c 10 including commercial applications, and to alter it and redistribute it
miruga27 0:7fb6877b5d7c 11 freely, subject to the following restrictions:
miruga27 0:7fb6877b5d7c 12
miruga27 0:7fb6877b5d7c 13 1. The origin of this software must not be misrepresented; you must not
miruga27 0:7fb6877b5d7c 14 claim that you wrote the original software. If you use this software
miruga27 0:7fb6877b5d7c 15 in a product, an acknowledgment in the product documentation would be
miruga27 0:7fb6877b5d7c 16 appreciated but is not required.
miruga27 0:7fb6877b5d7c 17 2. Altered source versions must be plainly marked as such, and must not be
miruga27 0:7fb6877b5d7c 18 misrepresented as being the original software.
miruga27 0:7fb6877b5d7c 19 3. This notice may not be removed or altered from any source distribution.
miruga27 0:7fb6877b5d7c 20 */
miruga27 0:7fb6877b5d7c 21
miruga27 0:7fb6877b5d7c 22 /**
miruga27 0:7fb6877b5d7c 23 * \file SDL_rect.h
miruga27 0:7fb6877b5d7c 24 *
miruga27 0:7fb6877b5d7c 25 * Header file for SDL_rect definition and management functions.
miruga27 0:7fb6877b5d7c 26 */
miruga27 0:7fb6877b5d7c 27
miruga27 0:7fb6877b5d7c 28 #ifndef _SDL_rect_h
miruga27 0:7fb6877b5d7c 29 #define _SDL_rect_h
miruga27 0:7fb6877b5d7c 30
miruga27 0:7fb6877b5d7c 31 #include "SDL_stdinc.h"
miruga27 0:7fb6877b5d7c 32 #include "SDL_error.h"
miruga27 0:7fb6877b5d7c 33 #include "SDL_pixels.h"
miruga27 0:7fb6877b5d7c 34 #include "SDL_rwops.h"
miruga27 0:7fb6877b5d7c 35
miruga27 0:7fb6877b5d7c 36 #include "begin_code.h"
miruga27 0:7fb6877b5d7c 37 /* Set up for C function definitions, even when using C++ */
miruga27 0:7fb6877b5d7c 38 #ifdef __cplusplus
miruga27 0:7fb6877b5d7c 39 extern "C" {
miruga27 0:7fb6877b5d7c 40 #endif
miruga27 0:7fb6877b5d7c 41
miruga27 0:7fb6877b5d7c 42 /**
miruga27 0:7fb6877b5d7c 43 * \brief The structure that defines a point
miruga27 0:7fb6877b5d7c 44 *
miruga27 0:7fb6877b5d7c 45 * \sa SDL_EnclosePoints
miruga27 0:7fb6877b5d7c 46 */
miruga27 0:7fb6877b5d7c 47 typedef struct SDL_Point
miruga27 0:7fb6877b5d7c 48 {
miruga27 0:7fb6877b5d7c 49 int x;
miruga27 0:7fb6877b5d7c 50 int y;
miruga27 0:7fb6877b5d7c 51 } SDL_Point;
miruga27 0:7fb6877b5d7c 52
miruga27 0:7fb6877b5d7c 53 /**
miruga27 0:7fb6877b5d7c 54 * \brief A rectangle, with the origin at the upper left.
miruga27 0:7fb6877b5d7c 55 *
miruga27 0:7fb6877b5d7c 56 * \sa SDL_RectEmpty
miruga27 0:7fb6877b5d7c 57 * \sa SDL_RectEquals
miruga27 0:7fb6877b5d7c 58 * \sa SDL_HasIntersection
miruga27 0:7fb6877b5d7c 59 * \sa SDL_IntersectRect
miruga27 0:7fb6877b5d7c 60 * \sa SDL_UnionRect
miruga27 0:7fb6877b5d7c 61 * \sa SDL_EnclosePoints
miruga27 0:7fb6877b5d7c 62 */
miruga27 0:7fb6877b5d7c 63 typedef struct SDL_Rect
miruga27 0:7fb6877b5d7c 64 {
miruga27 0:7fb6877b5d7c 65 int x, y;
miruga27 0:7fb6877b5d7c 66 int w, h;
miruga27 0:7fb6877b5d7c 67 } SDL_Rect;
miruga27 0:7fb6877b5d7c 68
miruga27 0:7fb6877b5d7c 69 /**
miruga27 0:7fb6877b5d7c 70 * \brief Returns true if the rectangle has no area.
miruga27 0:7fb6877b5d7c 71 */
miruga27 0:7fb6877b5d7c 72 SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
miruga27 0:7fb6877b5d7c 73 {
miruga27 0:7fb6877b5d7c 74 return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE;
miruga27 0:7fb6877b5d7c 75 }
miruga27 0:7fb6877b5d7c 76
miruga27 0:7fb6877b5d7c 77 /**
miruga27 0:7fb6877b5d7c 78 * \brief Returns true if the two rectangles are equal.
miruga27 0:7fb6877b5d7c 79 */
miruga27 0:7fb6877b5d7c 80 SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
miruga27 0:7fb6877b5d7c 81 {
miruga27 0:7fb6877b5d7c 82 return (a && b && (a->x == b->x) && (a->y == b->y) &&
miruga27 0:7fb6877b5d7c 83 (a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE;
miruga27 0:7fb6877b5d7c 84 }
miruga27 0:7fb6877b5d7c 85
miruga27 0:7fb6877b5d7c 86 /**
miruga27 0:7fb6877b5d7c 87 * \brief Determine whether two rectangles intersect.
miruga27 0:7fb6877b5d7c 88 *
miruga27 0:7fb6877b5d7c 89 * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
miruga27 0:7fb6877b5d7c 90 */
miruga27 0:7fb6877b5d7c 91 extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
miruga27 0:7fb6877b5d7c 92 const SDL_Rect * B);
miruga27 0:7fb6877b5d7c 93
miruga27 0:7fb6877b5d7c 94 /**
miruga27 0:7fb6877b5d7c 95 * \brief Calculate the intersection of two rectangles.
miruga27 0:7fb6877b5d7c 96 *
miruga27 0:7fb6877b5d7c 97 * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
miruga27 0:7fb6877b5d7c 98 */
miruga27 0:7fb6877b5d7c 99 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
miruga27 0:7fb6877b5d7c 100 const SDL_Rect * B,
miruga27 0:7fb6877b5d7c 101 SDL_Rect * result);
miruga27 0:7fb6877b5d7c 102
miruga27 0:7fb6877b5d7c 103 /**
miruga27 0:7fb6877b5d7c 104 * \brief Calculate the union of two rectangles.
miruga27 0:7fb6877b5d7c 105 */
miruga27 0:7fb6877b5d7c 106 extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
miruga27 0:7fb6877b5d7c 107 const SDL_Rect * B,
miruga27 0:7fb6877b5d7c 108 SDL_Rect * result);
miruga27 0:7fb6877b5d7c 109
miruga27 0:7fb6877b5d7c 110 /**
miruga27 0:7fb6877b5d7c 111 * \brief Calculate a minimal rectangle enclosing a set of points
miruga27 0:7fb6877b5d7c 112 *
miruga27 0:7fb6877b5d7c 113 * \return SDL_TRUE if any points were within the clipping rect
miruga27 0:7fb6877b5d7c 114 */
miruga27 0:7fb6877b5d7c 115 extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
miruga27 0:7fb6877b5d7c 116 int count,
miruga27 0:7fb6877b5d7c 117 const SDL_Rect * clip,
miruga27 0:7fb6877b5d7c 118 SDL_Rect * result);
miruga27 0:7fb6877b5d7c 119
miruga27 0:7fb6877b5d7c 120 /**
miruga27 0:7fb6877b5d7c 121 * \brief Calculate the intersection of a rectangle and line segment.
miruga27 0:7fb6877b5d7c 122 *
miruga27 0:7fb6877b5d7c 123 * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
miruga27 0:7fb6877b5d7c 124 */
miruga27 0:7fb6877b5d7c 125 extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
miruga27 0:7fb6877b5d7c 126 rect, int *X1,
miruga27 0:7fb6877b5d7c 127 int *Y1, int *X2,
miruga27 0:7fb6877b5d7c 128 int *Y2);
miruga27 0:7fb6877b5d7c 129
miruga27 0:7fb6877b5d7c 130 /* Ends C function definitions when using C++ */
miruga27 0:7fb6877b5d7c 131 #ifdef __cplusplus
miruga27 0:7fb6877b5d7c 132 }
miruga27 0:7fb6877b5d7c 133 #endif
miruga27 0:7fb6877b5d7c 134 #include "close_code.h"
miruga27 0:7fb6877b5d7c 135
miruga27 0:7fb6877b5d7c 136 #endif /* _SDL_rect_h */
miruga27 0:7fb6877b5d7c 137
miruga27 0:7fb6877b5d7c 138 /* vi: set ts=4 sw=4 expandtab: */