removes redundant divisions from loop

This commit is contained in:
Francisco Dans 2015-05-06 12:39:59 +02:00
parent de5ad67a38
commit 6f351dd5fb

View File

@ -256,7 +256,11 @@ var Filters = require('./torque_filters');
}
var tileMax = this.options.resolution * (this.TILE_SIZE/this.options.resolution - 1)
var activePixels = tile.timeCount[key];
var anchor = this.options.resolution/2;
var anchor = this.options.resolution >> 1;
if(this._style){
var adjustmentFactor = this._style["marker-width"];
var adjustmentFactorAnchored = adjustmentFactor + anchor;
}
if (activePixels) {
var pixelIndex = tile.timeIndex[key];
for(var p = 0; p < activePixels; ++p) {
@ -268,9 +272,9 @@ var Filters = require('./torque_filters');
sp = sprites[c] = this.generateSprite(shader, c, shaderVars);
}
if (sp) {
var x = tile.x[posIdx]- (sp.width >> 1) + anchor;
var x = tile.x[posIdx]- adjustmentFactorAnchored;
var y = tileMax - tile.y[posIdx] + anchor; // flip mercator
ctx.drawImage(sp, x, y - (sp.height >> 1));
ctx.drawImage(sp, x, y - adjustmentFactor);
}
}
}