all Python 3colorsysfunction
colorsys.hsv_to_rgb()
HSV
Converts a colour from HSV to RGB; input and output are fractions from 0 to 1. Handy for generating a palette with an even hue step.
Syntax
r, g, b = colorsys.hsv_to_rgb(h, s, v)
The result is fractions, not bytes: for #RRGGBB multiply by 255 and use round(), not int(), or 0.9999… becomes 254. Types are not normalised: integer inputs may stay integers in the output — hsv_to_rgb(0.5, 1, 1) gives (0.0, 1.0, 1).
Examples
import colorsys
print(colorsys.hsv_to_rgb(0.5, 1, 1)) # → (0.0, 1.0, 1)
rgb = [round(c * 255) for c in colorsys.hsv_to_rgb(0.6, 0.5, 0.8)]
print('#%02x%02x%02x' % tuple(rgb)) # → #668fcc
See also
Open in the full glossarydocs.python.orgReport an inaccuracy