The requirement is as follows:
We need to map values to colors. So each discrete value will have a color.
We allow the user to specify a maxColor
but NO minColor
but allow them to specify the number of bins representing the number of shades. So if the maxColor
selected is Color.GREEN
and the bins= 5
,then we would like to have 5 shades of green with the color selected as max being the darkest and the rest four will be in order of increasing lightness.
//Give me a list of 5 shades of Green with the first argument being the darkest.
List<Color> greenShades = calculateShades(Color.GREEN,5);
//Give me a list of 7 shades of RED with the first argument being the darkest.
List<Color> greenShades = calculateShades(Color.RED,7);
I tagged the question as Java as I am coding in Java. But I understand it is just an algorithm.So implementation/idea of this implementation in other languages like JavaScript will also be acceptable.
The basic concept revolves around the idea of generating a color based on a fraction of the source...
That is, if you want 5 bands, each band will 1/5 the intensity of the last...
As a quick and nasty example...