if( (i*11 + j) % 4 == 0) //red
else if( (i*11 + j) % 3 == 0) //blue
else if( (i*11 + j) % 2 == 0) //green
else //yellow

Or you could use the inlining method, but it would get messy lol

Chris