A rainbow is made of the colors red, orange, yellow, green, blue, and violet. Where did the rainbow come from? All the colors exist in sunlight. We can’t see them because they are mixed together.
When sunlight moves from the air to the water in the glass, it bends in a special way. When it bends, the light separates into all the colors of the rainbow. It’s called refraction. From How To Make a Rainbow video