| 1 | #[repr (C)] |
| 2 | #[cfg_attr (feature = "serde" , derive(serde::Serialize, serde::Deserialize))] |
| 3 | #[cfg_attr (feature = "defmt-03" , derive(defmt::Format))] |
| 4 | #[derive (Copy, Clone, Debug, Default, Eq, PartialEq, Ord, PartialOrd, Hash)] |
| 5 | /// A `Value (brightness) + Alpha` pixel (rgb crate v0.9) |
| 6 | /// |
| 7 | /// This pixel is commonly used for grayscale images. |
| 8 | pub struct GrayA<T, A = T> { |
| 9 | /// Value - the brightness component. May be luma or luminance. |
| 10 | pub v: T, |
| 11 | /// Alpha Component |
| 12 | pub a: A, |
| 13 | } |
| 14 | |
| 15 | impl<T: Copy> GrayA<T> { |
| 16 | /// Reads the `.v` field |
| 17 | /// |
| 18 | /// This function isn't necessary, but it is forwards-compatible with the next major version of the RGB crate. |
| 19 | pub fn value(self) -> T { |
| 20 | self.v |
| 21 | } |
| 22 | |
| 23 | /// Exposes the `.v` field for writing |
| 24 | /// |
| 25 | /// This function isn't necessary, but it is forwards-compatible with the next major version of the RGB crate. |
| 26 | pub fn value_mut(&mut self) -> &mut T { |
| 27 | &mut self.v |
| 28 | } |
| 29 | } |
| 30 | |