add Rect::shrink(Distance) even though it arguably should be handled by Rect::expand()
This commit is contained in:
parent
f3d349bc9a
commit
857719f2e1
@ -94,6 +94,7 @@ struct LIBCANVAS_API Rect
|
||||
Rect extend (Rect const &) const;
|
||||
Rect translate (Duple) const;
|
||||
Rect expand (Distance) const;
|
||||
Rect shrink (Distance) const;
|
||||
bool contains (Duple) const;
|
||||
Rect fix () const;
|
||||
bool empty() const { return (x0 == x1 && y0 == y1); }
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user