Make the color fading code DRY.