aboutsummaryrefslogtreecommitdiff
path: root/src/util.h
blob: 06258e1d64cfd0471597d88b4eda20ffdfb4ef00 (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
#ifndef COMET_UTIL_H
#define COMET_UTIL_H

#include <time.h>
#include <stddef.h>
#include <stdbool.h>

struct timespec timespec_diff(struct timespec a, struct timespec b);

bool timespec_greater(struct timespec a, struct timespec b);

void timespec_print(struct timespec *ts);

// Check if point (px, py) is inside a rectangle in (x, y), (x+w, y), (x, y+h) and (w+h, y+h)
bool check_rect(int px, int py, int x, int y, int w, int h);

// Check if point (px, py) is inside a circle of radius r and center (x, y)
bool check_circle(int px, int py, int x, int y, int r);

// Check if point (px, py) is inside a capsule in (x, y), (x+w, y), (x, y+h) and (w+h, y+h)
bool check_capsule(int px, int py, int x, int y, int w, int h);

char *strslice(const char *string, size_t start, size_t end);

char *strcopy(const char *string);

#endif