2019-05-15 14:52:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
class CRect
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
float left; // x min
|
2019-05-30 19:24:47 +00:00
|
|
|
float bottom; // y max
|
2019-05-15 14:52:37 +00:00
|
|
|
float right; // x max
|
2019-05-30 19:24:47 +00:00
|
|
|
float top; // y min
|
2019-05-15 14:52:37 +00:00
|
|
|
|
|
|
|
CRect(void){
|
|
|
|
left = 1000000.0f;
|
2019-05-30 19:24:47 +00:00
|
|
|
top = 1000000.0f;
|
2019-05-15 14:52:37 +00:00
|
|
|
right = -1000000.0f;
|
2019-05-30 19:24:47 +00:00
|
|
|
bottom = -1000000.0f;
|
2019-05-15 14:52:37 +00:00
|
|
|
}
|
2019-05-30 19:24:47 +00:00
|
|
|
CRect(float l, float t, float r, float b){
|
2019-05-15 14:52:37 +00:00
|
|
|
left = l;
|
|
|
|
top = t;
|
2019-05-30 19:24:47 +00:00
|
|
|
right = r;
|
|
|
|
bottom = b;
|
2019-05-15 14:52:37 +00:00
|
|
|
}
|
|
|
|
void ContainPoint(CVector const &v){
|
|
|
|
if(v.x < left) left = v.x;
|
|
|
|
if(v.x > right) right = v.x;
|
2019-05-30 19:24:47 +00:00
|
|
|
if(v.y < top) top = v.y;
|
|
|
|
if(v.y > bottom) bottom = v.y;
|
2019-05-15 14:52:37 +00:00
|
|
|
}
|
2019-06-23 11:11:41 +00:00
|
|
|
|
|
|
|
void Translate(float x, float y){
|
|
|
|
left += x;
|
|
|
|
right += x;
|
|
|
|
bottom += y;
|
|
|
|
top += y;
|
|
|
|
}
|
|
|
|
void Grow(float r){
|
|
|
|
left -= r;
|
|
|
|
right += r;
|
|
|
|
top -= r;
|
|
|
|
bottom += r;
|
|
|
|
}
|
|
|
|
|
|
|
|
float GetWidth(void) { return right - left; }
|
|
|
|
float GetHeight(void) { return bottom - top; }
|
2019-05-15 14:52:37 +00:00
|
|
|
};
|