This is a demonstration of my ray casting "framework". Each pair of clicks draws a line. The "light source" is movable (click and drag). It will run VERY slowly. This is because the canvas element is drawing each small segment of each ray as the rays are expanded. Accessing the canvas is slow, and this is being done many times. In an applicatian, these rays will not be drawn (or at least not drawn as they are "cast"), so this will cease to be a problem. It would take more time to make an app that emulates this one (but faster) and as this is just a demo...well...meh.

This is how it works:
From the centre of the source (blue), a given number of lines are drawn (green). These lines continue until they collide with a wall (black) or the edge of the screen. The length of each line is increased by some amount repeatedly, then checked for collisions. Some algebra is used to check for collisions. I won't bore you with the details. All possible collision points (red) between lines are found (if each line was infinitely long), then checked to see if they actually lie on the lines.

To increase the accuracy of the areas denoted as dark and light, one can increase the number of rays, or decrease the amount by which each ray grows in size at each step. This will increase cost, and so for demonstration purposes, it is left in poor quality.