pub trait AlignRect: AlignRectMut + Sized {
// Provided method
fn align(
self,
mode: AlignMode,
srect: Rect,
orect: Rect,
offset: i64
) -> Self { ... }
}
Expand description
A geometric shape that can be aligned using the relationship between two Rect
s.
Takes in an owned copy of the shape and returns the aligned version.
§Examples
let mut rect1 = Rect::from_sides(0, 0, 100, 200);
let rect2 = Rect::from_sides(500, 600, 700, 700);
let rect1 = rect1.align(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();
assert_eq!(rect1.align(AlignMode::Left, rect1_alt, rect2, 0), Rect::from_sides(495, 0, 595, 200));
Provided Methods§
sourcefn align(self, mode: AlignMode, srect: Rect, orect: Rect, offset: i64) -> Self
fn align(self, mode: AlignMode, srect: Rect, orect: Rect, offset: i64) -> Self
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.
Creates a new shape at the aligned location of the original.
Object Safety§
This trait is not object safe.