forked from Rox64/NXEngine
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnx_math.h
68 lines (44 loc) · 1.3 KB
/
nx_math.h
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
#ifndef CaveStory_nx_math_h
#define CaveStory_nx_math_h
struct NXColor;
struct RectI
{
int x, y;
int w, h;
RectI() : x(0), y(0), w(0), h(0) {}
RectI(int x, int y, int w, int h) : x(x), y(y), w(w), h(h) {}
};
struct PointF
{
float x, y;
PointF(float x, float y) : x(x), y(y) {}
PointF() : x(0), y(0) {}
PointF operator+(PointF const& r) const;
PointF operator-(PointF const& r) const;
PointF operator*(float k) const;
};
struct RectF
{
float x, y;
float w, h;
static RectF centred(PointF const& p, float w, float h);
static RectF fromRectI(RectI const& rect);
bool point_in(PointF const& p) const;
bool point_in(float px, float py) const;
void to_screen_coord(int& x1, int& y1, int& x2, int& y2) const;
void draw_fill_rect(NXColor const& c) const;
void draw_thick_rect(NXColor const& c) const;
void draw_thin_rect(NXColor const& c) const;
void move(PointF const& translation);
RectF scale(float factor);
};
struct TriF
{
PointF a;
PointF b, c;
TriF() {}
TriF(PointF const& a, float size, float rb, float rc);
static float sign(PointF const& p1, PointF const& p2, PointF const& p3);
bool in(PointF const& pt) const;
};
#endif