Path: blob/main/system/include/SDL/SDL_rect.h
6169 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2011 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/**22* \file SDL_rect.h23*24* Header file for SDL_rect definition and management functions.25*/2627#ifndef _SDL_rect_h28#define _SDL_rect_h2930#include "SDL_stdinc.h"31#include "SDL_error.h"32#include "SDL_pixels.h"33#include "SDL_rwops.h"3435#include "begin_code.h"36/* Set up for C function definitions, even when using C++ */37#ifdef __cplusplus38/* *INDENT-OFF* */39extern "C" {40/* *INDENT-ON* */41#endif4243/**44* \brief The structure that defines a point45*46* \sa SDL_EnclosePoints47*/48typedef struct49{50int x;51int y;52} SDL_Point;5354/**55* \brief A rectangle, with the origin at the upper left.56*57* \sa SDL_RectEmpty58* \sa SDL_RectEquals59* \sa SDL_HasIntersection60* \sa SDL_IntersectRect61* \sa SDL_UnionRect62* \sa SDL_EnclosePoints63*/64typedef struct SDL_Rect65{66int x, y;67int w, h;68} SDL_Rect;6970/**71* \brief Returns true if the rectangle has no area.72*/73#define SDL_RectEmpty(X) (((X)->w <= 0) || ((X)->h <= 0))7475/**76* \brief Returns true if the two rectangles are equal.77*/78#define SDL_RectEquals(A, B) (((A)->x == (B)->x) && ((A)->y == (B)->y) && \79((A)->w == (B)->w) && ((A)->h == (B)->h))8081/**82* \brief Determine whether two rectangles intersect.83*84* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.85*/86extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,87const SDL_Rect * B);8889/**90* \brief Calculate the intersection of two rectangles.91*92* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.93*/94extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,95const SDL_Rect * B,96SDL_Rect * result);9798/**99* \brief Calculate the union of two rectangles.100*/101extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,102const SDL_Rect * B,103SDL_Rect * result);104105/**106* \brief Calculate a minimal rectangle enclosing a set of points107*108* \return SDL_TRUE if any points were within the clipping rect109*/110extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,111int count,112const SDL_Rect * clip,113SDL_Rect * result);114115/**116* \brief Calculate the intersection of a rectangle and line segment.117*118* \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise.119*/120extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *121rect, int *X1,122int *Y1, int *X2,123int *Y2);124125/* Ends C function definitions when using C++ */126#ifdef __cplusplus127/* *INDENT-OFF* */128}129/* *INDENT-ON* */130#endif131#include "close_code.h"132133#endif /* _SDL_rect_h */134135/* vi: set ts=4 sw=4 expandtab: */136137138