SVG DOM 仕様を見ずに書かれた、完全にテストされていないコードをいくつか紹介します。次に、それをテストし、微調整して機能させることができます。
まず、要素の境界ボックスを取得します。
var box = mypath.getBBox();
次に、パスを 2 回複製します (または要素を作成します)。
var rightCopy = mypath.cloneNode(true);
var bottomCopy = mypath.cloneNode(true);
次に、各コピーを変換します。
rightCopy.setAttribute("transform", "translate(" + box.width + ",0) " + rightCopy.getAttribute("transform"));
bottomCopy.setAttribute("transform", "translate(0," + box.height + ") " + bottomCopy.getAttribute("transform"));
乱雑に見える理由は、元のパスに既に変換がある可能性があるためです。
次に、それらのノードを DOM に追加します。
mypath.parentNode.insertBefore(rightCopy, mypath);
mypath.parentNode.insertBefore(bottomCopy, mypath);