Rename variables for clarity
This commit is contained in:
@@ -98,21 +98,23 @@ ol.render.canvas.Replay.prototype.draw = function(context, transform) {
|
|||||||
this.coordinates, 2, transform, this.pixelCoordinates_);
|
this.coordinates, 2, transform, this.pixelCoordinates_);
|
||||||
this.pixelCoordinates_ = pixelCoordinates; // FIXME ?
|
this.pixelCoordinates_ = pixelCoordinates; // FIXME ?
|
||||||
var instructions = this.instructions;
|
var instructions = this.instructions;
|
||||||
var i = 0;
|
var i = 0; // instruction index
|
||||||
var end, j, jj;
|
var ii = instructions.length; // end of instructions
|
||||||
for (j = 0, jj = instructions.length; j < jj; ++j) {
|
var d = 0; // data index
|
||||||
var instruction = instructions[j];
|
var dd; // end of per-instruction data
|
||||||
|
for (; i < ii; ++i) {
|
||||||
|
var instruction = instructions[i];
|
||||||
var type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
var type = /** @type {ol.render.canvas.Instruction} */ (instruction[0]);
|
||||||
if (type == ol.render.canvas.Instruction.BEGIN_PATH) {
|
if (type == ol.render.canvas.Instruction.BEGIN_PATH) {
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
} else if (type == ol.render.canvas.Instruction.CLOSE_PATH) {
|
} else if (type == ol.render.canvas.Instruction.CLOSE_PATH) {
|
||||||
context.closePath();
|
context.closePath();
|
||||||
} else if (type == ol.render.canvas.Instruction.DRAW_IMAGE) {
|
} else if (type == ol.render.canvas.Instruction.DRAW_IMAGE) {
|
||||||
end = /** @type {number} */ (instruction[1]);
|
dd = /** @type {number} */ (instruction[1]);
|
||||||
var imageStyle = /** @type {ol.style.Image} */ (instruction[2]);
|
var imageStyle = /** @type {ol.style.Image} */ (instruction[2]);
|
||||||
for (; i < end; i += 2) {
|
for (; d < dd; d += 2) {
|
||||||
var x = pixelCoordinates[i] - imageStyle.anchor[0];
|
var x = pixelCoordinates[d] - imageStyle.anchor[0];
|
||||||
var y = pixelCoordinates[i + 1] - imageStyle.anchor[1];
|
var y = pixelCoordinates[d + 1] - imageStyle.anchor[1];
|
||||||
if (imageStyle.snapToPixel) {
|
if (imageStyle.snapToPixel) {
|
||||||
x = (x + 0.5) | 0;
|
x = (x + 0.5) | 0;
|
||||||
y = (y + 0.5) | 0;
|
y = (y + 0.5) | 0;
|
||||||
@@ -122,11 +124,11 @@ ol.render.canvas.Replay.prototype.draw = function(context, transform) {
|
|||||||
} else if (type == ol.render.canvas.Instruction.FILL) {
|
} else if (type == ol.render.canvas.Instruction.FILL) {
|
||||||
context.fill();
|
context.fill();
|
||||||
} else if (type == ol.render.canvas.Instruction.MOVE_TO_LINE_TO) {
|
} else if (type == ol.render.canvas.Instruction.MOVE_TO_LINE_TO) {
|
||||||
context.moveTo(pixelCoordinates[i], pixelCoordinates[i + 1]);
|
context.moveTo(pixelCoordinates[d], pixelCoordinates[d + 1]);
|
||||||
goog.asserts.assert(goog.isNumber(instruction[1]));
|
goog.asserts.assert(goog.isNumber(instruction[1]));
|
||||||
end = /** @type {number} */ (instruction[1]);
|
dd = /** @type {number} */ (instruction[1]);
|
||||||
for (i += 2; i < end; i += 2) {
|
for (d += 2; d < dd; d += 2) {
|
||||||
context.lineTo(pixelCoordinates[i], pixelCoordinates[i + 1]);
|
context.lineTo(pixelCoordinates[d], pixelCoordinates[d + 1]);
|
||||||
}
|
}
|
||||||
} else if (type == ol.render.canvas.Instruction.SET_FILL_STYLE) {
|
} else if (type == ol.render.canvas.Instruction.SET_FILL_STYLE) {
|
||||||
goog.asserts.assert(goog.isObject(instruction[1]));
|
goog.asserts.assert(goog.isObject(instruction[1]));
|
||||||
@@ -141,7 +143,10 @@ ol.render.canvas.Replay.prototype.draw = function(context, transform) {
|
|||||||
context.stroke();
|
context.stroke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goog.asserts.assert(i == pixelCoordinates.length);
|
// assert that all data were consumed
|
||||||
|
goog.asserts.assert(d == pixelCoordinates.length);
|
||||||
|
// assert that all instructions were consumed
|
||||||
|
goog.asserts.assert(i == instructions.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user