Skip to content
This repository has been archived by the owner on Mar 6, 2019. It is now read-only.

Commit

Permalink
Minor coding style improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahocevar committed Feb 22, 2012
1 parent bb3ae99 commit 69660e3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/OpenLayers/Renderer/Canvas.js
Expand Up @@ -336,29 +336,29 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {
// Push symbol scaling, translation and rotation onto the transformation stack in reverse order.
// Don't forget to apply all canvas transformations to the hitContext canvas as well(!)
this.canvas.save();
if (this.hitDetection) this.hitContext.save();
if (this.hitDetection) { this.hitContext.save(); }

// Step 3: place symbol at the desired location
this.canvas.translate(p0,p1);
if (this.hitDetection) this.hitContext.translate(p0,p1);
if (this.hitDetection) { this.hitContext.translate(p0,p1); }

// Step 2a. rotate the symbol if necessary
angle = deg2rad * style.rotation; // will be NaN when style.rotation is undefined.
if (!isNaN(angle)) {
this.canvas.rotate(angle);
if (this.hitDetection) this.hitContext.rotate(angle);
if (this.hitDetection) { this.hitContext.rotate(angle); }
}

// // Step 2: scale symbol such that pointRadius equals half the maximum symbol dimension.
scaling = 2.0 * style.pointRadius / Math.max(symbolBounds.getWidth(), symbolBounds.getHeight());
this.canvas.scale(scaling,scaling);
if (this.hitDetection) this.hitContext.scale(scaling,scaling);
if (this.hitDetection) { this.hitContext.scale(scaling,scaling); }

// Step 1: center the symbol at the origin
cx = symbolBounds.getCenterLonLat().lon;
cy = symbolBounds.getCenterLonLat().lat;
this.canvas.translate(-cx,-cy);
if (this.hitDetection) this.hitContext.translate(-cx,-cy);
if (this.hitDetection) { this.hitContext.translate(-cx,-cy); }

// Don't forget to scale stroke widths, because they are affected by canvas scale transformations as well(!)
// Alternative: scale symbol coordinates manually, so stroke width scaling is not needed anymore.
Expand Down Expand Up @@ -408,7 +408,7 @@ OpenLayers.Renderer.Canvas = OpenLayers.Class(OpenLayers.Renderer, {

style.strokeWidth = unscaledStrokeWidth;
this.canvas.restore();
if (this.hitDetection) this.hitContext.restore();
if (this.hitDetection) { this.hitContext.restore(); }
this.setCanvasStyle("reset");
},

Expand Down

0 comments on commit 69660e3

Please sign in to comment.