#color-space #rgb #color #hsl #graphics

hsv

A simple crate for converting values in HSV color space to RGB

2 releases

0.1.1 Apr 15, 2023
0.1.0 Apr 15, 2023

#608 in GUI

Download history 20/week @ 2024-11-13 25/week @ 2024-11-20 23/week @ 2024-11-27 43/week @ 2024-12-04 110/week @ 2024-12-11 55/week @ 2024-12-18 15/week @ 2024-12-25 28/week @ 2025-01-01 46/week @ 2025-01-08 109/week @ 2025-01-15 52/week @ 2025-01-22 64/week @ 2025-01-29 63/week @ 2025-02-05 70/week @ 2025-02-12 36/week @ 2025-02-19 84/week @ 2025-02-26

268 downloads per month

MIT license

9KB
150 lines

hsv

Codecov

Simple conversion of HSV color space to RGB

A simple function hsv_to_rgb to convert values in the HSV color space to RGB. I created this crate because I couldn't find an existing one that worked for me, and, when I asked chatGPT how to convert HSV to RGB in Rust, it pointed me to a crate called hsv that didn't exist. Now it does.

Instructions

  • One function hsv_to_rgb taking hue: f64, saturation: f64, value: f64 and returning u8, u8, u8
  • Panics if supplied values is not within allowed ranges: 0 - 360, 0 - 1, 0 - 1 respectively
  • May not be correct in some sense, but should be okay for simple use cases.
  • Based mostly on https://en.wikipedia.org/wiki/HSL_and_HSV#Color_conversion_formulae

Please let me know if it's incorrect. Bug reports and PRs welcome!

No runtime deps