Created
December 6, 2021 16:49
-
-
Save w3core/ecb628b13dc681743f625ecbb3ffa8bf to your computer and use it in GitHub Desktop.
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 makeColorPreset = (amount) => { | |
const steps = [0, 180, 60, 240, 120, 300] | |
const diameter = 360 | |
const lightness = 50 | |
const saturation = 100 | |
const size = diameter / amount | |
let round = -1 | |
const colors = Array(amount).fill().map((value, count) => { | |
const key = count % steps.length | |
if (!key) round++ | |
const hue = steps[key] + round * size | |
return `hsl(${Math.floor(hue)}, ${saturation}%, ${lightness}%)` | |
}) | |
console.log(colors) | |
return colors | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
makeColorPreset(24)
:makeColorPreset(60)
: