Commit 1c26be90 authored by Davis King's avatar Davis King

Added operator + support for dlib.rectangle.

parent 4e01b779
......@@ -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>));
......
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