Skip to content

Instantly share code, notes, and snippets.

@jasonsperske
Created November 20, 2017 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonsperske/bd8d024e542d4ef005018d12fa3a1374 to your computer and use it in GitHub Desktop.
Save jasonsperske/bd8d024e542d4ef005018d12fa3a1374 to your computer and use it in GitHub Desktop.
HueSegments
//An example of this can be seen at https://jsfiddle.net/uLzwv8mx/
function HueSegments(steps) {
var segments = []
var step
var increment = 200/steps
for(step = 0; step < steps; step++) {
segments.push("hsla("+(Math.floor(increment*step))+", 100%, "+(step % 2 == 0 ? "75" : "50")+"%, 1)")
}
return segments
}
//Demo using jQuery
var out = $('#Output')
HueSegments(10).forEach(function(color) {
out.append($('<li>').css({backgroundColor: color}))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment