Created
February 17, 2022 16:28
-
-
Save iMoses/516245b9f9571f5731993e864ed79795 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function stringToHsl( | |
str, | |
{ saturation = 50, lightness = 50, range: [minHue, maxHue] = [0, 360] } = {} | |
) { | |
const hash = str.split('').reduce((hash, char) => char.charCodeAt(0) + ((hash << 5) - hash), 0); | |
return `hsl(${(Math.abs(hash) % (maxHue - minHue)) + minHue}, ${saturation}%, ${lightness}%)`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment