Add a method to fetch the center of a rect

This commit is contained in:
Patrick Walton 2020-02-18 14:36:10 -08:00
parent dcd12279d4
commit df150dea8a
1 changed files with 5 additions and 0 deletions

View File

@ -155,6 +155,11 @@ impl RectF {
self.0[3]
}
#[inline]
pub fn center(self) -> Vector2F {
self.origin() + self.size().scale(0.5)
}
#[inline]
pub fn scale(self, factor: f32) -> RectF {
RectF(self.0 * F32x4::splat(factor))