improvements in torque rendering, bubbles were not round in some cases

This commit is contained in:
javi 2015-12-02 10:11:11 +01:00
parent 4421294a4e
commit ce6ba46893

View File

@ -31,7 +31,8 @@ var Filters = require('./torque_filters');
"dst-atop": 'destination-atop', "dst-atop": 'destination-atop',
"xor": 'xor', "xor": 'xor',
"darken": 'darken', "darken": 'darken',
"lighten": 'lighten' "lighten": 'lighten',
"screen": "screen"
} }
function compop2canvas(compop) { function compop2canvas(compop) {
@ -157,9 +158,14 @@ var Filters = require('./torque_filters');
cartocss.renderSprite(ctx, img, st); cartocss.renderSprite(ctx, img, st);
} else { } else {
// take into account the exterior ring to calculate the size // take into account the exterior ring to calculate the size
var canvasSize = (st['marker-line-width'] || 0) + pointSize*2; var canvasSize = (st['marker-line-width'] || 0) + pointSize*2 + 2;
var w = ctx.width = canvas.width = ctx.height = canvas.height = Math.ceil(canvasSize); canvasSize = Math.ceil(canvasSize);
ctx.translate(w/2, w/2); // the sprite should be placed in the center of a pixel not in the middle so
// make the canvas size odd
canvasSize += canvasSize % 2 === 0 ? 1 : 0;
var w = ctx.width = canvas.width = ctx.height = canvas.height = canvasSize;
w = Math.floor(w/2) + 1;
ctx.translate(w, w);
var mt = st['marker-type']; var mt = st['marker-type'];
if (mt && mt === 'rectangle') { if (mt && mt === 'rectangle') {