-
Notifications
You must be signed in to change notification settings - Fork 0
/
rect.h
62 lines (46 loc) · 1.04 KB
/
rect.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
#ifndef __RECT_H__
#define __RECT_H__
#include "vec2.h"
#include <cmath>
class rect {
public:
rect() {
// empty
}
rect(const vec2d& origin, double width, double height) {
this->_origin = origin;
this->_size = vec2d(width, height);
}
rect(double x, double y, double width, double height) {
this->_origin = vec2d(x, y);
this->_size = vec2d(width, height);
}
void moveTo(const vec2d& pos) {
this->_origin = pos;
}
void moveTo(double x, double y) {
this->_origin = vec2d(x, y);
}
void setWidth(double width) {
this->_size.x = width;
}
void setHeight(double height) {
this->_size.y = height;
}
double width() {
return this->_size.x;
}
double height() {
return this->_size.y;
}
void setSize(double width, double height) {
this->_size = vec2d(width, height);
}
const vec2d& getOrigin() {
return this->_origin;
}
private:
vec2d _origin;
vec2d _size;
};
#endif