What's the science behind this phenomenon? Light travels in straight lines, but we have three different-colored bulbs spaced several inches apart.
Human Color Perception
The retina of the human eye has three receptors for colored light. One type of receptor is most sensitive to red light, one to green light, and one to blue light. With these three color receptors, we are able to perceive more than a million different shades of color.
When a red light, a blue light, and a green light are all shining on the screen, the screen looks white because these three colored lights stimulate all three color receptors on your retinas approximately equally, giving us the sensation of white. Red, green, and blue are therefore called additive primaries of light.
With these three lights, you can make shadows of seven different colors: blue, red, green, black, cyan (blue-green), magenta (a mixture of blue and red), and yellow (a mixture of red and green). If you block two of the three lights, you get a shadow of the third color. Block the red and green lights, for example, and you get a blue shadow. If you block all three lights, you get a black shadow. And if you block one of the three lights, you get a shadow whose color is a mixture of the two other colors. If the blue and green mix, they make cyan; red and blue make magenta; red and green make yellow.
If you turn off the red light, leaving only the blue and green lights on, the lights mix and the screen appears to be cyan, a blue-green color. When you hold the object in front of this cyan screen, you will see two shadows: one blue and one green. In one place the object blocks the light coming from the green bulb and therefore leaves a blue shadow; in another place it blocks the light from the blue bulb to make a green shadow. When you move the object close to the screen you will get a very dark (black) shadow, where the object blocks both lights.
When you turn off the green light, leaving the red and blue lights on, the screen will appear to be magenta, a mixture of red and blue. The shadows will be red and blue. When you turn off the blue light, leaving the red and green lights on, the screen will appear to be yellow. The shadows will be red and green.
It may seem strange that a red light and a green light mix to make yellow light on a white screen. A mixture of red and green light stimulates the red and green receptors on the retina of your eye. Those same receptors are also stimulated by yellow light—that is, by light from the yellow portion of the rainbow. When the red and green receptors in your eye are stimulated, whether by a mixture of red and green light, or by yellow light alone, you will see the color yellow.