Created
September 26, 2017 11:47
-
-
Save slonoed/997aca4fd74868337137cfe42b29efed to your computer and use it in GitHub Desktop.
Make nice colors
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
// Return "infinite" sequence of HSL colors | |
function* colorMaker({distance = 1, saturation, luminosity, shift = 0}) { | |
let colorIndex = 0 | |
while (true) { | |
const hue = (colorIndex * distance + shift) % 359 | |
yield `hsl(${hue}, ${saturation}%, ${luminosity}%)` | |
colorIndex++ | |
} | |
} | |
// usage | |
const color = colorMaker({distance: 40, saturation: 65, luminosity: 68}) | |
color().next().value // -> color value for component |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment