How to dynamically compute a list of colors?

前端 未结 3 1067
粉色の甜心
粉色の甜心 2020-12-10 18:19

In order to represent a List of Objects with different colors in a GWT-Widget, we need to get dynamically a List of colors with as much different colors as objects. Since th

3条回答
  •  無奈伤痛
    2020-12-10 19:01

    Something like this would do I guess. No randomness, just calculates which color steps to take and splits all color range to that steps. If you limit the lower limit - you will remove too dark colors, and limiting the upper limit will remove too bright colors.

    List getUniqueColors(int amount) {
        final int lowerLimit = 0x101010;
        final int upperLimit = 0xE0E0E0;
        final int colorStep = (upperLimit-lowerLimit)/amount;
    
        final List colors = new ArrayList(amount);
        for (int i=0;i

提交回复
热议问题