Expand description
Two-dimension alignment, e.g. Align2::LEFT_TOP
.
Tuple Fields§
§0: [Align; 2]
Implementations§
source§impl Align2
impl Align2
pub const LEFT_BOTTOM: Align2 = _
pub const LEFT_CENTER: Align2 = _
pub const LEFT_TOP: Align2 = _
pub const CENTER_BOTTOM: Align2 = _
pub const CENTER_CENTER: Align2 = _
pub const CENTER_TOP: Align2 = _
pub const RIGHT_BOTTOM: Align2 = _
pub const RIGHT_CENTER: Align2 = _
pub const RIGHT_TOP: Align2 = _
source§impl Align2
impl Align2
sourcepub fn anchor_rect(self, rect: Rect) -> Rect
pub fn anchor_rect(self, rect: Rect) -> Rect
Used e.g. to anchor a piece of text to a part of the rectangle. Give a position within the rect, specified by the aligns
sourcepub fn align_size_within_rect(self, size: Vec2, frame: Rect) -> Rect
pub fn align_size_within_rect(self, size: Vec2, frame: Rect) -> Rect
e.g. center a size within a given frame
sourcepub fn pos_in_rect(self, frame: &Rect) -> Pos2
pub fn pos_in_rect(self, frame: &Rect) -> Pos2
Returns the point on the rect’s frame or in the center of a rect according to the alignments of this object.
(*)-----------+------(*)------+-----------(*)--> X
| | | |
| Min, Min | Center, Min | Max, Min |
| | | |
+------------+---------------+------------+
| | | |
(*)Min, Center|Center(*)Center|Max, Center(*)
| | | |
+------------+---------------+------------+
| | | |
| Min, Max | Center, Max | Max, Max |
| | | |
(*)-----------+------(*)------+-----------(*)
|
Y
Trait Implementations§
source§impl<'de> Deserialize<'de> for Align2
impl<'de> Deserialize<'de> for Align2
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