java - How to dynamically compute a list of colors? -


To represent a list of objects with different colors in the GWT-widget, we dynamically create a list of colors There is a need to obtain as the size of the list can be different, with so many different colors in the form of objects, so we should be able to calculate such a list of colors.

Another version of my solution with category:

  list & Lt; Int & gt; GetUniqueColors (int amount) {last full less limit = 0x10; Last full upper limit = 0xE0; Last int color phase = (upper limit - lower limit) / Matho Po (amount, 1f / 3); Last list & lt; Int & gt; Color = new ArrayList & lt; Int & gt; (Quantity); For (Int b = lower limit, B & lt; to the upper limit, B + = color phase) (if Int + R = lower limit, R & lt; upper limit; R = Rngstep) (Int g = lower limit, G & lt; upper limit G + (Colors.size () & gt; = amount) {// calculate step is not very accurate, so it is securable return color;} other {Int color = ( R & lt; & lt; 16) + (G & lt; & lt; 8) + (B); colors.add (color);}} return color;}  

this Another advance is because of those colors Which are different from each other as much as possible (as did @eiob).

Normally we split the boundary for the three sub-colors of red green and blue, calculate that we need to take much action to iterate over each of them (by a PA (range, 1 F / 3) application and repeated them.

for example, the number given 3 Have it, generate 0x0000B1, 0x00B100, 0x00B1B1 Ga. The number will be to 10: 0x000076, 0x0000EC, 0x007600, 0x007676, 0x0076EC, 0x00EC00, 0x00EC76, 0x00ECEC, 0x760000, 0x760076


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -