pub enum Rotation {
None,
CW90,
CW180,
CW270,
}Expand description
Viewport rotation in 90-degree increments (clockwise).
When applied, the entire UI is rendered rotated and all input coordinates (mouse, touch) are remapped. Application code sees a normal coordinate space — rotation is transparent.
Use cases: pinball cabinet displays, kiosks, embedded screens, industrial panels mounted in non-standard orientation.
Variants§
None
No rotation (0 degrees).
CW90
90 degrees clockwise.
CW180
180 degrees.
CW270
270 degrees clockwise (= 90 degrees counter-clockwise).
Implementations§
Source§impl Rotation
impl Rotation
Sourcepub fn swaps_axes(self) -> bool
pub fn swaps_axes(self) -> bool
true if width and height are swapped (90 or 270 degrees).
Sourcepub fn is_none(self) -> bool
pub fn is_none(self) -> bool
true if this is Self::None.
Sourcepub fn next_cw(self) -> Self
pub fn next_cw(self) -> Self
The next rotation, cycling clockwise: None → CW90 → CW180 → CW270 → None.
Handy for a “rotate 90°” button or keyboard shortcut.
Sourcepub fn transform_pos(self, pos: Pos2, physical_size: Vec2) -> Pos2
pub fn transform_pos(self, pos: Pos2, physical_size: Vec2) -> Pos2
Transform a point from physical screen space to logical UI space.
physical_size is the physical window size (before rotation).
Sourcepub fn inverse_transform_pos(self, pos: Pos2, logical_size: Vec2) -> Pos2
pub fn inverse_transform_pos(self, pos: Pos2, logical_size: Vec2) -> Pos2
Transform a point from logical UI space back to physical screen space.
Sourcepub fn transform_vec(self, vec: Vec2) -> Vec2
pub fn transform_vec(self, vec: Vec2) -> Vec2
Transform a delta/vector (no translation needed).
Sourcepub fn inverse_angle(self) -> f32
pub fn inverse_angle(self) -> f32
Clockwise angle (radians) of the logical→physical mapping.
This is the rotational part of Self::inverse_transform_pos, expressed as
the clockwise angle used by epaint’s per-shape angle fields
(egui::epaint::TextShape::angle, RectShape::angle,
EllipseShape::angle).
Note the sign: it is the opposite of the screen’s physical mounting
(e.g. a screen mounted 90° CW is compensated by rendering the UI at -90°),
matching the directional remapping in crate::CursorIconExt::rotate.
Sourcepub fn transform_screen_rect(self, physical_rect: Rect) -> Rect
pub fn transform_screen_rect(self, physical_rect: Rect) -> Rect
Logical screen rect after rotation. For 90/270, width and height are swapped.