我试图制作一个随机颜色生成器,但我不希望类似的颜色出现在 arrayList 中
public class RandomColorGen {
public static Color RandColor() {
Random rand = new Random();
float r = rand.nextFloat();
float g = rand.nextFloat();
float b = rand.nextFloat();
Color c = new Color(r, g, b, 1);
return c;
}
public static ArrayList<Color> ColorList(int numOfColors) {
ArrayList<Color> colorList = new ArrayList<Color>();
for (int i = 0; i < numOfColors; i++) {
Color c = RandColor();
if(similarcolors){
dont add
}
colorList.add(c);
}
return colorList;
}
}
我真的很困惑请帮忙:)