I have a image, and i have cordinates (x1,y1),(x2,y2),(x3,y3),(x4,y4)
to draw a svg/rectagle on image, how to draw?
I have tried using svg tag in img
tag, but it does not work, the main thing is how to set width and height of svg(rect svg) using those cordinates.
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="100%" height="100%" viewBox="0 0 1055 717" preserveAspectRatio="xMinYMin meet" >
<rect x="540" y="134" width="150" height="100" fill="none" stroke="red" stroke-width="2" />
</svg>
You can consider using
calc()
and some CSS variables to find the width/height:If I understand correctly OP then so and look at the comments in the code.
UPDATE
If a square over the image is needed to focus on one or more fragments of the image, then you can use it repeatedly but add individual tooltips
<tooltip>
A tooltip pops up when you hover and hold the cursor on the red square