Hello stackoverflow community,
I'm working on a puzzle game using Cocos2D/Box2D were the player draws lines on the screen. Depending on were the player draws, I want to then work out the area and position of the rectangles that appear as a result of the drawn lines.
I've currently got an array of all lines in the game so I know their (x, y) positions and sizes but I'm at a lost as to how to calculate the area and Cartesian coordinates of the rectangles that are dynamically formed. To help illustrate the problem, please see the following:
In the image above, you can see a black border. Contained within this are 4 grey lines which have been drawn by the player. From this, 5 blue rectangles have been formed. Any guidance or advice on how I can calculate the area and Cartesian coordinates of the rectangles would be a great help.