Struct Rectangle
pub struct Rectangle<T = f32> {
pub x: T,
pub y: T,
pub width: T,
pub height: T,
}Expand description
An axis-aligned rectangle.
Fields§
§x: TX coordinate of the top-left corner.
y: TY coordinate of the top-left corner.
width: TWidth of the rectangle.
height: THeight of the rectangle.
Implementations§
§impl Rectangle
impl Rectangle
pub const INFINITE: Rectangle
pub const INFINITE: Rectangle
A rectangle starting at negative infinity and with infinite width and height.
pub fn with_radius(radius: f32) -> Rectangle
pub fn with_radius(radius: f32) -> Rectangle
Creates a new square Rectangle with the center at the origin and
with the given radius.
pub fn with_vertices(
top_left: Point,
top_right: Point,
bottom_left: Point,
) -> (Rectangle, Radians)
pub fn with_vertices( top_left: Point, top_right: Point, bottom_left: Point, ) -> (Rectangle, Radians)
pub fn offset(&self, container: &Rectangle) -> Vector
pub fn offset(&self, container: &Rectangle) -> Vector
Computes the offset that must be applied to the Rectangle to be placed
inside the given container.
pub fn is_within(&self, container: &Rectangle) -> bool
pub fn is_within(&self, container: &Rectangle) -> bool
Returns true if the current Rectangle is within the given
container. Includes the right and bottom edges.
pub fn intersection(&self, other: &Rectangle) -> Option<Rectangle>
pub fn intersection(&self, other: &Rectangle) -> Option<Rectangle>
Computes the intersection with the given Rectangle.
pub fn intersects(&self, other: &Rectangle) -> bool
pub fn intersects(&self, other: &Rectangle) -> bool
Returns whether the Rectangle intersects with the given one.
pub fn zoom(self, zoom: f32) -> Rectangle
pub fn zoom(self, zoom: f32) -> Rectangle
Scales the Rectangle without changing its position, effectively
“zooming” it.
pub fn anchor(
&self,
size: Size,
align_x: impl Into<Horizontal>,
align_y: impl Into<Vertical>,
) -> Point
pub fn anchor( &self, size: Size, align_x: impl Into<Horizontal>, align_y: impl Into<Vertical>, ) -> Point
pub fn chord(&self, angle: impl Into<Radians>) -> (Point, Point)
pub fn chord(&self, angle: impl Into<Radians>) -> (Point, Point)
Returns the two endpoints of a chord through the rectangle’s center
at the given angle.
The angle is measured clockwise from the negative y-axis, so 0
produces a vertical chord and π/2 a horizontal one. The returned
points are (start, end), symmetric about Rectangle::center.
Trait Implementations§
§impl<T> AddAssign<Vector<T>> for Rectangle<T>where
T: AddAssign,
impl<T> AddAssign<Vector<T>> for Rectangle<T>where
T: AddAssign,
§fn add_assign(&mut self, translation: Vector<T>)
fn add_assign(&mut self, translation: Vector<T>)
+= operation. Read more§impl Mul<Transformation> for Rectangle
impl Mul<Transformation> for Rectangle
§impl<T> SubAssign<Vector<T>> for Rectangle<T>where
T: SubAssign,
impl<T> SubAssign<Vector<T>> for Rectangle<T>where
T: SubAssign,
§fn sub_assign(&mut self, translation: Vector<T>)
fn sub_assign(&mut self, translation: Vector<T>)
-= operation. Read moreimpl<T> Copy for Rectangle<T>where
T: Copy,
impl<T> Eq for Rectangle<T>where
T: Eq,
impl<T> StructuralPartialEq for Rectangle<T>
Auto Trait Implementations§
impl<T> Freeze for Rectangle<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rectangle<T>where
T: RefUnwindSafe,
impl<T> Send for Rectangle<T>where
T: Send,
impl<T> Sync for Rectangle<T>where
T: Sync,
impl<T> Unpin for Rectangle<T>where
T: Unpin,
impl<T> UnsafeUnpin for Rectangle<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Rectangle<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().