pub struct LayoutRect {
pub origin: LayoutPoint,
pub size: LayoutSize,
}Expand description
An axis-aligned rectangle: an origin point plus a size.
LayoutRect is the final output for every node after layout: it says exactly
where the node sits on screen and how large it is.
§Example
use fission_layout::{LayoutRect, LayoutPoint};
let rect = LayoutRect::new(10.0, 20.0, 300.0, 200.0);
assert_eq!(rect.right(), 310.0);
assert!(rect.contains(LayoutPoint::new(15.0, 25.0)));Fields§
§origin: LayoutPointThe top-left corner of the rectangle.
size: LayoutSizeThe width and height of the rectangle.
Implementations§
Source§impl LayoutRect
impl LayoutRect
Sourcepub fn new(
x: LayoutUnit,
y: LayoutUnit,
width: LayoutUnit,
height: LayoutUnit,
) -> Self
pub fn new( x: LayoutUnit, y: LayoutUnit, width: LayoutUnit, height: LayoutUnit, ) -> Self
Creates a rectangle from x, y, width, and height.
Sourcepub fn x(&self) -> LayoutUnit
pub fn x(&self) -> LayoutUnit
The x coordinate of the left edge.
Sourcepub fn y(&self) -> LayoutUnit
pub fn y(&self) -> LayoutUnit
The y coordinate of the top edge.
Sourcepub fn width(&self) -> LayoutUnit
pub fn width(&self) -> LayoutUnit
The width of the rectangle.
Sourcepub fn height(&self) -> LayoutUnit
pub fn height(&self) -> LayoutUnit
The height of the rectangle.
Sourcepub fn right(&self) -> LayoutUnit
pub fn right(&self) -> LayoutUnit
The x coordinate of the right edge (x + width).
Sourcepub fn bottom(&self) -> LayoutUnit
pub fn bottom(&self) -> LayoutUnit
The y coordinate of the bottom edge (y + height).
Sourcepub fn contains(&self, p: LayoutPoint) -> bool
pub fn contains(&self, p: LayoutPoint) -> bool
Returns true if the point p lies within this rectangle (inclusive on
the left/top edges, exclusive on the right/bottom edges).
Trait Implementations§
Source§impl Clone for LayoutRect
impl Clone for LayoutRect
Source§fn clone(&self) -> LayoutRect
fn clone(&self) -> LayoutRect
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LayoutRect
impl Debug for LayoutRect
Source§impl<'de> Deserialize<'de> for LayoutRect
impl<'de> Deserialize<'de> for LayoutRect
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 LayoutRect
impl PartialEq for LayoutRect
Source§impl Serialize for LayoutRect
impl Serialize for LayoutRect
impl Copy for LayoutRect
impl StructuralPartialEq for LayoutRect
Auto Trait Implementations§
impl Freeze for LayoutRect
impl RefUnwindSafe for LayoutRect
impl Send for LayoutRect
impl Sync for LayoutRect
impl Unpin for LayoutRect
impl UnsafeUnpin for LayoutRect
impl UnwindSafe for LayoutRect
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