Struct bevy_math::primitives::Rectangle
source · pub struct Rectangle {
pub half_size: Vec2,
}
Expand description
A rectangle primitive
Fields§
§half_size: Vec2
Half of the width and height of the rectangle
Implementations§
source§impl Rectangle
impl Rectangle
sourcepub fn new(width: f32, height: f32) -> Self
pub fn new(width: f32, height: f32) -> Self
Create a new Rectangle
from a full width and height
sourcepub fn from_corners(point1: Vec2, point2: Vec2) -> Self
pub fn from_corners(point1: Vec2, point2: Vec2) -> Self
Create a new Rectangle
from two corner points
sourcepub fn closest_point(&self, point: Vec2) -> Vec2
pub fn closest_point(&self, point: Vec2) -> Vec2
Finds the point on the rectangle that is closest to the given point
.
If the point is outside the rectangle, the returned point will be on the perimeter of the rectangle. Otherwise, it will be inside the rectangle and returned as is.
Trait Implementations§
source§impl Bounded2d for Rectangle
impl Bounded2d for Rectangle
source§fn aabb_2d(&self, translation: Vec2, rotation: f32) -> Aabb2d
fn aabb_2d(&self, translation: Vec2, rotation: f32) -> Aabb2d
Get an axis-aligned bounding box for the shape with the given translation and rotation.
The rotation is in radians, counterclockwise, with 0 meaning no rotation.
source§fn bounding_circle(&self, translation: Vec2, _rotation: f32) -> BoundingCircle
fn bounding_circle(&self, translation: Vec2, _rotation: f32) -> BoundingCircle
Get a bounding circle for the shape
The rotation is in radians, counterclockwise, with 0 meaning no rotation.
source§impl<'de> Deserialize<'de> for Rectangle
impl<'de> Deserialize<'de> for Rectangle
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
source§impl PartialEq for Rectangle
impl PartialEq for Rectangle
impl Copy for Rectangle
impl Primitive2d for Rectangle
impl StructuralPartialEq for Rectangle
Auto Trait Implementations§
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