I want to make a rectangle knowing the position of the two vertical lines of the sides. The lines are implemented as follows:
<path fill="#000000" id="Measure1" d="M159.688,119.75L159.688,88.75L160.28799999999998,88.75L160.28799999999998,119.75ZM162.688,119.75L162.688,88.75L163.28799999999998,88.75L163.28799999999998,119.75Z"/>
<path fill="#000000" id="Measure2" d="M260.168,119.75L260.168,88.75L260.76800000000003,88.75L260.76800000000003,119.75Z"/>
With this code I have a rectangle:
<path d="M10 80 H 110 V 130 H 10 V 80 Z" fill="red" />
But can I use the coordinates of the two lines to use them to give my rectangle the position?
Thank you!
You can get the bounding box of the lines with SVG’s native
getBBox(), and then calculate the positions, here is a basic example:You can see the result here:
http://jsfiddle.net/3rSYV/