pub trait PlaceRect: PlaceRectMut + Sized {
    // Provided method
    fn place(self, mode: PlaceMode, srect: Rect, pt: Point) -> Self { ... }
}
Expand description

A geometric shape that can be placed at a point.

§Examples

let mut rect1 = Rect::from_sides(0, 0, 100, 200);
assert_eq!(
    rect1.place(PlaceMode::Center, rect1, Point::new(25, 25)),
    Rect::from_sides(-25, -75, 75, 125),
);

// Alternate rectangle to align `rect1` with.
// Conceptually, this represents that `rect1` has
// 5 units of hangover space on all sides that should
// not contribute to placement.
let rect1_alt = rect1.shrink_all(5).unwrap();

assert_eq!(
    rect1.place(
        PlaceMode::Corner(Corner::UpperRight),
        rect1_alt,
        Point::new(25, 25)
    ),
    Rect::from_sides(-70, -170, 30, 30),
);

Provided Methods§

source

fn place(self, mode: PlaceMode, srect: Rect, pt: Point) -> Self

Places an object at the given point.

For center alignments, the center’s non-integer coordinates are rounded down to the nearest integer. This behavior is subject to change and should not be relied upon.

Creates a new shape at the placed location.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> PlaceRect for T
where T: PlaceRectMut,