auto use preferred color format

This commit is contained in:
Anton-4 2022-04-26 19:00:41 +02:00
parent 3a0adb1c7e
commit 8875a9ee9c
No known key found for this signature in database
GPG key ID: C954D6E0F9C0ABFD
3 changed files with 24 additions and 15 deletions

View file

@ -1,4 +1,4 @@
use palette::{FromColor, Hsv, Srgb};
use palette::{FromColor, Hsv, LinSrgb, Srgb};
pub type RgbaTup = (f32, f32, f32, f32);
pub const WHITE: RgbaTup = (1.0, 1.0, 1.0, 1.0);
@ -12,11 +12,11 @@ pub fn from_hsb(hue: usize, saturation: usize, brightness: usize) -> RgbaTup {
}
pub fn from_hsba(hue: usize, saturation: usize, brightness: usize, alpha: f32) -> RgbaTup {
let rgb = Srgb::from_color(Hsv::new(
let rgb = LinSrgb::from(Srgb::from_color(Hsv::new(
hue as f32,
(saturation as f32) / 100.0,
(brightness as f32) / 100.0,
));
)));
(rgb.red, rgb.green, rgb.blue, alpha)
}