Skip to content

Instantly share code, notes, and snippets.

@jasonsperske
Created November 20, 2017 05:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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