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#![no_std]
19
20#[cfg(test)]
21mod tests;
22mod transform;
23
24pub use crate::transform::CoordinateTransform;
25
26/// A coordinate transform that mirrors pixels along the x-axis of the display.
27pub type MirrorX<T> = CoordinateTransform<T, true, false, false>;
28
29/// A coordinate transform that mirrors pixels along the y-axis of the display.
30pub type MirrorY<T> = CoordinateTransform<T, false, true, false>;
31
32/// A coordinate transform that mirrors pixels along both the x and y axes of the display.
33pub type MirrorXY<T> = CoordinateTransform<T, true, true, false>;
34
35/// A coordinate transform that transposes the x and y axes of the display.
36pub type TransposeXY<T> = CoordinateTransform<T, false, false, true>;
37
38/// A coordinate transform that rotates the display by 0 degrees.
39pub type Rotate0<T> = CoordinateTransform<T, false, false, false>;
40
41/// A coordinate transform that rotates the display by 90 degrees.
42pub type Rotate90<T> = CoordinateTransform<T, true, false, true>;
43
44/// A coordinate transform that rotates the display by 180 degrees.
45pub type Rotate180<T> = CoordinateTransform<T, true, true, false>;
46
47/// A coordinate transform that rotates the display by 270 degrees.
48pub type Rotate270<T> = CoordinateTransform<T, false, true, true>;