Computing polygons from intersecting lines
I have a bounding rectangle that a user can add lines onto. The lines will always extend to intersect the rectangle, so a new shape is always created.Does anyone have any ideas how I would traverse the lines and intersection points to create the bounded polygons created as each new line is added? I need to be able to color each piece of the created polygon differently.
Currently I create lines and intersections which I associated with each other. I then tried traversing all intersections on line switching to the intersecting line at each intersection point. I compare the distance to the origin to determine the best point to chose on the intersecting line, but this is problematic. Is there an easier way to do this?

