Skip to content

Instantly share code, notes, and snippets.

@w3core
Created December 6, 2021 16:49
Show Gist options
  • Save w3core/ecb628b13dc681743f625ecbb3ffa8bf to your computer and use it in GitHub Desktop.
Save w3core/ecb628b13dc681743f625ecbb3ffa8bf to your computer and use it in GitHub Desktop.
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
}
@w3core
Copy link
Author

w3core commented Dec 6, 2021

makeColorPreset(24):
image

makeColorPreset(60):
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment