puts max radius as a constant

This commit is contained in:
Francisco Dans 2015-05-05 12:56:37 +02:00
parent 645da00ce1
commit fa5791483e
2 changed files with 6 additions and 6 deletions

View File

@ -2,6 +2,7 @@
// min value to render a line. // min value to render a line.
// it does not make sense to render a line of a width is not even visible // it does not make sense to render a line of a width is not even visible
var LINEWIDTH_MIN_VALUE = 0.05; var LINEWIDTH_MIN_VALUE = 0.05;
var MAX_SPRITE_RADIUS = 255;
function renderPoint(ctx, st) { function renderPoint(ctx, st) {
ctx.fillStyle = st['marker-fill']; ctx.fillStyle = st['marker-fill'];
@ -78,8 +79,7 @@
if (st['marker-fill-opacity'] !== undefined || st['marker-opacity'] !== undefined) { if (st['marker-fill-opacity'] !== undefined || st['marker-opacity'] !== undefined) {
ctx.globalAlpha = st['marker-fill-opacity'] || st['marker-opacity']; ctx.globalAlpha = st['marker-fill-opacity'] || st['marker-opacity'];
} }
var maxSpriteRadius = 255; ctx.drawImage(img, 0, 0, Math.min(img.width, MAX_SPRITE_RADIUS), Math.min(img.height, MAX_SPRITE_RADIUS));
ctx.drawImage(img, 0, 0, Math.min(img.width, maxSpriteRadius), Math.min(img.height, maxSpriteRadius));
} }
} }

View File

@ -137,11 +137,11 @@ var Filters = require('./torque_filters');
if (qualifiedUrl && this._iconsToLoad <= 0 && this._icons[qualifiedUrl]) { if (qualifiedUrl && this._iconsToLoad <= 0 && this._icons[qualifiedUrl]) {
var img = this._icons[qualifiedUrl]; var img = this._icons[qualifiedUrl];
var dWidth = st['marker-width'] * 2 || img.width; var dWidth = Math.min(st['marker-width'] * 2 || img.width, this.options.maxSpriteSize || 512);
var dHeight = (st['marker-height'] || dWidth) * (img.width / img.height); var dHeight = Math.min((st['marker-height'] || dWidth) * (img.width / img.height), this.options.maxSpriteSize || 512);
canvas.width = ctx.width = Math.min(dWidth, this.options.maxSpriteSize || 512); canvas.width = ctx.width = dWidth;
canvas.height = ctx.height = Math.min(dHeight, this.options.maxSpriteSize || 512); canvas.height = ctx.height = dHeight;
ctx.scale(dWidth/img.width, dHeight/img.height); ctx.scale(dWidth/img.width, dHeight/img.height);