# # Convert a color in the HSV color space to the RGB color space. # # Parameters: # h: The hue of the color (between 0 and 360) # s: The saturation of the color (between 0 and 1) # v: The value of the color (between 0 and 1) # # Returns: # A tuple containing the red, green and blue components for the HSV color # provided. The red, green and blue values range between 0 and 256. # def hsv_to_rgb(h, s, v): h /= 360.0 hi = int(h * 6) f = h * 6 - hi p = v * (1 - s) q = v * (1 - f * s) t = v * (1 - (1 - f) * s) if hi == 0: return v * 256, t * 256, p * 256 elif hi == 1: return q * 256, v * 256, p * 256 elif hi == 2: return p * 256, v * 256, t * 256 elif hi == 3: return p * 256, q * 256, v * 256 elif hi == 4: return t * 256, p * 256, v * 256 else: return v * 256, p * 256, q * 256