aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy_math.c
blob: 5da800c17cc84e5cd9132c82ef00c61c12092bcd (plain)
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
#include "teensy.h"

bool ty_pointi_in_recti(ty_Vec2i point, ty_Recti rect)
{
    return
        point.x > rect.x &&
        point.x < rect.x + rect.w &&
        point.y > rect.y &&
        point.y < rect.y + rect.h;
}

bool ty_point_in_rect(ty_Vec2 point, ty_Rect rect)
{
    return
        point.x > rect.x &&
        point.x < rect.x + rect.w &&
        point.y > rect.y &&
        point.y < rect.y + rect.h;
}


ty_Recti ty_recti_shrink(ty_Recti rect, int p)
{
    rect.x += p;
    rect.y += p;
    rect.w -= p * 2;
    rect.h -= p * 2;
    return rect;
}

ty_Recti ty_recti_grow(ty_Recti rect, int p)
{
    rect.x -= p;
    rect.y -= p;
    rect.w += p * 2;
    rect.h += p * 2;
    return rect;
}