Add methods to rectangle to get its corners as locations
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user