function drawEllipse(ctx, x0, y0, x1, y1, fill_p) {
var w = (x1 - x0) / 2;
var h = (y1 - y0) / 2;
var C = 0.5522847498307933;
var c_x = C * w;
var c_y = C * h;
ctx.beginPath();
ctx.moveTo(x1, y0 + h);
ctx.bezierCurveTo(x1, y0 + h - c_y, x0 + w + c_x, y0, x0 + w, y0);
ctx.bezierCurveTo(x0 + w - c_x, y0, x0, y0 + h - c_y, x0, y0 + h);
ctx.bezierCurveTo(x0, y0 + h + c_y, x0 + w - c_x, y1, x0 + w, y1);
ctx.bezierCurveTo(x0 + w + c_x, y1, x1, y0 + h + c_y, x1, y0 + h);
if (fill_p) {
ctx.fill();
} else {
ctx.stroke();
}
}
var canvas = document.body.appendChild(document.createElement('canvas'));
canvas.width = 400;
canvas.height = 400;
var ctx = canvas.getContext('2d');
ctx.lineWidth = 20;
drawEllipse(ctx, 300, 200, 50, 50);