Struct emath::Rect [−][src]
A rectangular region of space.
Normally given in points, e.g. logical pixels.
Fields
min: Pos2
max: Pos2
Implementations
impl Rect
[src]
pub const EVERYTHING: Self
[src]
Infinite rectangle that contains everything.
pub const NOTHING: Self
[src]
The inverse of Self::EVERYTHING
: stretches from positive infinity to negative infinity.
Contains no points.
This is useful as the seed for bounding bounding boxes.
let inf = f32::INFINITY; assert!(Rect::NOTHING.size() == Vec2::splat(-inf)); assert!(Rect::NOTHING.contains(pos2(0.0, 0.0)) == false);
Example:
let mut rect = Rect::NOTHING; rect.extend_with(pos2(2.0, 1.0)); rect.extend_with(pos2(0.0, 3.0)); assert_eq!(rect, Rect::from_min_max(pos2(0.0, 1.0), pos2(2.0, 3.0)))
pub const NAN: Self
[src]
An invalid Rect
filled with f32::NAN
;
pub fn everything() -> Self
[src]
Use Rect::EVERYTHING
pub fn nothing() -> Self
[src]
Use Rect::NOTHING
pub fn invalid() -> Self
[src]
Use Rect::NAN
pub const fn from_min_max(min: Pos2, max: Pos2) -> Self
[src]
pub fn from_min_size(min: Pos2, size: Vec2) -> Self
[src]
pub fn from_center_size(center: Pos2, size: Vec2) -> Self
[src]
pub fn from_x_y_ranges(
x_range: RangeInclusive<f32>,
y_range: RangeInclusive<f32>
) -> Self
[src]
x_range: RangeInclusive<f32>,
y_range: RangeInclusive<f32>
) -> Self
pub fn from_two_pos(a: Pos2, b: Pos2) -> Self
[src]
#[must_use]pub fn expand(self, amnt: f32) -> Self
[src]
Expand by this much in each direction, keeping the center
#[must_use]pub fn expand2(self, amnt: Vec2) -> Self
[src]
Expand by this much in each direction, keeping the center
#[must_use]pub fn shrink(self, amnt: f32) -> Self
[src]
Shrink by this much in each direction, keeping the center
#[must_use]pub fn shrink2(self, amnt: Vec2) -> Self
[src]
Shrink by this much in each direction, keeping the center
#[must_use]pub fn translate(self, amnt: Vec2) -> Self
[src]
#[must_use]pub fn intersect(self, other: Rect) -> Self
[src]
#[must_use]pub fn intersects(self, other: Rect) -> bool
[src]
pub fn set_width(&mut self, w: f32)
[src]
keep min
pub fn set_height(&mut self, h: f32)
[src]
keep min
pub fn set_center(&mut self, center: Pos2)
[src]
Keep size
#[must_use]pub fn contains(&self, p: Pos2) -> bool
[src]
#[must_use]pub fn clamp(&self, p: Pos2) -> Pos2
[src]
Return the given points clamped to be inside the rectangle
pub fn extend_with(&mut self, p: Pos2)
[src]
pub fn extend_with_x(&mut self, x: f32)
[src]
Expand to include the given x coordinate
pub fn extend_with_y(&mut self, y: f32)
[src]
Expand to include the given y coordinate
pub fn union(self, other: Rect) -> Rect
[src]
pub fn center(&self) -> Pos2
[src]
pub fn size(&self) -> Vec2
[src]
pub fn width(&self) -> f32
[src]
pub fn height(&self) -> f32
[src]
pub fn aspect_ratio(&self) -> f32
[src]
Width / height
aspect_ratio < 1
: portrait / highaspect_ratio = 1
: squareaspect_ratio > 1
: landscape / wide
pub fn square_proportions(&self) -> Vec2
[src]
[2, 1]
for wide screen, and [1, 2]
for portrait, etc.
At least one dimension = 1, the other >= 1
Returns the proportions required to letter-box a square view area.
pub fn area(&self) -> f32
[src]
pub fn x_range(&self) -> RangeInclusive<f32>
[src]
pub fn y_range(&self) -> RangeInclusive<f32>
[src]
pub fn bottom_up_range(&self) -> RangeInclusive<f32>
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn is_finite(&self) -> bool
[src]
pub fn left(&self) -> f32
[src]
pub fn right(&self) -> f32
[src]
pub fn top(&self) -> f32
[src]
pub fn bottom(&self) -> f32
[src]
pub fn left_top(&self) -> Pos2
[src]
pub fn center_top(&self) -> Pos2
[src]
pub fn right_top(&self) -> Pos2
[src]
pub fn left_center(&self) -> Pos2
[src]
pub fn right_center(&self) -> Pos2
[src]
pub fn left_bottom(&self) -> Pos2
[src]
pub fn center_bottom(&self) -> Pos2
[src]
pub fn right_bottom(&self) -> Pos2
[src]
Trait Implementations
impl Clone for Rect
[src]
impl Copy for Rect
[src]
impl Debug for Rect
[src]
impl Eq for Rect
[src]
impl From<[Pos2; 2]> for Rect
[src]
from (min, max) or (left top, right bottom)
impl PartialEq<Rect> for Rect
[src]
impl StructuralEq for Rect
[src]
impl StructuralPartialEq for Rect
[src]
Auto Trait Implementations
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnwindSafe for Rect
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,