pub struct Alignment {
pub x: f32,
pub y: f32,
}Expand description
Where to place a child inside its containing box: two continuous fractions
in [-1, 1]. x = -1 hugs the left, 0 centres, +1 hugs the right; y = -1
is the top, +1 the bottom. Being continuous, it interpolates
(crate::Lerp): a Tween<Alignment> slides a child from one anchor to
another. The nine usual anchors are provided as constants
(Alignment::CENTER, Alignment::TOP_LEFT, and so on).
Fields§
§x: f32Horizontal fraction: -1 (left) … 0 (centre) … +1 (right).
y: f32Vertical fraction: -1 (top) … 0 (centre) … +1 (bottom).
Implementations§
Source§impl Alignment
impl Alignment
Sourcepub const TOP_CENTER: Self
pub const TOP_CENTER: Self
Hugs the top edge, centred horizontally.
Sourcepub const CENTER_LEFT: Self
pub const CENTER_LEFT: Self
Hugs the left edge, centred vertically.
Sourcepub const CENTER_RIGHT: Self
pub const CENTER_RIGHT: Self
Hugs the right edge, centred vertically.
Sourcepub const BOTTOM_LEFT: Self
pub const BOTTOM_LEFT: Self
Hugs the bottom-left corner.
Sourcepub const BOTTOM_CENTER: Self
pub const BOTTOM_CENTER: Self
Hugs the bottom edge, centred horizontally.
Sourcepub const BOTTOM_RIGHT: Self
pub const BOTTOM_RIGHT: Self
Hugs the bottom-right corner.
Sourcepub fn fraction_x(self) -> f32
pub fn fraction_x(self) -> f32
The horizontal fraction mapped into [0, 1] (0 = left, 1 = right): the
share of the free space to leave before the child on the x axis.
Sourcepub fn fraction_y(self) -> f32
pub fn fraction_y(self) -> f32
The vertical fraction mapped into [0, 1] (0 = top, 1 = bottom).