私はそれをこのように書くでしょう
int[] values = new int[]{0, 32, 64, 96, 128, 160, 192, 224, 255};
SortedMap<Long, Color> colours = new TreeMap<>(Collections.reverseOrder());
for (int r : values) {
for (int g : values) {
for (int b : values) {
long brightness = (r + g + b) / 3;
long colourScore = (brightness << 24) + (r << 8) + (g << 16) + b;
colours.put(colourScore, new Color(r,g,b));
}
}
}
for (Color color : colours.values()) {
System.out.println(color);
}
青の色合いは夜に関連しているため、これは青よりも赤と緑を優先します。;)印刷します
java.awt.Color[r=255,g=255,b=255]
java.awt.Color[r=255,g=255,b=224]
java.awt.Color[r=224,g=255,b=255]
java.awt.Color[r=255,g=224,b=255]
java.awt.Color[r=255,g=255,b=192]
java.awt.Color[r=224,g=255,b=224]
java.awt.Color[r=192,g=255,b=255]
... many deleted ...
java.awt.Color[r=32,g=0,b=32]
java.awt.Color[r=0,g=0,b=64]
java.awt.Color[r=0,g=32,b=0]
java.awt.Color[r=32,g=0,b=0]
java.awt.Color[r=0,g=0,b=32]
java.awt.Color[r=0,g=0,b=0]