pub struct Rectangle {
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
}Expand description
Axis-aligned rectangle, (x, y) is the top-left corner.
Fields§
§x: f64§y: f64§width: f64§height: f64Implementations§
Source§impl Rectangle
impl Rectangle
Sourcepub fn new(x: f64, y: f64, width: f64, height: f64) -> Rectangle
pub fn new(x: f64, y: f64, width: f64, height: f64) -> Rectangle
Panics if width < 0 or height < 0.
pub fn area(&self) -> f64
pub fn perimeter(&self) -> f64
pub fn centroid(&self) -> Point2
pub fn contains(&self, p: Point2) -> bool
Sourcepub fn intersects(&self, other: &Rectangle) -> bool
pub fn intersects(&self, other: &Rectangle) -> bool
Overlap of two axis-aligned rectangles.
Sourcepub fn rotated_polygon(&self, angle: f64) -> Polygon
pub fn rotated_polygon(&self, angle: f64) -> Polygon
Rotate by angle radians about the centroid, returning the resulting Polygon.
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 UnsafeUnpin 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