-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrect.cpp
More file actions
56 lines (42 loc) · 726 Bytes
/
rect.cpp
File metadata and controls
56 lines (42 loc) · 726 Bytes
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
#include <stdio.h>
#include "rect.h"
Rect::Rect() :
x1(0),
y1(0),
x2(0),
y2(0)
{
}
Rect::Rect(int x1_, int y1_, int x2_, int y2_):
x1(x1_),
y1(y1_),
x2(x2_),
y2(y2_)
{
}
int Rect::surface() const {
return (x2 - x1) * (y2 - y1);
}
std::vector<Rect> load_rects(std::string filename) {
FILE *f;
std::vector<Rect> result;
f = fopen(filename.c_str(), "r");
if (!f) {
return result;
}
int x1, y1, x2, y2;
while (fscanf(f, "%d %d %d %d\n", &x1, &y1, &x2, &y2) == 4) {
result.push_back(Rect(x1, y1, x2, y2));
}
return result;
}
RectMovement::RectMovement() :
source(),
dest()
{
}
RectMovement::RectMovement(Rect source_, Rect dest_) :
source(source_),
dest(dest_)
{
}