add low level ellipse rendering support

This commit is contained in:
Vladimir Agafonkin 2014-01-02 19:25:08 +02:00
parent 9ce2cc5cbd
commit c4a9418d3b
3 changed files with 18 additions and 5 deletions

View File

@ -129,10 +129,21 @@ L.Canvas = L.Renderer.extend({
if (layer._empty()) { return; }
var p = layer._point,
ctx = this._ctx;
ctx = this._ctx,
r = layer._radius,
s = (layer._radiusY || r) / r;
if (s !== 1) {
ctx.save();
ctx.scale(1, s);
}
ctx.beginPath();
ctx.arc(p.x, p.y, layer._radius, 0, Math.PI * 2, false);
ctx.arc(p.x, p.y / s, r, 0, Math.PI * 2, false);
if (s !== 1) {
ctx.restore();
}
this._fillStroke(ctx, layer);
},

View File

@ -104,10 +104,11 @@ L.SVG.include(!L.Browser.vml ? {} : {
_updateCircle: function (layer) {
var p = layer._point,
r = Math.round(layer._radius);
r = Math.round(layer._radius),
r2 = Math.round(layer._radiusY || r);
this._setPath(layer, layer._empty() ? 'M0 0' :
'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r + ' 0,' + (65535 * 360));
'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r2 + ' 0,' + (65535 * 360));
},
_setPath: function (layer, path) {

View File

@ -110,7 +110,8 @@ L.SVG = L.Renderer.extend({
_updateCircle: function (layer) {
var p = layer._point,
r = layer._radius,
arc = 'a' + r + ',' + r + ' 0 1,0 ';
r2 = layer._radiusY || r,
arc = 'a' + r + ',' + r2 + ' 0 1,0 ';
// drawing a circle with two half-arcs
var d = layer._empty() ? 'M0 0' :