Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- impl Color {
- // Constructor for HSL model
- pub fn from_hsl(h: u16, s: f64, l: f64) -> Color {
- if !Self::is_valid_hue(h) {
- panic!("Invalid Hue value {} in HSL model", h);
- }
- if !Self::is_valid_ratio(s) {
- panic!("Invalid Saturation value {} in HSL model", s);
- }
- if !Self::is_valid_ratio(l) {
- panic!("Invalid Lightness value {} in HSL model", l);
- }
- Color::HSL{ h: h, s: s, l: l }
- }
- }
- impl Color {
- fn is_valid_hue(n: u16) -> bool {
- n < 360
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement