Problem Statement
Although this generally works well, it doesn't generate good complements for grey colors that have all three components right around 128. To fix this you will return an alternate complement for grey colors. If each component of a color and its corresponding component of the color's complement differ by 32 or less, then make the complement of each component by either adding 128 to a component's value, or by subtracting 128 from a component's value, whichever one results in a legal value. For example, the color {120,130,140} would have the complement {125,105,115}, but each component in the color and the complement differ by 32 or less, so we make the complement {248,2,12}.
Create a class RGBColor with a method getComplement that takes a
Definition
- Class:
- RGBColor
- Method:
- getComplement
- Parameters:
- int[]
- Returns:
- int[]
- Method signature:
- int[] getComplement(int[] rgb)
- (be sure your method is public)
Constraints
- rgb will contain exactly three elements.
- Each element of rgb will be a value between 0 and 255, inclusive.
Examples
{255,0,0}
Returns: { 0, 255, 255 }
The complement of red is cyan.
{115,115,143}
Returns: { 243, 243, 15 }
The complement of this bluish-grey would normally have been {140,140,112}. But since each component of the complement would have been within 32 of the corresponding component of rgb we return the alternate complement instead.
{115,115,144}
Returns: { 140, 140, 111 }
Also a bluish-grey, but in this case the blue component of the complement differs by 33 from the blue component of rgb, just enough so that we don't need to return the alternate complement.
{153,12,55}
Returns: { 102, 243, 200 }
{126,129,107}
Returns: { 129, 126, 148 }
{139,114,139}
Returns: { 11, 242, 11 }
{134,141,143}
Returns: { 6, 13, 15 }
{28,225,135}
Returns: { 227, 30, 120 }
{191,49,222}
Returns: { 64, 206, 33 }
{114,15,71}
Returns: { 141, 240, 184 }
{102,135,89}
Returns: { 153, 120, 166 }
{120,140,137}
Returns: { 248, 12, 9 }
{86,19,123}
Returns: { 169, 236, 132 }
{133,161,216}
Returns: { 122, 94, 39 }
{84,85,47}
Returns: { 171, 170, 208 }
{174,101,91}
Returns: { 81, 154, 164 }
{114,137,136}
Returns: { 242, 9, 8 }
{227,26,118}
Returns: { 28, 229, 137 }
{143,137,137}
Returns: { 15, 9, 9 }
{31,63,54}
Returns: { 224, 192, 201 }
{115,136,125}
Returns: { 243, 8, 253 }
{250,190,166}
Returns: { 5, 65, 89 }
{228,134,142}
Returns: { 27, 121, 113 }
{41,109,78}
Returns: { 214, 146, 177 }
{134,113,128}
Returns: { 6, 241, 0 }
{139,127,129}
Returns: { 11, 255, 1 }
{5,144,197}
Returns: { 250, 111, 58 }
{220,83,205}
Returns: { 35, 172, 50 }
{59,72,153}
Returns: { 196, 183, 102 }
{131,130,141}
Returns: { 3, 2, 13 }
{143,122,133}
Returns: { 15, 250, 5 }
{0,0,0}
Returns: { 255, 255, 255 }
{255,255,255}
Returns: { 0, 0, 0 }
{ 129, 30, 30 }
Returns: { 126, 225, 225 }
{ 128, 128, 128 }
Returns: { 0, 0, 0 }
{ 115, 115, 144 }
Returns: { 140, 140, 111 }
{ 128, 129, 3 }
Returns: { 127, 126, 252 }
{ 1, 1, 128 }
Returns: { 254, 254, 127 }
{ 0, 128, 255 }
Returns: { 255, 127, 0 }
{ 230, 230, 230 }
Returns: { 25, 25, 25 }
{ 1, 1, 120 }
Returns: { 254, 254, 135 }
{ 130, 130, 130 }
Returns: { 2, 2, 2 }
{ 115, 115, 128 }
Returns: { 243, 243, 0 }
{ 115, 155, 144 }
Returns: { 140, 100, 111 }
{ 1, 1, 1 }
Returns: { 254, 254, 254 }
{ 127, 127, 127 }
Returns: { 255, 255, 255 }
{ 140, 140, 111 }
Returns: { 115, 115, 144 }
{ 120, 120, 120 }
Returns: { 248, 248, 248 }