pub trait AlignRectMut: TranslateMut {
    // Provided method
    fn align_mut(
        &mut self,
        mode: AlignMode,
        srect: Rect,
        orect: Rect,
        offset: i64
    ) { ... }
}
Expand description

A geometric shape that can be aligned using the relationship between two Rects.

§Examples

let mut rect1 = Rect::from_sides(0, 0, 100, 200);
let rect2 = Rect::from_sides(500, 600, 700, 700);
rect1.align_mut(AlignMode::Left, rect1, rect2, 0);
assert_eq!(rect1.left(), rect2.left());
assert_eq!(rect1, Rect::from_sides(500, 0, 600, 200));

// 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 alignment.
let rect1_alt = rect1.shrink_all(5).unwrap();
rect1.align_mut(AlignMode::Left, rect1_alt, rect2, 0);
assert_eq!(rect1, Rect::from_sides(495, 0, 595, 200));

Provided Methods§

source

fn align_mut(&mut self, mode: AlignMode, srect: Rect, orect: Rect, offset: i64)

Align self based on the relationship between srect and orect.

offset represents an offset from the base alignment in the positive direction along the alignment axis.

For center alignments, if the centers are a non-integer number of units apart, the translation amount is rounded down to the nearest integer. This behavior is subject to change and should not be relied upon.

Implementors§

source§

impl<T> AlignRectMut for T
where T: Translate,