-
I am trying to port some code from 0.5 to 0.6. I am having trouble reasoning my way through the usage of let h: f64 = 1.0;
let hue = RgbHue::from_radians(h);
let hsv = palette::Hsv<palette::encoding::Srgb, f64>::new(hue, *self.s, 1.);
let rgb: palette::LinSrgb<f64> = hsv.into_rgb();
let (r, g, b) = rgb.into_components();
Rgb::from_floats(r, g, b) I understand that
Are there restrictions on converting between certain encodings? I'm not intimate with this code, nor how color encoding works in general. I'm just trying to maintain functionality of the code, but with 0.6. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi! You are definitely on the right track, and you are right that the new system doesn't allow converting both color space and encoding in one go. You will have to convert to |
Beta Was this translation helpful? Give feedback.
Hi! You are definitely on the right track, and you are right that the new system doesn't allow converting both color space and encoding in one go. You will have to convert to
Srgb
first, so something likeSrgb::<f64>::from_color(hsv).into_linear()
should do the trick. The reason why this restriction is in place is that removing it makes type inference fail a lot more. I chose to keep it more conservative for now, at the cost of having this blind spot.