Function macroquad::color::hsl_to_rgb

source ยท
pub fn hsl_to_rgb(h: f32, s: f32, l: f32) -> Color
Examples found in repository?
examples/shadertoy.rs (line 39)
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
fn color_picker_texture(w: usize, h: usize) -> (Texture2D, Image) {
    let ratio = 1.0 / h as f32;

    let mut image = Image::gen_image_color(w as u16, h as u16, WHITE);
    let image_data = image.get_image_data_mut();

    for j in 0..h {
        for i in 0..w {
            let lightness = 1.0 - i as f32 * ratio;
            let hue = j as f32 * ratio;

            image_data[i + j * w] = color::hsl_to_rgb(hue, 1.0, lightness).into();
        }
    }

    (Texture2D::from_image(&image), image)
}