embedded_graphics_coordinate_transform/
lib.rs

1//! Embedded-graphics-coordinate-transform is a helper library for rotating, mirroring and
2//! transposing embedded-graphics displays.
3//!
4//! This library provides a single generic implementation of a coordinate transformation wrapper
5//! [`CoordinateTransform`]. However, in most cases you will want to specifically rotate, mirror or
6//! transpose the display, so a number of helper types are provided.
7//!
8//! - [`MirrorX`]: Mirror pixels along the x-axis.
9//! - [`MirrorY`]: Mirror pixels along the y-axis.
10//! - [`MirrorXY`]: Mirror pixels along both axes.
11//! - [`TransposeXY`]: Transpose the x and y axes.
12//! - [`Rotate0`]: Rotate the display by 0 degrees.
13//! - [`Rotate90`]: Rotate the display by 90 degrees.
14//! - [`Rotate180`]: Rotate the display by 180 degrees.
15//! - [`Rotate270`]: Rotate the display by 270 degrees.
16//!
17//! ![A grid of displays with different coordinate transforms applied.](https://raw.githubusercontent.com/msvisser/embedded-graphics-coordinate-transform/main/assets/overview.png)
18
19#[cfg(test)]
20mod tests;
21mod transform;
22
23pub use crate::transform::CoordinateTransform;
24
25/// A coordinate transform that mirrors pixels along the x-axis of the display.
26pub type MirrorX<T> = CoordinateTransform<T, true, false, false>;
27
28/// A coordinate transform that mirrors pixels along the y-axis of the display.
29pub type MirrorY<T> = CoordinateTransform<T, false, true, false>;
30
31/// A coordinate transform that mirrors pixels along both the x and y axes of the display.
32pub type MirrorXY<T> = CoordinateTransform<T, true, true, false>;
33
34/// A coordinate transform that transposes the x and y axes of the display.
35pub type TransposeXY<T> = CoordinateTransform<T, false, false, true>;
36
37/// A coordinate transform that rotates the display by 0 degrees.
38pub type Rotate0<T> = CoordinateTransform<T, false, false, false>;
39
40/// A coordinate transform that rotates the display by 90 degrees.
41pub type Rotate90<T> = CoordinateTransform<T, true, false, true>;
42
43/// A coordinate transform that rotates the display by 180 degrees.
44pub type Rotate180<T> = CoordinateTransform<T, true, true, false>;
45
46/// A coordinate transform that rotates the display by 270 degrees.
47pub type Rotate270<T> = CoordinateTransform<T, false, true, true>;