The colorsys.hsv_to_rgb(r, g, b)
function converts HSV (Hue Saturation Value) coordinates to RGB (Red Green Blue) coordinates.
The colorsys
module stores the definition of the hsv_to_rgb()
function. The colorsys
module can be imported using the following code:
import colorsys
colorsys.hsv_to_rgb(h, s, v)
h
, s
, and v
can have any value between 0 and 1 inclusive.
The following code snippet demonstrates the use of hsv_to_rgb()
:
import colorsys if __name__ == '__main__': h = 0.32 s = 0.76 v = 0.29 r, g, b = colorsys.hsv_to_rgb(h, s, v) print('HSV:-') print('h: ' + str(h) + '\ns: ' + str(s) + '\nv: ' + str(v)) print('\nRGB:-') print('r: ' + str(r) + '\ng: ' + str(g) + '\nb: ' + str(b))
RELATED TAGS
CONTRIBUTOR
View all Courses