Rotation

Trait Rotation 

Source
pub trait Rotation {
    // Required methods
    fn inverse(&self) -> Self;
    fn rotate_size(&self, size: Size) -> Size;
    fn rotate_point(&self, point: Point, bounds: Size) -> Point;
    fn rotate_rectangle(&self, rectangle: Rectangle, bounds: Size) -> Rectangle;
}

Required Methods§

Source

fn inverse(&self) -> Self

Returns the inverse rotation that reverses this rotation’s effect.

Source

fn rotate_size(&self, size: Size) -> Size

Rotates the given size according to this rotation type.

Source

fn rotate_point(&self, point: Point, bounds: Size) -> Point

Rotates a point according to this rotation type, within overall source bounds of the given size.

For example, if the given point is (1,2) from a 10x20 space, then Rotate::Degrees90 would return (17, 1) in a 20x10 space. bounds should be the source dimensions of 10x20.


let r = Rotate::Degrees90;
assert_eq!(r.rotate_point(Point::new(1, 2), Size::new(10, 20)), Point::new(17, 1));
Source

fn rotate_rectangle(&self, rectangle: Rectangle, bounds: Size) -> Rectangle

Rotates a rectangle according to this rotation type, within overall source bounds of the given size.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§