pub enum TextAlign {
ScreenAbsolute(i32, i32),
ScreenRelative(i32, i32),
Viewport(i32, i32),
Scene(Vec3, i32, i32),
}Expand description
Specifies how the position property of a TextRef is applied.
Variants§
ScreenAbsolute(i32, i32)
Positions the text relative to the bottom left corner of the screen, then anchors it with respect to its bounding box.
§Examples
TextAlign::Screen(0, 0): Anchors at the centerTextAlign::Screen(1, -1): Anchors at the upper left corner
ScreenRelative(i32, i32)
Positions the text relative to the center of the screen, then anchors it with respect to its bounding box.
§Examples
TextAlign::Screen(0, 0): Anchors at the centerTextAlign::Screen(1, -1): Anchors at the upper left corner
Viewport(i32, i32)
Anchors the text to the edges of the viewport (as set by
TextBuilder::set_viewport),
then positions it with respect to its bounding box.
§Examples
TextAlign::Viewport(0, 0): Anchors at the lower left corner of the viewportTextAlign::Viewport(1, 0): Anchors at the right edge of the viewport
Scene(Vec3, i32, i32)
Anchors the text to the projected position of the 3D point (as described by
TextBuilder::set_projection_view),
then positions it with respect to its bounding box.
§Examples
TextAlign::Scene(vec(0.0, 0.0, 0.0), 0, 0): Projects the scene’s origin then anchors at the center
Implementations§
Source§impl TextAlign
impl TextAlign
Sourcepub fn into_global_and_local_offset(
self,
world_to_screen: Mat4,
viewport: Vec2,
bounds: Vec2,
) -> Option<(Vec2, Vec2)>
pub fn into_global_and_local_offset( self, world_to_screen: Mat4, viewport: Vec2, bounds: Vec2, ) -> Option<(Vec2, Vec2)>
Calculates the global and local offets required to align a rectangle with the given bounds inside the specified viewport.
Important: This assumes that the rectangle’s lower left corner is at the coordinates
0, 0.