if the required colors are few, the color difference is large, and the required colors are small, the color difference is small, as follows Figure:
At this time, the calculation of the gradient color of the same color system is used. The algorithm is as follows:
function getItemColors (colorLevel) { var colors= []; //default darkest color var red = 134,green = 108, blue = 184; //The lightest color is 239,239,239 For example: the lightest color red is 239, then the difference is 239-134=105 var maxRed = 105, maxGreen = 131, maxBlue = 55; var level = colorLevel; while(level--) { colors.push( 'rgb('+red +','+green+','+blue+')'); red += parseInt(maxRed/colorLevel); green += parseInt(maxGreen/colorLevel); blue += parseInt(maxBlue/colorLevel); } return colors; }
*&**&**&**&**&**&**&**&**&**&*Happy dividing line*&**&**&**&**&** &**&**&**&**&**&**&*
I'm getting married soon, happy