pub struct ColorRGB {
pub red: u8,
pub green: u8,
pub blue: u8,
}
Expand description
RGB value
- stores a color in RGB space
- default color is black
[0,0,0]
Fields§
§red: u8
The red part
green: u8
The green part
blue: u8
The blue part
Implementations§
source§impl ColorRGB
impl ColorRGB
sourcepub fn new_from_array(color: &[u8; 3]) -> Self
pub fn new_from_array(color: &[u8; 3]) -> Self
Create color from an array
color[0]
-> redcolor[1]
-> greencolor[2]
-> blue
sourcepub fn to_array(&self) -> [u8; 3]
pub fn to_array(&self) -> [u8; 3]
convert color to array,
will return [red, green, blue]
sourcepub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
Turn into hex representation
use sampling::heatmap::ColorRGB;
let color = ColorRGB::new(0,0,0);
let hex = color.to_hex();
assert_eq!(&hex, "#000000");
let color = ColorRGB::new_from_array(&[255,255,255]);
let hex = color.to_hex();
assert_eq!(&hex, "#FFFFFF");
Trait Implementations§
source§impl<'de> Deserialize<'de> for ColorRGB
impl<'de> Deserialize<'de> for ColorRGB
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for ColorRGB
Auto Trait Implementations§
impl RefUnwindSafe for ColorRGB
impl Send for ColorRGB
impl Sync for ColorRGB
impl Unpin for ColorRGB
impl UnwindSafe for ColorRGB
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<S, T> Cast<T> for Swhere
T: Conv<S>,
impl<S, T> Cast<T> for Swhere
T: Conv<S>,
§impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
impl<S, T> CastApprox<T> for Swhere
T: ConvApprox<S>,
§fn try_cast_approx(self) -> Result<T, Error>
fn try_cast_approx(self) -> Result<T, Error>
§fn cast_approx(self) -> T
fn cast_approx(self) -> T
§impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
impl<S, T> CastFloat<T> for Swhere
T: ConvFloat<S>,
§fn cast_trunc(self) -> T
fn cast_trunc(self) -> T
Cast to integer, truncating Read more
§fn cast_nearest(self) -> T
fn cast_nearest(self) -> T
Cast to the nearest integer Read more
§fn cast_floor(self) -> T
fn cast_floor(self) -> T
Cast the floor to an integer Read more
§fn try_cast_trunc(self) -> Result<T, Error>
fn try_cast_trunc(self) -> Result<T, Error>
Try converting to integer with truncation Read more
§fn try_cast_nearest(self) -> Result<T, Error>
fn try_cast_nearest(self) -> Result<T, Error>
Try converting to the nearest integer Read more
§fn try_cast_floor(self) -> Result<T, Error>
fn try_cast_floor(self) -> Result<T, Error>
Try converting the floor to an integer Read more
§fn try_cast_ceil(self) -> Result<T, Error>
fn try_cast_ceil(self) -> Result<T, Error>
Try convert the ceiling to an integer Read more