Barra, thats pretty much how it works for many species. Others can't do it at all. For some fish species a darker colour is just from sunburn.
Check out some vids of cuttlefish.,I think they do it best of all. The patterns & colours they can make are unbelievable.