URect

URect

  • min : glam::UVec2
  • max : glam::UVec2

Description

A rectangle defined by two opposite corners.

The rectangle is axis aligned, and defined by its minimum and maximum coordinates, stored in URect::min and URect::max, respectively. The minimum/maximum invariant must be upheld by the user when directly assigning the fields, otherwise some methods produce invalid results. It is generally recommended to use one of the constructor methods instead, which will ensure this invariant is met, unless you already have the minimum and maximum corners.

Functions

FunctionSummary
as_irect(_self) Returns self as [`IRect`] (i32)
as_rect(_self) Returns self as [`Rect`] (f32)
assert_receiver_is_total_eq(_self)No Documentation 🚧
center(_self) The center point of the rectangle. # Rounding Behavior If the (min + max) contains odd numbers th
clone(_self)No Documentation 🚧
contains(_self, point) Check if a point lies within this rectangle, inclusive of its edges. # Examples ``` # use bevy_math::URect; let r = URect::new(0, 0, 5, 1); // w=5 h=1 assert!(r.contains(r.center())); assert!(r.contains(r.min)); assert!(r.contains(r.max)); ```
eq(_self, other)No Documentation 🚧
from_center_half_size(origin, half_size) Create a new rectangle from its center and half-size. # Panics This method panics if any of the c
from_center_size(origin, size) Create a new rectangle from its center and size. # Rounding Behavior If the size contains odd num
from_corners(p0, p1) Create a new rectangle from two corner points. The two points do not need to be the minimum and/or
half_size(_self) Rectangle half-size. # Rounding Behavior If the full size contains odd numbers they will be round
height(_self) Rectangle height (max.y - min.y). # Examples ``` # use bevy_math::URect; let r = URect::new(0, 0, 5, 1); // w=5 h=1 assert_eq!(r.height(), 1); `
inflate(_self, expansion) Create a new rectangle by expanding it evenly on all sides. A positive expansion value produces a
intersect(_self, other) Build a new rectangle formed of the intersection of this rectangle and another rectangle. The inte
is_empty(_self) Check if the rectangle is empty. # Examples ``` # use bevy_math::{URect, UVec2}; let r = URect::from_corners(UVec2::ZERO, UVec2::new(0, 1)); // w=0 h=1 assert!(r.is_empty()); ```
new(x0, y0, x1, y1) Create a new rectangle from two corner points. The two points do not need to be the minimum and/or
size(_self) Rectangle size. # Examples ``` # use bevy_math::{URect, UVec2}; let r = URect::new(0, 0, 5, 1); // w=5 h=1 assert_eq!(r.size(), UVec2::new(5, 1)); `
union(_self, other) Build a new rectangle formed of the union of this rectangle and another rectangle. The union is th
union_point(_self, other) Build a new rectangle formed of the union of this rectangle and a point. The union is the smallest
width(_self) Rectangle width (max.x - min.x). # Examples ``` # use bevy_math::URect; let r = URect::new(0, 0, 5, 1); // w=5 h=1 assert_eq!(r.width(), 5); `