Commit 6adfdac9 authored by Davis King's avatar Davis King

Added shrink_rect() and grow_rect() for drectangle objects.

parent 43e29a07
......@@ -365,6 +365,40 @@ namespace dlib
return drectangle(p.x()-width/2, p.y()-height/2, p.x()+width/2, p.y()+height/2);
}
inline const drectangle shrink_rect (
const drectangle& rect,
double num
)
{
return drectangle(rect.left()+num, rect.top()+num, rect.right()-num, rect.bottom()-num);
}
inline const drectangle grow_rect (
const drectangle& rect,
double num
)
{
return shrink_rect(rect, -num);
}
inline const drectangle shrink_rect (
const drectangle& rect,
double width,
double height
)
{
return drectangle(rect.left()+width, rect.top()+height, rect.right()-width, rect.bottom()-height);
}
inline const drectangle grow_rect (
const drectangle& rect,
double width,
double height
)
{
return shrink_rect(rect, -width, -height);
}
// ----------------------------------------------------------------------------------------
}
......
......@@ -490,6 +490,57 @@ namespace dlib
- R.tl_corner() == point(p.x()-width/2, p.y()-height/2)
!*/
// ----------------------------------------------------------------------------------------
const drectangle shrink_rect (
const drectangle& rect,
double num
);
/*!
ensures
- returns drectangle(rect.left()+num, rect.top()+num, rect.right()-num, rect.bottom()-num)
(i.e. shrinks the given drectangle by shrinking its border by num)
!*/
// ----------------------------------------------------------------------------------------
const drectangle grow_rect (
const drectangle& rect,
double num
);
/*!
ensures
- return shrink_rect(rect, -num)
(i.e. grows the given drectangle by expanding its border by num)
!*/
// ----------------------------------------------------------------------------------------
const drectangle shrink_rect (
const drectangle& rect,
double width,
double height
);
/*!
ensures
- returns drectangle(rect.left()+width, rect.top()+height, rect.right()-width, rect.bottom()-height)
(i.e. shrinks the given drectangle by shrinking its left and right borders by width
and its top and bottom borders by height. )
!*/
// ----------------------------------------------------------------------------------------
const drectangle grow_rect (
const drectangle& rect,
double width,
double height
);
/*!
ensures
- return shrink_rect(rect, -width, -height)
(i.e. grows the given drectangle by expanding its border)
!*/
// ----------------------------------------------------------------------------------------
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment