From c4a9418d3b6435077fb80363978e8e5a8f042a79 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Thu, 2 Jan 2014 19:25:08 +0200 Subject: [PATCH] add low level ellipse rendering support --- src/layer/vector/Canvas.js | 15 +++++++++++++-- src/layer/vector/SVG.VML.js | 5 +++-- src/layer/vector/SVG.js | 3 ++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/layer/vector/Canvas.js b/src/layer/vector/Canvas.js index d2dc02aa..64a46110 100644 --- a/src/layer/vector/Canvas.js +++ b/src/layer/vector/Canvas.js @@ -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); }, diff --git a/src/layer/vector/SVG.VML.js b/src/layer/vector/SVG.VML.js index 1d4ecccb..ce1bf505 100644 --- a/src/layer/vector/SVG.VML.js +++ b/src/layer/vector/SVG.VML.js @@ -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) { diff --git a/src/layer/vector/SVG.js b/src/layer/vector/SVG.js index c712aaeb..98fa1504 100644 --- a/src/layer/vector/SVG.js +++ b/src/layer/vector/SVG.js @@ -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' :