Add Rect::offset

This commit is contained in:
Alexandre Bury 2018-03-16 18:06:53 -07:00
parent 5d3c0d3fb0
commit e23a5cd3a2

View File

@ -79,6 +79,13 @@ impl Rect {
self
}
/// Adds the given offset to this rectangle.
pub fn offset<V>(&mut self, offset: V) where V: Into<Vec2> {
let offset = offset.into();
self.top_left = self.top_left + offset;
self.bottom_right = self.bottom_right + offset;
}
/// Returns the size of the rectangle.
pub fn size(self) -> Vec2 {
self.bottom_right - self.top_left + (1, 1)