I have an array of 24 colors. Occasionally when I generate it I get colors that have the exact same RGB values. What I want to do is find the duplicates in the array and change the value of the match by like 1 or 2. Just so that it doesn't match anymore.
Here is my array of colors. Notice that there are 3 of the exact shade of red. I want each one to be slightly different from each other. Keep the R channel the same but change the G and or B channels to be like 1 or 2 numbers higher.
Color Array: [java.awt.Color[r=255,g=194,b=23], java.awt.Color[r=255,g=0,b=0], java.awt.Color[r=255,g=0,b=0], java.awt.Color[r=0,g=67,b=255], java.awt.Color[r=0,g=255,b=175], java.awt.Color[r=255,g=13,b=10], java.awt.Color[r=255,g=115,b=43], java.awt.Color[r=2,g=92,b=255], java.awt.Color[r=241,g=219,b=255], java.awt.Color[r=255,g=194,b=0], java.awt.Color[r=231,g=210,b=255], java.awt.Color[r=0,g=43,b=255], java.awt.Color[r=255,g=80,b=0], java.awt.Color[r=255,g=205,b=27], java.awt.Color[r=255,g=0,b=9], java.awt.Color[r=205,g=199,b=255], java.awt.Color[r=0,g=44,b=255], java.awt.Color[r=255,g=0,b=0], java.awt.Color[r=21,g=255,b=219], java.awt.Color[r=255,g=199,b=51], java.awt.Color[r=255,g=82,b=2], java.awt.Color[r=215,g=198,b=255], java.awt.Color[r=0,g=255,b=203], java.awt.Color[r=255,g=98,b=28]]
What I was thinking was iterating through the array.
for(int i = 0; i < colorArray.length; i++){
if(colorArray[i] == //not sure what this would be equal to as it will be checking all the values in the array ) {
colorArray[i].getBlue() = matchingColor.getBlue() += 1;
colorArray[i].getGreen() matchingColor.getGreen() += 2; //These are example values just to make sure that they have no match
}
}