Understanding the volume indicator color

Hello folks,

I am trying to understand, the importance of the volume indicator, But I got stuck how volume indicator is constructed, or logic behind the volume indicator,

How volume bar color is chosed based on bid and ask price? or Mathematical rules behind the volume bar color is red or green.

Does this help?