mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
# Conflicts: # libs/SDL2/COPYING.txt # libs/SDL2/WhatsNew.txt # libs/SDL2/docs/README-android.md # libs/SDL2/docs/README-linux.md # libs/SDL2/i686-w64-mingw32/bin/SDL2.dll # libs/SDL2/i686-w64-mingw32/bin/sdl2-config # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_assert.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_atomic.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_audio.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_bits.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_blendmode.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_clipboard.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_config.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_cpuinfo.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_egl.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_endian.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_error.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_events.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_filesystem.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gamecontroller.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_gesture.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_haptic.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_hints.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_joystick.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keyboard.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_keycode.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_loadso.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_log.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_main.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_messagebox.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mouse.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_mutex.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_name.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengl.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_opengles2.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_pixels.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_platform.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_power.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_quit.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rect.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_render.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_revision.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_rwops.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_scancode.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_sensor.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_shape.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_stdinc.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_surface.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_system.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_syswm.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_assert.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_common.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_compare.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_crc32.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_font.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_fuzzer.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_harness.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_images.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_log.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_md5.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_memory.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_test_random.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_thread.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_timer.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_touch.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_types.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_version.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_video.h # libs/SDL2/i686-w64-mingw32/include/SDL2/SDL_vulkan.h # libs/SDL2/i686-w64-mingw32/include/SDL2/begin_code.h # libs/SDL2/i686-w64-mingw32/include/SDL2/close_code.h # libs/SDL2/i686-w64-mingw32/lib/libSDL2.a # libs/SDL2/i686-w64-mingw32/lib/libSDL2.dll.a # libs/SDL2/i686-w64-mingw32/lib/libSDL2.la # libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.a # libs/SDL2/i686-w64-mingw32/lib/libSDL2_test.la # libs/SDL2/i686-w64-mingw32/lib/libSDL2main.a # libs/SDL2/i686-w64-mingw32/lib/libSDL2main.la # libs/SDL2/i686-w64-mingw32/lib/pkgconfig/sdl2.pc # libs/SDL2/test/Makefile.in # libs/SDL2/test/Makefile.os2 # libs/SDL2/test/checkkeys.c # libs/SDL2/test/configure.ac # libs/SDL2/test/controllermap.c # libs/SDL2/test/loopwave.c # libs/SDL2/test/loopwavequeue.c # libs/SDL2/test/testatomic.c # libs/SDL2/test/testaudiocapture.c # libs/SDL2/test/testaudiohotplug.c # libs/SDL2/test/testaudioinfo.c # libs/SDL2/test/testautomation.c # libs/SDL2/test/testbounds.c # libs/SDL2/test/testcustomcursor.c # libs/SDL2/test/testdisplayinfo.c # libs/SDL2/test/testdraw2.c # libs/SDL2/test/testdrawchessboard.c # libs/SDL2/test/testdropfile.c # libs/SDL2/test/testerror.c # libs/SDL2/test/testfile.c # libs/SDL2/test/testfilesystem.c # libs/SDL2/test/testgamecontroller.c # libs/SDL2/test/testgesture.c # libs/SDL2/test/testgl2.c # libs/SDL2/test/testgles.c # libs/SDL2/test/testgles2.c # libs/SDL2/test/testhotplug.c # libs/SDL2/test/testiconv.c # libs/SDL2/test/testime.c # libs/SDL2/test/testintersections.c # libs/SDL2/test/testjoystick.c # libs/SDL2/test/testkeys.c # libs/SDL2/test/testloadso.c # libs/SDL2/test/testlock.c # libs/SDL2/test/testmessage.c # libs/SDL2/test/testmultiaudio.c # libs/SDL2/test/testnative.c # libs/SDL2/test/testnative.h # libs/SDL2/test/testnativew32.c # libs/SDL2/test/testnativex11.c # libs/SDL2/test/testoverlay2.c # libs/SDL2/test/testplatform.c # libs/SDL2/test/testpower.c # libs/SDL2/test/testqsort.c # libs/SDL2/test/testrelative.c # libs/SDL2/test/testrendercopyex.c # libs/SDL2/test/testrendertarget.c # libs/SDL2/test/testresample.c # libs/SDL2/test/testrumble.c # libs/SDL2/test/testscale.c # libs/SDL2/test/testsem.c # libs/SDL2/test/testsensor.c # libs/SDL2/test/testshader.c # libs/SDL2/test/testshape.c # libs/SDL2/test/testsprite2.c # libs/SDL2/test/testspriteminimal.c # libs/SDL2/test/teststreaming.c # libs/SDL2/test/testthread.c # libs/SDL2/test/testtimer.c # libs/SDL2/test/testver.c # libs/SDL2/test/testviewport.c # libs/SDL2/test/testvulkan.c # libs/SDL2/test/testwm2.c # libs/SDL2/test/testyuv.c # libs/SDL2/test/testyuv_cvt.c # libs/SDL2/test/testyuv_cvt.h # libs/SDL2/test/torturethread.c # libs/SDL2/x86_64-w64-mingw32/bin/SDL2.dll # libs/SDL2/x86_64-w64-mingw32/bin/sdl2-config # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_assert.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_atomic.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_audio.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_bits.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_blendmode.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_clipboard.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_config.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_cpuinfo.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_egl.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_endian.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_error.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_events.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_filesystem.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gamecontroller.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_gesture.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_haptic.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_hints.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_joystick.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keyboard.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_keycode.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_loadso.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_log.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_main.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_messagebox.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mouse.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_mutex.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_name.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengl.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_opengles2.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_pixels.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_platform.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_power.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_quit.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rect.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_render.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_revision.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_rwops.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_scancode.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_sensor.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_shape.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_stdinc.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_surface.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_system.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_syswm.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_assert.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_common.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_compare.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_crc32.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_font.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_fuzzer.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_harness.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_images.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_log.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_md5.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_memory.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_test_random.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_thread.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_timer.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_touch.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_types.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_version.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_video.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/SDL_vulkan.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/begin_code.h # libs/SDL2/x86_64-w64-mingw32/include/SDL2/close_code.h # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.a # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.dll.a # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2.la # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.a # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2_test.la # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.a # libs/SDL2/x86_64-w64-mingw32/lib/libSDL2main.la # libs/SDL2/x86_64-w64-mingw32/lib/pkgconfig/sdl2.pc
376 lines
13 KiB
C
376 lines
13 KiB
C
/*
|
|
Simple DirectMedia Layer
|
|
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
warranty. In no event will the authors be held liable for any damages
|
|
arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
including commercial applications, and to alter it and redistribute it
|
|
freely, subject to the following restrictions:
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
claim that you wrote the original software. If you use this software
|
|
in a product, an acknowledgment in the product documentation would be
|
|
appreciated but is not required.
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
misrepresented as being the original software.
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
*/
|
|
|
|
/**
|
|
* \file SDL_rect.h
|
|
*
|
|
* Header file for SDL_rect definition and management functions.
|
|
*/
|
|
|
|
#ifndef SDL_rect_h_
|
|
#define SDL_rect_h_
|
|
|
|
#include "SDL_stdinc.h"
|
|
#include "SDL_error.h"
|
|
#include "SDL_pixels.h"
|
|
#include "SDL_rwops.h"
|
|
|
|
#include "begin_code.h"
|
|
/* Set up for C function definitions, even when using C++ */
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* The structure that defines a point (integer)
|
|
*
|
|
* \sa SDL_EnclosePoints
|
|
* \sa SDL_PointInRect
|
|
*/
|
|
typedef struct SDL_Point
|
|
{
|
|
int x;
|
|
int y;
|
|
} SDL_Point;
|
|
|
|
/**
|
|
* The structure that defines a point (floating point)
|
|
*
|
|
* \sa SDL_EncloseFPoints
|
|
* \sa SDL_PointInFRect
|
|
*/
|
|
typedef struct SDL_FPoint
|
|
{
|
|
float x;
|
|
float y;
|
|
} SDL_FPoint;
|
|
|
|
|
|
/**
|
|
* A rectangle, with the origin at the upper left (integer).
|
|
*
|
|
* \sa SDL_RectEmpty
|
|
* \sa SDL_RectEquals
|
|
* \sa SDL_HasIntersection
|
|
* \sa SDL_IntersectRect
|
|
* \sa SDL_IntersectRectAndLine
|
|
* \sa SDL_UnionRect
|
|
* \sa SDL_EnclosePoints
|
|
*/
|
|
typedef struct SDL_Rect
|
|
{
|
|
int x, y;
|
|
int w, h;
|
|
} SDL_Rect;
|
|
|
|
|
|
/**
|
|
* A rectangle, with the origin at the upper left (floating point).
|
|
*
|
|
* \sa SDL_FRectEmpty
|
|
* \sa SDL_FRectEquals
|
|
* \sa SDL_FRectEqualsEpsilon
|
|
* \sa SDL_HasIntersectionF
|
|
* \sa SDL_IntersectFRect
|
|
* \sa SDL_IntersectFRectAndLine
|
|
* \sa SDL_UnionFRect
|
|
* \sa SDL_EncloseFPoints
|
|
* \sa SDL_PointInFRect
|
|
*/
|
|
typedef struct SDL_FRect
|
|
{
|
|
float x;
|
|
float y;
|
|
float w;
|
|
float h;
|
|
} SDL_FRect;
|
|
|
|
|
|
/**
|
|
* Returns true if point resides inside a rectangle.
|
|
*/
|
|
SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
|
|
{
|
|
return ( (p->x >= r->x) && (p->x < (r->x + r->w)) &&
|
|
(p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the rectangle has no area.
|
|
*/
|
|
SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)
|
|
{
|
|
return ((!r) || (r->w <= 0) || (r->h <= 0)) ? SDL_TRUE : SDL_FALSE;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the two rectangles are equal.
|
|
*/
|
|
SDL_FORCE_INLINE SDL_bool SDL_RectEquals(const SDL_Rect *a, const SDL_Rect *b)
|
|
{
|
|
return (a && b && (a->x == b->x) && (a->y == b->y) &&
|
|
(a->w == b->w) && (a->h == b->h)) ? SDL_TRUE : SDL_FALSE;
|
|
}
|
|
|
|
/**
|
|
* Determine whether two rectangles intersect.
|
|
*
|
|
* If either pointer is NULL the function will return SDL_FALSE.
|
|
*
|
|
* \param A an SDL_Rect structure representing the first rectangle
|
|
* \param B an SDL_Rect structure representing the second rectangle
|
|
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 2.0.0.
|
|
*
|
|
* \sa SDL_IntersectRect
|
|
*/
|
|
extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A,
|
|
const SDL_Rect * B);
|
|
|
|
/**
|
|
* Calculate the intersection of two rectangles.
|
|
*
|
|
* If `result` is NULL then this function will return SDL_FALSE.
|
|
*
|
|
* \param A an SDL_Rect structure representing the first rectangle
|
|
* \param B an SDL_Rect structure representing the second rectangle
|
|
* \param result an SDL_Rect structure filled in with the intersection of
|
|
* rectangles `A` and `B`
|
|
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 2.0.0.
|
|
*
|
|
* \sa SDL_HasIntersection
|
|
*/
|
|
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A,
|
|
const SDL_Rect * B,
|
|
SDL_Rect * result);
|
|
|
|
/**
|
|
* Calculate the union of two rectangles.
|
|
*
|
|
* \param A an SDL_Rect structure representing the first rectangle
|
|
* \param B an SDL_Rect structure representing the second rectangle
|
|
* \param 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.
|
|
*/
|
|
extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A,
|
|
const SDL_Rect * B,
|
|
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.
|
|
*
|
|
* \param points an array of SDL_Point structures representing points to be
|
|
* enclosed
|
|
* \param count the number of structures in the `points` array
|
|
* \param clip an SDL_Rect used for clipping or NULL to enclose all points
|
|
* \param result an SDL_Rect structure filled in with the minimal enclosing
|
|
* rectangle
|
|
* \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the
|
|
* points were outside of the clipping rectangle.
|
|
*
|
|
* \since This function is available since SDL 2.0.0.
|
|
*/
|
|
extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points,
|
|
int count,
|
|
const SDL_Rect * clip,
|
|
SDL_Rect * result);
|
|
|
|
/**
|
|
* 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 `X1`, `Y1`, `X2`, and/or `Y2` as necessary.
|
|
*
|
|
* \param rect an SDL_Rect structure representing the rectangle to intersect
|
|
* \param X1 a pointer to the starting X-coordinate of the line
|
|
* \param Y1 a pointer to the starting Y-coordinate of the line
|
|
* \param X2 a pointer to the ending X-coordinate of the line
|
|
* \param Y2 a pointer to the ending Y-coordinate of the line
|
|
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 2.0.0.
|
|
*/
|
|
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine(const SDL_Rect *
|
|
rect, int *X1,
|
|
int *Y1, int *X2,
|
|
int *Y2);
|
|
|
|
|
|
/* SDL_FRect versions... */
|
|
|
|
/**
|
|
* Returns true if point resides inside a rectangle.
|
|
*/
|
|
SDL_FORCE_INLINE SDL_bool SDL_PointInFRect(const SDL_FPoint *p, const SDL_FRect *r)
|
|
{
|
|
return ( (p->x >= r->x) && (p->x < (r->x + r->w)) &&
|
|
(p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the rectangle has no area.
|
|
*/
|
|
SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty(const SDL_FRect *r)
|
|
{
|
|
return ((!r) || (r->w <= 0.0f) || (r->h <= 0.0f)) ? SDL_TRUE : SDL_FALSE;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the two rectangles are equal, within some given epsilon.
|
|
*
|
|
* \since This function is available since SDL 2.0.22.
|
|
*/
|
|
SDL_FORCE_INLINE SDL_bool SDL_FRectEqualsEpsilon(const SDL_FRect *a, const SDL_FRect *b, const float epsilon)
|
|
{
|
|
return (a && b && ((a == b) ||
|
|
((SDL_fabs(a->x - b->x) <= epsilon) &&
|
|
(SDL_fabs(a->y - b->y) <= epsilon) &&
|
|
(SDL_fabs(a->w - b->w) <= epsilon) &&
|
|
(SDL_fabs(a->h - b->h) <= epsilon))))
|
|
? SDL_TRUE : SDL_FALSE;
|
|
}
|
|
|
|
/**
|
|
* Returns true if the two rectangles are equal, using a default epsilon.
|
|
*
|
|
* \since This function is available since SDL 2.0.22.
|
|
*/
|
|
SDL_FORCE_INLINE SDL_bool SDL_FRectEquals(const SDL_FRect *a, const SDL_FRect *b)
|
|
{
|
|
return SDL_FRectEqualsEpsilon(a, b, SDL_FLT_EPSILON);
|
|
}
|
|
|
|
/**
|
|
* Determine whether two rectangles intersect with float precision.
|
|
*
|
|
* If either pointer is NULL the function will return SDL_FALSE.
|
|
*
|
|
* \param A an SDL_FRect structure representing the first rectangle
|
|
* \param B an SDL_FRect structure representing the second rectangle
|
|
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 2.0.22.
|
|
*
|
|
* \sa SDL_IntersectRect
|
|
*/
|
|
extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersectionF(const SDL_FRect * A,
|
|
const SDL_FRect * B);
|
|
|
|
/**
|
|
* Calculate the intersection of two rectangles with float precision.
|
|
*
|
|
* If `result` is NULL then this function will return SDL_FALSE.
|
|
*
|
|
* \param A an SDL_FRect structure representing the first rectangle
|
|
* \param B an SDL_FRect structure representing the second rectangle
|
|
* \param result an SDL_FRect structure filled in with the intersection of
|
|
* rectangles `A` and `B`
|
|
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 2.0.22.
|
|
*
|
|
* \sa SDL_HasIntersectionF
|
|
*/
|
|
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectFRect(const SDL_FRect * A,
|
|
const SDL_FRect * B,
|
|
SDL_FRect * result);
|
|
|
|
/**
|
|
* Calculate the union of two rectangles with float precision.
|
|
*
|
|
* \param A an SDL_FRect structure representing the first rectangle
|
|
* \param B an SDL_FRect structure representing the second rectangle
|
|
* \param 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.
|
|
*/
|
|
extern DECLSPEC void SDLCALL SDL_UnionFRect(const SDL_FRect * A,
|
|
const SDL_FRect * B,
|
|
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.
|
|
*
|
|
* \param points an array of SDL_FPoint structures representing points to be
|
|
* enclosed
|
|
* \param count the number of structures in the `points` array
|
|
* \param clip an SDL_FRect used for clipping or NULL to enclose all points
|
|
* \param result an SDL_FRect structure filled in with the minimal enclosing
|
|
* rectangle
|
|
* \returns SDL_TRUE if any points were enclosed or SDL_FALSE if all the
|
|
* points were outside of the clipping rectangle.
|
|
*
|
|
* \since This function is available since SDL 2.0.22.
|
|
*/
|
|
extern DECLSPEC SDL_bool SDLCALL SDL_EncloseFPoints(const SDL_FPoint * points,
|
|
int count,
|
|
const SDL_FRect * clip,
|
|
SDL_FRect * result);
|
|
|
|
/**
|
|
* 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 `X1`, `Y1`, `X2`, and/or `Y2` as necessary.
|
|
*
|
|
* \param rect an SDL_FRect structure representing the rectangle to intersect
|
|
* \param X1 a pointer to the starting X-coordinate of the line
|
|
* \param Y1 a pointer to the starting Y-coordinate of the line
|
|
* \param X2 a pointer to the ending X-coordinate of the line
|
|
* \param Y2 a pointer to the ending Y-coordinate of the line
|
|
* \returns SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
|
|
*
|
|
* \since This function is available since SDL 2.0.22.
|
|
*/
|
|
extern DECLSPEC SDL_bool SDLCALL SDL_IntersectFRectAndLine(const SDL_FRect *
|
|
rect, float *X1,
|
|
float *Y1, float *X2,
|
|
float *Y2);
|
|
|
|
/* Ends C function definitions when using C++ */
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#include "close_code.h"
|
|
|
|
#endif /* SDL_rect_h_ */
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|