Added operator + support for dlib.rectangle.

This commit is contained in:
Davis King 2018-03-03 17:21:23 -05:00
parent 4e01b7790b
commit 1c26be904c

View File

@ -68,6 +68,30 @@ string print_rectangle_repr(const rect_type& r)
return sout.str();
}
rectangle add_point_to_rect(const rectangle& r, const point& p)
{
return r + p;
}
rectangle add_rect_to_rect(const rectangle& r, const rectangle& p)
{
return r + p;
}
rectangle& iadd_point_to_rect(rectangle& r, const point& p)
{
r += p;
return r;
}
rectangle& iadd_rect_to_rect(rectangle& r, const rectangle& p)
{
r += p;
return r;
}
// ----------------------------------------------------------------------------------------
void bind_rectangles(py::module& m)
@ -92,6 +116,10 @@ void bind_rectangles(py::module& m)
.def("intersect", &::intersect<type>, py::arg("rectangle"))
.def("__str__", &::print_rectangle_str<type>)
.def("__repr__", &::print_rectangle_repr<type>)
.def("__add__", &::add_point_to_rect)
.def("__add__", &::add_rect_to_rect)
.def("__iadd__", &::iadd_point_to_rect)
.def("__iadd__", &::iadd_rect_to_rect)
.def(py::self == py::self)
.def(py::self != py::self)
.def(py::pickle(&getstate<type>, &setstate<type>));