diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-10 20:35:05 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-10 20:35:05 +0100 |
| commit | ed70b4faf0f53b106aebd4b9195ccc81da97880e (patch) | |
| tree | 03ccbe558fbcc4165115e89212692ebcc0fda019 /src/lib/util.cc | |
| parent | cc4a67b7eb8ecaed076e261960848f70e3e741af (diff) | |
Thumbs sort of have subs.
Diffstat (limited to 'src/lib/util.cc')
| -rw-r--r-- | src/lib/util.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib/util.cc b/src/lib/util.cc index 935566440..82aaf8ff5 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -600,3 +600,16 @@ Socket::read_indefinite (uint8_t* data, int size, int timeout) assert (size >= _buffer_data); memcpy (data, _buffer, size); } + +Rectangle +Rectangle::intersection (Rectangle const & other) const +{ + int const tx = max (x, other.x); + int const ty = max (y, other.y); + + return Rectangle ( + tx, ty, + min (x + w, other.x + other.w) - tx, + min (y + h, other.y + other.h) - ty + ); +} |
