#[repr(C)]pub struct Rectangle {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}
Fields§
§x: f32
§y: f32
§width: f32
§height: f32
Implementations§
Source§impl Rectangle
impl Rectangle
Sourcepub fn check_collision_recs(&self, other: &Rectangle) -> bool
pub fn check_collision_recs(&self, other: &Rectangle) -> bool
Check collision between two rectangles
Sourcepub fn check_collision_circle_rec(
&self,
center: impl Into<Vector2>,
radius: f32,
) -> bool
pub fn check_collision_circle_rec( &self, center: impl Into<Vector2>, radius: f32, ) -> bool
Checks collision between circle and rectangle.
Sourcepub fn get_collision_rec(&self, other: &Rectangle) -> Option<Rectangle>
pub fn get_collision_rec(&self, other: &Rectangle) -> Option<Rectangle>
Gets the overlap between two colliding rectangles.
use raylib::prelude::*;
fn main() {
let r1 = Rectangle::new(0.0, 0.0, 10.0, 10.0);
let r2 = Rectangle::new(20.0, 20.0, 10.0, 10.0);
assert_eq!(None, r1.get_collision_rec(&r2));
assert_eq!(Some(r1), r1.get_collision_rec(&r1));
}
Sourcepub fn check_collision_point_rec(&self, point: impl Into<Vector2>) -> bool
pub fn check_collision_point_rec(&self, point: impl Into<Vector2>) -> bool
Checks if point is inside rectangle.
Trait Implementations§
impl Copy for Rectangle
impl StructuralPartialEq for Rectangle
Auto Trait Implementations§
impl Freeze for Rectangle
impl RefUnwindSafe for Rectangle
impl Send for Rectangle
impl Sync for Rectangle
impl Unpin for Rectangle
impl UnwindSafe for Rectangle
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