mirror of
https://github.com/arabianq/colorgram-rust.git
synced 2026-04-27 22:21:22 +00:00
impl Display for Rgb and Hsl
This commit is contained in:
+13
-1
@@ -6,12 +6,24 @@ pub struct Hsl {
|
||||
pub l: u8,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Hsl {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "hsl({}, {}, {})", self.h, self.s, self.l)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Rgb {
|
||||
pub r: u8,
|
||||
pub g: u8,
|
||||
pub b: u8,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Rgb {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "rgb({}, {}, {})", self.r, self.g, self.b)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Color {
|
||||
pub rgb: Rgb,
|
||||
pub hsl: Hsl,
|
||||
@@ -19,7 +31,7 @@ pub struct Color {
|
||||
}
|
||||
|
||||
impl Color {
|
||||
fn new(rgb: Rgb, proportion: f32) -> Color {
|
||||
pub fn new(rgb: Rgb, proportion: f32) -> Color {
|
||||
let hsl = rgb_to_hsl(&rgb);
|
||||
Color {
|
||||
rgb,
|
||||
|
||||
Reference in New Issue
Block a user