diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp
index 848d9b4f9900689b79ff86c39707d7090122d18d..72bced37bb048ca9337d8c03658710f412c2dd81 100644 (file)
--- a/src/libnr/nr-rect.cpp
+++ b/src/libnr/nr-rect.cpp
Rect::Rect(const Point &p0, const Point &p1)
: _min(std::min(p0[X], p1[X]), std::min(p0[Y], p1[Y])),
- _max(std::max(p0[X], p1[X]), std::max(p0[Y], p1[Y])) {}
+ _max(std::max(p0[X], p1[X]), std::max(p0[Y], p1[Y]))
+{}
/** returns the four corners of the rectangle in the correct winding order */
Point Rect::corner(unsigned i) const {
}
}
+void Rect::growBy(double size) {
+ for ( unsigned d = 0 ; d < 2 ; d++ ) {
+ _min[d] -= size;
+ _max[d] += size;
+ if ( _min[d] > _max[d] ) {
+ _min[d] = _max[d] = ( _min[d] + _max[d] ) / 2;
+ }
+ }
+}
+
/** Returns the set of points shared by both rectangles. */
-Maybe<Rect> intersection(Maybe<Rect const &> a, Maybe<Rect const &> b) {
+Maybe<Rect> intersection(Maybe<Rect> const & a, Maybe<Rect> const & b) {
if ( !a || !b ) {
return Nothing();
} else {