diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-11-05 16:56:45 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-11-05 19:45:23 -0500 |
commit | 857719f2e12bdfbb6f770afe75c0f968b2c4fa2c (patch) | |
tree | 3e701c6339901d9c5b923972f78151c91bb056a5 /libs/canvas/types.cc | |
parent | f3d349bc9a05eacfaa5c443ce5657f59d328d2f2 (diff) |
add Rect::shrink(Distance) even though it arguably should be handled by Rect::expand()
Diffstat (limited to 'libs/canvas/types.cc')
-rw-r--r-- | libs/canvas/types.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/libs/canvas/types.cc b/libs/canvas/types.cc index 4fd064d746..4c8cd854f2 100644 --- a/libs/canvas/types.cc +++ b/libs/canvas/types.cc @@ -102,6 +102,24 @@ Rect::expand (Distance amount) const return r; } +Rect +Rect::shrink (Distance amount) const +{ + /* This isn't the equivalent of expand (-distance) because + of the peculiarities of safe_add() with negative values. + Maybe. + */ + + Rect r; + + r.x0 = safe_add (x0, amount); + r.y0 = safe_add (y0, amount); + r.x1 = x1 - amount; + r.y1 = y1 - amount; + + return r; +} + bool Rect::contains (Duple point) const { |