Add methods to rectangle to get its corners as locations

This commit is contained in:
2014-04-12 12:37:56 -04:00
parent 7afaaf3a60
commit 9f5480ba8b
2 changed files with 20 additions and 0 deletions

View File

@@ -129,6 +129,22 @@ location rectangle::centre() {
return location((left + right) / 2, (top + bottom) / 2);
}
location rectangle::topLeft() {
return location(left, top);
}
location rectangle::topRight() {
return location(right, top);
}
location rectangle::bottomLeft() {
return location(left, bottom);
}
location rectangle::bottomRight() {
return location(right, bottom);
}
void rectangle::offset(int h, int v) {
left += h; right += h;
top += v; bottom += v;

View File

@@ -57,6 +57,10 @@ struct rectangle {
rectangle_size_delegate width();
rectangle_size_delegate height();
location centre();
location topLeft();
location topRight();
location bottomLeft();
location bottomRight();
bool contains(location p);
bool contains(int x, int y);
void offset(int h, int v);