Skip to content

Instantly share code, notes, and snippets.

@emmettna
Created August 29, 2018 05:48
Show Gist options
  • Save emmettna/309b718655e5d13779fd0f603228e5da to your computer and use it in GitHub Desktop.
Save emmettna/309b718655e5d13779fd0f603228e5da to your computer and use it in GitHub Desktop.
function getColorSets(){
const numberRange = [...Array( 14).keys()].map( x => x * 20) // [0,20..260]
const addZero = function( val){ return ( val.length < 2) ? "0" + val : val; }
const defaultColors = ["f44336","E91E63","9C27B0","673AB7","3F51B5","2196F3","03A9F4","00BCD4","009688",
"4CAF50","8BC34A","CDDC39","FFEB3B","FFC107","FF9800","FF5722","795548","9E9E9E","607D8B"]
const flattenList = function( unFlattenedList){ [].concat.apply([], unFlattenedList) }
const generateSet = function( colors, n) {
return colors.map( x => [[x.slice(0,2)],[x.slice(2,4)],[x.slice(4,6)]]) // slice RGB
.map(x => x.map( d => addZero( ( ( parseInt( d, 16) + n) % 255).toString( 16))))
.map( x => x.join( ""))
.map( x => "#"+x)
}
return flattenList( numberRange.map( x => generateSet( defaultColors, x)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment