1919/// assert_eq!(red.r, 255);
2020/// assert_eq!(red.g, 128);
2121/// assert_eq!(red.b, 0);
22- /// assert_eq!(red.a, 0xff);
23- ///
24- /// let from_struct_literal = Pixel { r: 255, g: 0x80, b: 0, a: 0xff };
25- /// assert_eq!(red, from_struct_literal);
22+ /// # // assert_eq!(red.a, 0xff);
23+ /// #
24+ /// # // let from_struct_literal = Pixel { r: 255, g: 0x80, b: 0, a: 0xff };
25+ /// # // assert_eq!(red, from_struct_literal);
2626/// ```
2727///
2828/// Convert a pixel to an array of `u8`s.
4848/// let red = unsafe { core::mem::transmute::<Pixel, u32>(red) };
4949///
5050/// // BGRX
51- /// assert_eq!(red, u32::from_le_bytes([0x00, 0x00, 0xff, 0xff ]));
51+ /// assert_eq!(red, u32::from_le_bytes([0x00, 0x00, 0xff, 0x00 ]));
5252/// ```
5353#[ repr( C ) ]
5454#[ repr( align( 4 ) ) ] // Help the compiler to see that this is a u32
@@ -65,18 +65,15 @@ pub struct Pixel {
6565 ///
6666 /// `0xff` here means opaque, whereas `0` means transparent.
6767 ///
68- /// NOTE: Transparency is yet poorly supported, see [#17], until that is resolved, you will
69- /// probably want to set this to `0xff`.
68+ /// NOTE: Transparency is not yet supported, see [#17], so this doesn't actually do anything.
7069 ///
7170 /// [#17]: https://github.com/rust-windowing/softbuffer/issues/17
72- pub a : u8 ,
71+ pub ( crate ) a : u8 ,
7372}
7473
7574impl Pixel {
7675 /// Create a new pixel from a red, a green and a blue component.
7776 ///
78- /// The alpha component is set to opaque.
79- ///
8077 /// # Example
8178 ///
8279 /// ```
@@ -86,13 +83,12 @@ impl Pixel {
8683 /// assert_eq!(red.r, 255);
8784 /// ```
8885 pub const fn new_rgb ( r : u8 , g : u8 , b : u8 ) -> Self {
89- Self { r, g, b, a : 0xff }
86+ // FIXME(madsmtm): Change alpha to `0xff` once we support transparency.
87+ Self { r, g, b, a : 0x00 }
9088 }
9189
9290 /// Create a new pixel from a blue, a green and a red component.
9391 ///
94- /// The alpha component is set to opaque.
95- ///
9692 /// # Example
9793 ///
9894 /// ```
@@ -102,7 +98,8 @@ impl Pixel {
10298 /// assert_eq!(red.r, 255);
10399 /// ```
104100 pub const fn new_bgr ( b : u8 , g : u8 , r : u8 ) -> Self {
105- Self { r, g, b, a : 0xff }
101+ // FIXME(madsmtm): Change alpha to `0xff` once we support transparency.
102+ Self { r, g, b, a : 0x00 }
106103 }
107104
108105 // TODO(madsmtm): Once we have transparency, add `new_rgba` and `new_bgra` methods.
0 commit comments