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