I'm working with some coordinate points, such as [0, 0],[30, 0],[30, 20],[60, 20],[60, 40],[0, 40],[0, 0]
Using these points as input, I want to create shapes with clickable corners. The edges will overlap each other - on the first mouse click, the first segment goes over the second. On the second click, the second segment goes over the first, and on the third click it creates a mitre effect.
[Here are some possible polygon interaction effects][1] [1]: https://i.sstatic.net/Ok0iM.png
Is there a way to place invisible rectangles at the corners for click detection? The challenge is accurately determining where to position the rectangles at each corner.
Additionally, what is the best approach for converting these points into lines or paths? The generated lines should be thick, but without using stroke width settings.
I previously attempted paths with stroke width settings, which caused the line join mitre effect to not work properly. Any suggestions on how to improve this would be greatly appreciated.
Below is a sample code snippet with lines and rectangles placed at corners:
<svg id="SvgjsSvg1001" width="700" height="400" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" viewBox="-100 -20 350 200"><defs id="SvgjsDefs1002"></defs><g id="SvgjsG1008" transform="matrix(2.5,0,0,2.5,0,0)"><line id="SvgjsLine1009" x1="0" y1="0" x2="30" y2="0" stroke-linecap="square" stroke="#ffdc0b" stroke-width="4"></line><line id="SvgjsLine1010" x1="30" y1="0" x2="30" y2="20" stroke-linecap="square" stroke="#002438" stroke-width="4"></line><line id="SvgjsLine1011" x1="30" y1="20" x2="60" y2="20" stroke-linecap="square" stroke="#9b56bb" stroke-width="4"></line><line id="SvgjsLine1012" x1="60" y1="20" x2="60" y2="40" stroke-linecap="square" stroke="#c6c7e2" stroke-width="4"></line><line id="SvgjsLine1013" x1="60" y1="40" x2="0" y2="40" stroke-linecap="square" stroke="#318700" stroke-width="4"></line><line id="SvgjsLine1014" x1="0" y1="40" x2="0" y2="0" stroke-linecap="square" stroke="#fe854f" stroke-width="4"></line>
<rect width="5" height="5" x="30" y="0"></rect>
<rect width="5" height="5" x="30" y="20"></rect>
<rect width="5" height="5" x="60" y="20"></rect>
<rect width="5" height="5" x="60" y="40"></rect>
<rect width="5" height="5" x="0" y="40"></rect>
<rect width="5" height="5" x="0" y="0"></rect></g></svg>