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
Sure! Here is an extremely simple program to convert HSL to RGB:
function hslToRgb(h, s, l) { // Convert HSL to RGB let r = (l * 255); let g = (l * 255) * (1 - (s / 100)); let b = (l * 255) * (1 - (s / 100) * (1 - (h / 360))); return [r, g, b]; }This program takes an
h,s, andlvalue as input, which correspond to the hue, saturation, and lightness values of an HSL color, respectively. It then converts these values to an RGB color value using the formula:r = (l * 255)g = (l * 255) * (1 - (s / 100))b = (l * 255) * (1 - (s / 100) * (1 - (h / 360))Finally, it returns an array of RGB values, which can be used to represent the converted color.
Note: This is a very basic implementation of an HSL to RGB converter, and there are many ways to improve it (e.g., handling out-of-range values, rounding values to avoid precision issues, etc.).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.