Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
c01d248a
Commit
c01d248a
authored
Dec 31, 2011
by
Davis King
Browse files
Added some overloads of shrink_rect() and grow_rect() which
allow you to adjust the width and height independently.
parent
bcf8df16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
dlib/geometry/rectangle.h
dlib/geometry/rectangle.h
+22
-0
dlib/geometry/rectangle_abstract.h
dlib/geometry/rectangle_abstract.h
+27
-0
No files found.
dlib/geometry/rectangle.h
View file @
c01d248a
...
@@ -466,6 +466,28 @@ namespace dlib
...
@@ -466,6 +466,28 @@ namespace dlib
return
shrink_rect
(
rect
,
-
num
);
return
shrink_rect
(
rect
,
-
num
);
}
}
// ----------------------------------------------------------------------------------------
inline
const
rectangle
shrink_rect
(
const
rectangle
&
rect
,
long
width
,
long
height
)
{
return
rectangle
(
rect
.
left
()
+
width
,
rect
.
top
()
+
height
,
rect
.
right
()
-
width
,
rect
.
bottom
()
-
height
);
}
// ----------------------------------------------------------------------------------------
inline
const
rectangle
grow_rect
(
const
rectangle
&
rect
,
long
width
,
long
height
)
{
return
shrink_rect
(
rect
,
-
width
,
-
height
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
inline
const
rectangle
translate_rect
(
inline
const
rectangle
translate_rect
(
...
...
dlib/geometry/rectangle_abstract.h
View file @
c01d248a
...
@@ -491,6 +491,33 @@ namespace dlib
...
@@ -491,6 +491,33 @@ namespace dlib
(i.e. grows the given rectangle by expanding its border by num)
(i.e. grows the given rectangle by expanding its border by num)
!*/
!*/
// ----------------------------------------------------------------------------------------
inline
const
rectangle
shrink_rect
(
const
rectangle
&
rect
,
long
width
,
long
height
);
/*!
ensures
- returns rectangle(rect.left()+width, rect.top()+height, rect.right()-width, rect.bottom()-height)
(i.e. shrinks the given rectangle by shrinking its left and right borders by width
and its top and bottom borders by height. )
!*/
// ----------------------------------------------------------------------------------------
inline
const
rectangle
grow_rect
(
const
rectangle
&
rect
,
long
width
,
long
height
);
/*!
ensures
- return shrink_rect(rect, -width, -height)
(i.e. grows the given rectangle by expanding its border)
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
const
rectangle
translate_rect
(
const
rectangle
translate_rect
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment