Light from the sun always travels in straight paths. Sunlight appears to be ‘white’ but it actually contains the entire range or spectrum of visible (and not-visible) colours.
You can make the spectrum visible with a glass prism. Each colour of light bends slightly different amounts as it enters and leaves the prism, so the colours spread out like a fan.
We see objects by the light they reflect rather than absorb. So apples are red because they reflect red light to our eyes but absorb the other colours. And green leaves? They reflect green light to our eyes.