Browse Source

Add 'Center()' method on 'Rectangle'

pull/2753/head
Juliano Leal Goncalves 5 years ago committed by Anders Jenbo
parent
commit
f90d3239e5
  1. 8
      Source/engine/rectangle.hpp

8
Source/engine/rectangle.hpp

@ -16,6 +16,14 @@ struct Rectangle {
&& point.y >= this->position.y
&& point.y < (this->position.y + this->size.height);
}
/**
* @brief Computes the center of this rectangle in integer coordinates. Values are truncated towards zero.
*/
constexpr Point Center() const
{
return position + Displacement(size / 2);
}
};
} // namespace devilution

Loading…
Cancel
Save