1use crate::{c_float, c_int, stdinc::*};
4
5#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
7#[repr(C)]
8#[allow(missing_docs)]
9pub struct SDL_Point {
10  pub x: c_int,
11  pub y: c_int,
12}
13
14#[derive(Debug, Clone, Copy, Default, PartialEq, PartialOrd)]
16#[repr(C)]
17#[allow(missing_docs)]
18pub struct SDL_FPoint {
19  pub x: c_float,
20  pub y: c_float,
21}
22
23#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
25#[repr(C)]
26#[allow(missing_docs)]
27pub struct SDL_Rect {
28  pub x: c_int,
29  pub y: c_int,
30  pub w: c_int,
31  pub h: c_int,
32}
33
34#[derive(Debug, Clone, Copy, Default, PartialEq, PartialOrd)]
36#[repr(C)]
37#[allow(missing_docs)]
38pub struct SDL_FRect {
39  pub x: f32,
40  pub y: f32,
41  pub w: f32,
42  pub h: f32,
43}
44
45#[inline]
47#[must_use]
48pub const fn SDL_PointInRect(p: SDL_Point, r: SDL_Rect) -> bool {
49  (p.x >= r.x) && (p.x < (r.x + r.w)) && (p.y >= r.y) && (p.y < (r.y + r.h))
50}
51
52#[inline]
54#[must_use]
55pub const fn SDL_RectEmpty(r: SDL_Rect) -> bool {
56  (r.w <= 0) || (r.h <= 0)
57}
58
59extern "C" {
60  pub fn SDL_HasIntersection(
64    A: *const SDL_Rect, B: *const SDL_Rect,
65  ) -> SDL_bool;
66
67  pub fn SDL_IntersectRect(
71    A: *const SDL_Rect, B: *const SDL_Rect, result: *mut SDL_Rect,
72  ) -> SDL_bool;
73
74  pub fn SDL_UnionRect(
76    A: *const SDL_Rect, B: *const SDL_Rect, result: *mut SDL_Rect,
77  );
78
79  pub fn SDL_EnclosePoints(
83    points: *const SDL_Point, count: c_int, clip: *const SDL_Rect,
84    result: *mut SDL_Rect,
85  ) -> SDL_bool;
86
87  pub fn SDL_IntersectRectAndLine(
91    rect: *const SDL_Rect, X1: *mut c_int, Y1: *mut c_int, X2: *mut c_int,
92    Y2: *mut c_int,
93  ) -> SDL_bool;
94}