/**
* Draw an ellipse.
*
* @method drawEllipse
* @param {Number} x The x coordinate(in bitmap) of the center of the ellipse
* @param {Number} y The y coordinate(in bitmap) of the center of the ellipse
* @param {Number} w The width of the ellipse
* @param {Number} h The height of the ellipse
* @param {Number} lw The width of the ellipse's line
* @param {String} color The color of the ellipse in CSS format
*/
Bitmap.prototype.drawEllipse = function(x, y, w, h, lw, color) {
var context = this._context;
var w = w * 2;
var h = h * 2;
var x = x - w/2;
var y = y - h/2;
context.save();
context.beginPath();
var kappa = 0.5522848,
ox = (w / 2) * kappa, // control point offset horizontal
oy = (h / 2) * kappa, // control point offset vertical
xe = x + w, // x-end
ye = y + h, // y-end
xm = x + w / 2, // x-middle
ym = y + h / 2; // y-middle
context.moveTo(x, ym);
context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
context.closePath();
context.strokeStyle = color;
context.lineWidth = lw;
context.stroke();
context.restore();
this._setDirty();
};
/**
* Fill an ellipse.
*
* @method fillEllipse
* @param {Number} x The x coordinate(in bitmap) of the center of the ellipse
* @param {Number} y The y coordinate(in bitmap) of the center of the ellipse
* @param {Number} w The width of the ellipse
* @param {Number} h The height of the ellipse
* @param {String} color The color of the ellipse in CSS format
*/
Bitmap.prototype.fillEllipse = function(x, y, w, h, color) {
var context = this._context;
var w = w * 2;
var h = h * 2;
var x = x - w/2;
var y = y - h/2;
context.save();
context.beginPath();
var kappa = 0.5522848,
ox = (w / 2) * kappa, // control point offset horizontal
oy = (h / 2) * kappa, // control point offset vertical
xe = x + w, // x-end
ye = y + h, // y-end
xm = x + w / 2, // x-middle
ym = y + h / 2; // y-middle
context.moveTo(x, ym);
context.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
context.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
context.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
context.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
context.closePath();
context.fillStyle = color;
context.fill();
context.restore();
this._setDirty();
};