Created
September 4, 2017 06:27
-
-
Save lvnam96/d341d3885244c285efc7590b7d9c107b to your computer and use it in GitHub Desktop.
Generate random dark HSL color (CSS) in JavaScript
This file contains 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
const getRandomColor = () => { | |
const h = Math.floor(Math.random() * 360), | |
s = Math.floor(Math.random() * 100) + '%', | |
l = Math.floor(Math.random() * 60) + '%';// max value of l is 100, but I set to 60 cause I want to generate dark colors | |
// (use for background with white/light font color) | |
return `hsl(${h},${s},${l})`; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment