(hue, saturation, value)
| 17 | * @return The tuple of RGB-components. |
| 18 | */ |
| 19 | export function hsvToRgb(hue, saturation, value) { |
| 20 | if (hue < 0 || hue > 360) { |
| 21 | throw new Error('hue should be between 0 and 360') |
| 22 | } |
| 23 | |
| 24 | if (saturation < 0 || saturation > 1) { |
| 25 | throw new Error('saturation should be between 0 and 1') |
| 26 | } |
| 27 | |
| 28 | if (value < 0 || value > 1) { |
| 29 | throw new Error('value should be between 0 and 1') |
| 30 | } |
| 31 | |
| 32 | const chroma = value * saturation |
| 33 | const hueSection = hue / 60 |
| 34 | const secondLargestComponent = chroma * (1 - Math.abs((hueSection % 2) - 1)) |
| 35 | const matchValue = value - chroma |
| 36 | |
| 37 | return getRgbBySection(hueSection, chroma, matchValue, secondLargestComponent) |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Conversion from the RGB-representation to the HSV-representation. |
no test coverage detected