hueShiftedColorSet
Generate color sets by walking around the color wheel at a constant saturation/value.
by khrome
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/mootools/1.4.5/mootools-core-full-compat.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mootools-more/1.4.0.1/mootools-more-yui-compressed.js"></script>
JavaScript
function hueShiftedColorSet(){
var args = {};
var arg;
for(var lcv=0; lcv < arguments.length; lcv++){
arg = arguments[lcv];
if(typeOf(arg) == 'number') args.num = arg;
else if(
typeOf(arg) == 'array' ||
(typeOf(arg) == 'string' && arg.match(/#?[0-9A-F]{6}/))
) args.color = arg;
else if(typeOf(arg) == 'string') args.result = arg;
};
if(!args.num) args.num = 5;
if(!args.color) args.color = '#FF0000';
var result = [];
for(var lcv=0;lcv<args.num;lcv++){
var newColor = new Color(args.color);
var newColor = (newColor).setHue((newColor.hsb[0]+(359/args.num)*lcv)%359);
if(args.result)result.push(newColor[args.result]);
else result.push(newColor);
}
return result;
}
document.writeln(hueShiftedColorSet('#0000FF', 2));
document.writeln('<br/>');
document.writeln(hueShiftedColorSet(2));
document.writeln('<br/>');
document.writeln(hueShiftedColorSet('hex', 3, '#999900'));
document.writeln('<br/>');
document.writeln(hueShiftedColorSet(3, 'hsb'));