I'm looking for a solution where I can find the center of SVG line via path since I want to render the foreign object at center of SVG.
Here is my code
<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
</head>
<body>
<svg>
<g
stroke-linecap="round"
data-linkid="36141ffc-14b0-4375-9d40-8d002ac597fc"
stroke-opacity="0"
stroke-width="20"
><svg>
<path
stroke-width="10"
stroke="rgba(255,0,0,0.5)"
d="M68.6875,52.6875 C 68.6875,102.6875
379.6875,331.6875 379.6875,381.6875"
tets="Fd"
></path>
<foreignObject x="50" y="50" height="100" width="40">
<div xmlns="http://www.w3.org/1999/xhtml">
<h1>HI</h1>
</div>
</foreignObject>
</svg></g
>
</svg>
<script src="src/index.js"></script>
</body>
</html>
As you can see in the above code for rendering foreign object I have passed static x and y coordinates as 50. How can I calculate the center point so that HI is rendered exactly at the center of my SVG?