inverse every bit of color to get the right color

Because the longest pin of color LED is positive, so if 0 on R pin, it means there's red color in the LED. So the color definition should be inverse.