Struct sensehat_screen::color::PixelColor
[−]
[src]
pub struct PixelColor { pub red: u8, pub green: u8, pub blue: u8, }
A single LED pixel color, with RGB565 rendering.
// FROM // convert directly from 3-bytes in a tuple let red: PixelColor = (0xFF, 0, 0).into(); assert_eq!(red, PixelColor::RED); let green: PixelColor = (0, 0xFF, 0).into(); assert_eq!(green, PixelColor::GREEN); // convert directly from Rgb565 let blue_rgb565 = Rgb565::from_rgb(0, 0, 0xFF); let blue: PixelColor = blue_rgb565.into(); assert_eq!(blue, PixelColor::new(0, 0, 0xF8)); // INTO // convert directly into a 3-bytes tuple let red_tuple: (u8, u8, u8) = PixelColor::RED.into(); assert_eq!(red_tuple, (0xFF, 0, 0)); let yellow_tuple: (u8, u8, u8) = PixelColor::YELLOW.into(); assert_eq!(yellow_tuple, (0xFF, 0xFF, 0)); // convert directly into Rgb565 let blue_565: Rgb565 = PixelColor::BLUE.into(); assert_eq!(blue_565, Rgb565::from_rgb(0, 0, 0xF8));
Fields
red: u8
green: u8
blue: u8
Methods
impl PixelColor
[src]
pub const BLACK: PixelColor
BLACK: PixelColor = PixelColor{red: 0, green: 0, blue: 0,}
pub const RED: PixelColor
RED: PixelColor = PixelColor{red: 255, green: 0, blue: 0,}
pub const BLUE: PixelColor
BLUE: PixelColor = PixelColor{red: 0, green: 0, blue: 255,}
pub const GREEN: PixelColor
GREEN: PixelColor = PixelColor{red: 0, green: 255, blue: 0,}
pub const WHITE: PixelColor
WHITE: PixelColor = PixelColor{red: 255, green: 255, blue: 255,}
pub const YELLOW: PixelColor
YELLOW: PixelColor = PixelColor{red: 255, green: 255, blue: 0,}
pub const CYAN: PixelColor
CYAN: PixelColor = PixelColor{red: 0, green: 255, blue: 255,}
pub const MAGENTA: PixelColor
MAGENTA: PixelColor = PixelColor{red: 255, green: 0, blue: 255,}
pub fn new(red: u8, green: u8, blue: u8) -> Self
[src]
Create a new LED pixel color.
pub fn from_rgb565(color: [u8; 2]) -> Self
[src]
Create a new LED pixel color from a pair of RGB565-encoded bytes.
pub fn rgb565(&self) -> [u8; 2]
[src]
Encodes the current LED pixel color into a pair of RGB565-encoded bytes.
pub fn dim(self, scale: f32) -> PixelColor
[src]
Sets the brightness of this colour.
The scale
value should be between 0 and 1. Values outside this range
are clamped.
Trait Implementations
impl Copy for PixelColor
[src]
impl Clone for PixelColor
[src]
fn clone(&self) -> PixelColor
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for PixelColor
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Default for PixelColor
[src]
fn default() -> PixelColor
[src]
Returns the "default value" for a type. Read more
impl PartialEq for PixelColor
[src]
fn eq(&self, __arg_0: &PixelColor) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &PixelColor) -> bool
[src]
This method tests for !=
.
impl From<Rgb565> for PixelColor
[src]
impl From<(u8, u8, u8)> for PixelColor
[src]
impl Into<(u8, u8, u8)> for PixelColor
[src]
impl From<PixelColor> for Rgb565
[src]
fn from(color: PixelColor) -> Self
[src]
Performs the conversion.
impl<'a> From<&'a PixelColor> for Rgb565
[src]
fn from(color: &'a PixelColor) -> Self
[src]
Performs the conversion.