Color Collision??

i just got this idea in my mind hope you read it all

so lets say we have 2 cubes 1 red and 1 blue

now if we could check if red Color intersects with blue Color and if it does the color purple stop moving?

have anybody tried this?

it just came to my mind by random, the idea can be improved ofcorse but would that save performance or?