Could someone explain this snippet of code i found?

Please explain what this code does(mainly the ‘pixels(i) = …’ parts):


if (height < 0) {
     underWater++;
     pixels[i] = 20 << 16 | 50 << 8 | (height / 2 + 225);
} else if (height < 2945) {
     pixels[i] = 0 << 16 | (100 + height / 19) << 8 | 0;
} else {
    pixels[i] = ((height - 2945) / 19) << 16 | 255 << 8 | ((height - 2945) / 19);
}

Thanks