From 9f5480ba8b269bbcf99eb4940392ace045fcc8ef Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Sat, 12 Apr 2014 12:37:56 -0400 Subject: [PATCH] Add methods to rectangle to get its corners as locations --- osx/classes/location.cpp | 16 ++++++++++++++++ osx/classes/location.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/osx/classes/location.cpp b/osx/classes/location.cpp index ec144c9c..50b7a3ba 100644 --- a/osx/classes/location.cpp +++ b/osx/classes/location.cpp @@ -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; diff --git a/osx/classes/location.h b/osx/classes/location.h index 5129f967..542a7755 100644 --- a/osx/classes/location.h +++ b/osx/classes/location.h @@ -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);