pub struct Color {
pub r: u8,
pub g: u8,
pub b: u8,
}Expand description
RGB Color representation
Fields§
§r: u8§g: u8§b: u8Implementations§
Source§impl Color
impl Color
Sourcepub fn from_hsv(h: f64, s: f64, v: f64) -> Self
pub fn from_hsv(h: f64, s: f64, v: f64) -> Self
Create a color from HSV values
§Arguments
h- Hue (0.0 - 360.0)s- Saturation (0.0 - 1.0)v- Value/Brightness (0.0 - 1.0)
Sourcepub fn from_hex(hex: &str) -> Result<Self>
pub fn from_hex(hex: &str) -> Result<Self>
Parse a hex color string into a Color
Supports the following formats:
#RGB(e.g.,#F0A)#RRGGBB(e.g.,#FF00AA)RGB(without #)RRGGBB(without #)
§Examples
use scala_chromatica::Color;
let color1 = Color::from_hex("#FF5733").unwrap();
assert_eq!(color1.r, 255);
assert_eq!(color1.g, 87);
assert_eq!(color1.b, 51);
let color2 = Color::from_hex("#F0A").unwrap();
assert_eq!(color2.r, 255);
assert_eq!(color2.g, 0);
assert_eq!(color2.b, 170);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Color
impl<'de> Deserialize<'de> for Color
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 Color
impl StructuralPartialEq for Color
Auto Trait Implementations§
impl Freeze for Color
impl RefUnwindSafe for Color
impl Send for Color
impl Sync for Color
impl Unpin for Color
impl UnsafeUnpin for Color
impl UnwindSafe for Color
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