-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.h
More file actions
88 lines (66 loc) · 1.91 KB
/
Image.h
File metadata and controls
88 lines (66 loc) · 1.91 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#pragma once
#include "Point.h"
//Image represents a single continuous set of points
//(well, there may be breaks, but they just come from rotation)
//Image stores information about the box where it is located
//(this box is not necessarily equal to the bounding box)
class Image
{
public:
Image(void);
Image(const Box & box) :m_box(box) {}
Image(const Box & box, const std::vector<Point> & points)
:m_box(box), m_points(points) {}
~Image(void);
void set_box(Box box) {
m_box = box;
}
const Box & box() const {
return m_box;
}
Box minimalBox() const;
const std::vector<Point> & points() const {
return m_points; }
Point firstPoint() const {
return m_points[0];
}
Point lastPoint() const {
return m_points.back();
}
void add(Point point) {
m_points.push_back(point);
}
void addBreak() {
m_breaks.insert(m_points.size());
}
//first-to-last point
Vector vector() const;
std::vector<double> getAngleDeltas(int minDist) const;
void draw(HDC dc, RECT drawRect) const;
Point project(const Point & pt, const RECT & rect) const;
void scale(double dx, double dy);
void transfer(int dx, int dy);
std::vector<double> collectAngles (Point center) const;
Point closestPoint(Point rayStart, Vector rayDir) const;
private:
std::vector<Point> m_points;
std::set<std::vector<Point>::size_type> m_breaks;
Box m_box;
};
//This class represents a collection of images in a single box.
//It usually is the character, perhapse in process of drawing
class CompositeImage : public std::vector<Image>
{
public:
CompositeImage() {}
CompositeImage(const CompositeImage & other) : std::vector<Image>(other) {}
CompositeImage(const std::vector<Image> & other) : std::vector<Image>(other) {}
void add(const Image & image) {
push_back(image);
}
void fit(const Box & box);
void draw(HDC dc, RECT drawRect) const;
void scale(double dx, double dy);
void transfer(int dx, int dy);
Box minimalBox() const;
};