pub struct Rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}Expand description
2D rectangle representing screen or chart bounds
Fields§
§x: f32§y: f32§width: f32§height: f32Implementations§
Source§impl Rect
impl Rect
pub fn new(x: f32, y: f32, width: f32, height: f32) -> Self
pub fn from_size(width: f32, height: f32) -> Self
pub fn right(&self) -> f32
pub fn bottom(&self) -> f32
pub fn center(&self) -> Vec2
pub fn contains_point(&self, point: Vec2) -> bool
pub fn intersects(&self, other: &Rect) -> bool
Sourcepub fn split_horizontal(&self, ratio: f32) -> (Rect, Rect)
pub fn split_horizontal(&self, ratio: f32) -> (Rect, Rect)
Split rectangle horizontally into two parts
Sourcepub fn intersection(&self, other: &Rect) -> Option<Rect>
pub fn intersection(&self, other: &Rect) -> Option<Rect>
Calculate the intersection of two rectangles
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rect
impl<'de> Deserialize<'de> for Rect
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Freeze for Rect
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnsafeUnpin for Rect
impl UnwindSafe for Rect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more