electron dependecy

1. How are the color of an compound and it's constituent elements related?

Suppose the color of some elements is red and blue but after the reaction between them a new compound formed with yellow color .so on what factor does the the color of compound depend??? I think it may depend depend upon the number of electron transferred and the remaining one...