Create a gist now

Instantly share code, notes, and snippets.

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