pub struct HslColor {
pub h: f64,
pub s: f64,
pub l: f64,
}Expand description
A color representation in HSL (Hue, Saturation, Lightness) color space.
Fields§
§h: f64Hue component [0-360]
s: f64Saturation component [0-100]
l: f64Lightness component [0-100]
Implementations§
Source§impl HslColor
impl HslColor
Sourcepub fn new(h: f64, s: f64, l: f64) -> Self
pub fn new(h: f64, s: f64, l: f64) -> Self
Creates a new HslColor from HSL components.
§Arguments
h- Hue [0-360]s- Saturation [0-100]l- Lightness [0-100]
§Examples
Initialize a pure red color:
use pixel_loop::color::HslColor;
let color = HslColor::new(0.0, 100.0, 50.0); // Pure redConvert from RGB to HSL:
use pixel_loop::color::{Color, HslColor};
let rgb = Color::from_rgb(255, 0, 0);
let hsl = rgb.as_hsl();
assert_eq!(hsl.h, 0.0); // Red has hue 0
assert_eq!(hsl.s, 100.0); // Full saturation
assert_eq!(hsl.l, 50.0); // Mid lightnessConvert from HSL to RGB:
use pixel_loop::color::{Color, HslColor};
let hsl = HslColor::new(0.0, 100.0, 50.0);
let rgb = Color::from(hsl);
assert_eq!(rgb, Color::from_rgb(255, 0, 0)); // Pure redTrait Implementations§
Auto Trait Implementations§
impl Freeze for HslColor
impl RefUnwindSafe for HslColor
impl Send for HslColor
impl Sync for HslColor
impl Unpin for HslColor
impl UnwindSafe for HslColor
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