pub struct PxRect {
pub x: Px,
pub y: Px,
pub width: Px,
pub height: Px,
}Expand description
A 2D rectangle in physical pixel space.
Fields§
§x: PxThe x-coordinate of the top-left corner
y: PxThe y-coordinate of the top-left corner
width: PxThe width of the rectangle
height: PxThe height of the rectangle
Implementations§
Source§impl PxRect
impl PxRect
Sourcepub const fn new(x: Px, y: Px, width: Px, height: Px) -> Self
pub const fn new(x: Px, y: Px, width: Px, height: Px) -> Self
Creates a new rectangle from position and size.
Sourcepub fn from_position_size(position: PxPosition, size: PxSize) -> Self
pub fn from_position_size(position: PxPosition, size: PxSize) -> Self
Creates a new rectangle from a position and size.
Sourcepub fn is_orthogonal(&self, other: &Self) -> bool
pub fn is_orthogonal(&self, other: &Self) -> bool
Returns whether the rectangles do not overlap; touching edges do not overlap.
Sourcepub fn union(&self, other: &Self) -> Self
pub fn union(&self, other: &Self) -> Self
Returns the smallest rectangle containing both rectangles.
§Examples
use tessera_ui::px::{Px, PxRect};
let rect1 = PxRect::new(Px::new(0), Px::new(0), Px::new(100), Px::new(100));
let rect2 = PxRect::new(Px::new(50), Px::new(50), Px::new(100), Px::new(100));
let union_rect = rect1.union(&rect2);
assert_eq!(
union_rect,
PxRect::new(Px::new(0), Px::new(0), Px::new(150), Px::new(150))
);Sourcepub fn intersection(&self, other: &Self) -> Option<Self>
pub fn intersection(&self, other: &Self) -> Option<Self>
Returns the overlapping rectangle, or None when edges only touch.
§Examples
use tessera_ui::px::{Px, PxRect};
let rect1 = PxRect::new(Px::new(0), Px::new(0), Px::new(100), Px::new(100));
let rect2 = PxRect::new(Px::new(50), Px::new(50), Px::new(100), Px::new(100));
let intersection = rect1.intersection(&rect2);
assert_eq!(
intersection,
Some(PxRect::new(
Px::new(50),
Px::new(50),
Px::new(50),
Px::new(50)
))
);Sourcepub fn contains(&self, point: PxPosition) -> bool
pub fn contains(&self, point: PxPosition) -> bool
Includes the top and left edges and excludes the bottom and right edges.
Trait Implementations§
impl Copy for PxRect
impl Eq for PxRect
impl StructuralPartialEq for PxRect
Auto Trait Implementations§
impl Freeze for PxRect
impl RefUnwindSafe for PxRect
impl Send for PxRect
impl Sync for PxRect
impl Unpin for PxRect
impl UnsafeUnpin for PxRect
impl UnwindSafe for PxRect
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§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>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
Converts
&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)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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
Compare self to
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
Checks if this value is equivalent to the given key. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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
The none-equivalent value.