3
私はベルカーブを描画したいと思います。だから本質的に私はx1、x2、heightという3つのパラメータを渡すことができ、破線のベルカーブを描くはずです。これを達成する最良の方法は何ですか?ここでsvgは2点の間に点線のベルカーブを描きます
私は通常のベジェ曲線を描くために持っているものです。あなたが鐘を近似曲線を取得するには次曲線を使用することができます
function getDimension(x1, x2, height) {
return "M" + x1 + "," + height + " C" + x1 + ",0 " + x2 + ",0 " + x2 + "," + height;
}
var curve = document.createElementNS("http://www.w3.org/2000/svg", "path");
curve.setAttribute("d", getDimension(0, 100, 50));
curve.setAttribute("x", '0');
curve.setAttribute("fill", 'none');
curve.setAttribute("stroke", 'black');
curve.setAttribute("stroke-dasharray", '5');
document.getElementById('svg').appendChild(curve);
私は情報を提供する前になぜdownvote?私はこれまでのところを示すために説明を更新しました。 –