_hslToHex.js.flow 545 B

123456789101112131415161718
  1. // @flow
  2. import hslToRgb from './_hslToRgb'
  3. import reduceHexValue from './_reduceHexValue'
  4. import toHex from './_numberToHex'
  5. function colorToHex(color: number): string {
  6. return toHex(Math.round(color * 255))
  7. }
  8. function convertToHex(red: number, green: number, blue: number): string {
  9. return reduceHexValue(`#${colorToHex(red)}${colorToHex(green)}${colorToHex(blue)}`)
  10. }
  11. function hslToHex(hue: number, saturation: number, lightness: number): string {
  12. return hslToRgb(hue, saturation, lightness, convertToHex)
  13. }
  14. export default hslToHex