From be6fc4e41d0c64963b004566eb15c1640b9d7361 Mon Sep 17 00:00:00 2001 From: David Schnur Date: Fri, 11 Jan 2013 18:43:49 -0500 Subject: [PATCH] Draw selection on half-pixels to avoid aliasing. Adapted from pull request #17. --- jquery.flot.selection.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jquery.flot.selection.js b/jquery.flot.selection.js index 2fccf4e..781678c 100644 --- a/jquery.flot.selection.js +++ b/jquery.flot.selection.js @@ -308,10 +308,10 @@ The plugin allso adds the following methods to the plot object: ctx.lineJoin = "round"; ctx.fillStyle = c.scale('a', 0.4).toString(); - var x = Math.min(selection.first.x, selection.second.x), - y = Math.min(selection.first.y, selection.second.y), - w = Math.abs(selection.second.x - selection.first.x), - h = Math.abs(selection.second.y - selection.first.y); + var x = Math.min(selection.first.x, selection.second.x) + 0.5, + y = Math.min(selection.first.y, selection.second.y) + 0.5, + w = Math.abs(selection.second.x - selection.first.x) - 1, + h = Math.abs(selection.second.y - selection.first.y) - 1; ctx.fillRect(x, y, w, h); ctx.strokeRect(x, y, w, h);