In a digital camera light doesn’t really travel through – light is focused by the lens onto a sensor. The sensor is basically a big grid of photosites, which are like buckets that store photons from the incoming light. Each photosite has a filter over it, so it only catches light of a paticular colour (red, green or blue).
A pixel in the final image is then made up of a group of four photosites – usually one red, one blue and two green, as the human eye is more sensitive to green light. By counting how many photons there are in each photosite, the camera can then work out which colour each pixel will be!!!
The simplest type of camera is a ‘pinhole’ camera – you don’t even need a lens. For this you just make a small hole. If you sketch how each lightray comes from an object in the scene and goes through the pinhole, travelling in straight lines, you’ll see that you automatically get an inverted image formed on the sensor / film.
Lensed cameras are basically the same except you use shaped glass to bend the light rays so you can gather lots more light at once and still have it focus on the same place. But then you have to add extra bits of specially shaped glass to stop the ‘rainbow’ effect, and keep everything in focus, and it gets horrifically complicated very quickly, which is why there’s lots of different bits in a camera lens and they’re really expensive!