]> git.lizzy.rs Git - nothing.git/blob - src/rect.h
(#152) Make equilateral triangle use matrices for transformations
[nothing.git] / src / rect.h
1 #ifndef RECT_H_
2 #define RECT_H_
3
4 #include <SDL2/SDL.h>
5 #include "./point.h"
6
7 typedef enum rect_side_t {
8     RECT_SIDE_LEFT = 0,
9     RECT_SIDE_RIGHT,
10     RECT_SIDE_TOP,
11     RECT_SIDE_BOTTOM,
12
13     RECT_SIDE_N
14 } rect_side_t;
15
16 typedef struct rect_t {
17     float x, y, w, h;
18 } rect_t;
19
20 typedef struct line_t {
21     point_t p1;
22     point_t p2;
23 } line_t;
24
25 rect_t rect(float x, float y, float w, float h);
26 rect_t rect_from_vecs(point_t position, vec_t size);
27
28 rect_t rects_overlap_area(rect_t rect1, rect_t rect2);
29
30 int rect_contains_point(rect_t rect, point_t p);
31
32 int rects_overlap(rect_t rect1, rect_t rect2);
33
34 void rect_object_impact(const rect_t *object,
35                         const rect_t *obstacle,
36                         int *sides);
37
38 line_t rect_side(rect_t rect, rect_side_t side);
39
40 rect_t rect_from_point(point_t p, float w, float h);
41
42 float line_length(line_t line);
43
44 SDL_Rect rect_for_sdl(rect_t rect);
45
46 #endif  // RECT_H_