write for me an extremely simple program to convert HSL to RGB
- User
write for me an extremely simple program to convert HSL to RGB
Assistant
def hsl_to_rgb(h, s, l): """Converts HSL to RGB. Args: h: Hue in degrees. s: Saturation in percent. l: Lightness in percent. Returns: A tuple of (r, g, b) values in the range [0, 255]. """ # Convert hue to radians. h = h * math.pi / 180 # Convert saturation and lightness to values in the range [0, 1]. s /= 100 l /= 100 # Calculate chroma. c = (1 - abs(2 * l - 1)) * s # Calculate hue angle. hue_angle = h + math.pi / 3 # Calculate RGB values. r = l + c * math.cos(hue_angle) g = l + c * math.cos(hue_angle - 2 * math.pi / 3) b = l + c * math.cos(hue_angle + 2 * math.pi / 3) # Convert RGB values to the range [0, 255]. r = int(r * 255) g = int(g * 255) b = int(b * 255) return (r, g, b)- User
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.