[go: up one dir, main page]

Menu

[3cb4b9]: / src / yrect.h  Maximize  Restore  History

Download this file

62 lines (50 with data), 1.4 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
#ifndef __YRECT_H
#define __YRECT_H
#include "ypoint.h"
// change this to use x,y,w,h internal representation?
class YRect {
public:
#if 0
YRect(): x1(0), y1(0), x2(0), y2(0) {}
#endif
YRect(int x, int y, int w, int h)
:xx(x), yy(y), ww(w), hh(h)
{ }
int x() const { return xx; }
int y() const { return yy; }
int width() const { return ww; }
int height() const { return hh; }
#if 0
int left() const { return x1; }
int right() const { return x2; }
int top() const { return y1; }
int bottom() const { return y2; }
void setX(int x) { x1 = x; }
void setY(int y) { y2 = y; }
void setWidth(int w) { x2 = x1 + w - 1; }
void setHeight(int h) { y2 = y1 + h - 1; }
void setLeft(int x) { x1 = x; }
void setRight(int x) { x2 = x; }
void setTop(int y) { y1 = y; }
void setBottom(int y) { y2 = y; }
void setRect(const YRect &r) {
setLeft(r.left());
setTop(r.top());
setRight(r.right());
setBottom(r.bottom());
}
#endif
//YPoint center() { return YPoint((x1 + x2) / 2,
// (y1 + y2) / 2); }
#if 0
bool inside(const YPoint &p) {
return (p.x() >= x1 &&
p.y() >= y1 &&
p.x() <= x2 &&
p.y() <= y2) ? true : false;
}
#endif
private:
int xx, yy, ww, hh;
};
#endif