Commit 4a35faff authored by David Schnur's avatar David Schnur

Merge pull request #925 from danxshap/master

Always draw crosshair on half-pixels to prevent aliasing.
parents 620b05a7 1bee7663
...@@ -139,18 +139,22 @@ The plugin also adds four public methods: ...@@ -139,18 +139,22 @@ The plugin also adds four public methods:
ctx.translate(plotOffset.left, plotOffset.top); ctx.translate(plotOffset.left, plotOffset.top);
if (crosshair.x != -1) { if (crosshair.x != -1) {
var adj = plot.getOptions().crosshair.lineWidth % 2 === 0 ? 0 : 0.5;
ctx.strokeStyle = c.color; ctx.strokeStyle = c.color;
ctx.lineWidth = c.lineWidth; ctx.lineWidth = c.lineWidth;
ctx.lineJoin = "round"; ctx.lineJoin = "round";
ctx.beginPath(); ctx.beginPath();
if (c.mode.indexOf("x") != -1) { if (c.mode.indexOf("x") != -1) {
ctx.moveTo(crosshair.x, 0); var drawX = Math.round(crosshair.x) + adj;
ctx.lineTo(crosshair.x, plot.height()); ctx.moveTo(drawX, 0);
ctx.lineTo(drawX, plot.height());
} }
if (c.mode.indexOf("y") != -1) { if (c.mode.indexOf("y") != -1) {
ctx.moveTo(0, crosshair.y); var drawY = Math.round(crosshair.y) + adj;
ctx.lineTo(plot.width(), crosshair.y); ctx.moveTo(0, drawY);
ctx.lineTo(plot.width(), drawY);
} }
ctx.stroke(); ctx.stroke();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment