I want to have a static method, which whenever called will return a color value that didn't appear yet, and is not too close to last returned color (i.e. return new Color(last_value += 10)
won't do). It also should be not random, so everytime the application is launched, the sequence of returned colors would be the same.
First thing that popped to my head, is to iterate over an array with a primal number step, something like this:
private static HashMap<Integer, Boolean> used = new HashMap<>();
private static int[] values = new int[0xfffff]; // 1/16th of possible colors
private static int current = 0, jump = values.length / 7;
public static Color getColour(){
int value = values[current];
used.put(current, true);
current += jump;
current %= values.length;
//have some check here if all colors were used
while (used.containsKey(current)){
current++;
current%=values.length;
}
return new Color(value);
}
But I don't like it, since colors will be close to each other from some calls back.