- gContext.strokeStyle = "#FF0000";
- gContext.fillStyle = gContext.strokeStyle;
- gContext.lineWidth = 2;
- gContext.lineCap = "round";
- gContext.lineJoin = "round";
- gContext.beginPath();
- if (!gLastTrackPoint || gLastTrackPoint == trackpoint) {
- gContext.arc((trackpoint.x - gPos.x) / gZoomFactor + gCanvas.width / 2,
- (trackpoint.y - gPos.y) / gZoomFactor + gCanvas.height / 2,
+ // lastPoint is for optimizing (not actually executing the draw until the last)
+ trackpoint.optimized = (lastPoint === false);
+
+ if (!gLastDrawnPoint || !gLastDrawnPoint.optimized) {
+ gContext.strokeStyle = "#FF0000";
+ gContext.fillStyle = gContext.strokeStyle;
+ gContext.lineWidth = 2;
+ gContext.lineCap = "round";
+ gContext.lineJoin = "round";
+ }
+ if (!gLastDrawnPoint || gLastDrawnPoint == trackpoint) {
+ // This breaks optimiziation, so make sure to close path and reset optimization.
+ if (gLastDrawnPoint && gLastDrawnPoint.optimized)
+ gContext.stroke();
+ gContext.beginPath();
+ trackpoint.optimized = false;
+ gContext.arc(Math.round((trackpoint.x - gPos.x) / gZoomFactor + gCanvas.width / 2),
+ Math.round((trackpoint.y - gPos.y) / gZoomFactor + gCanvas.height / 2),