X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FPixelSampler.js;h=e1b3be36b651efa8ea59e23f7b7c34abb0543495;hb=51fc2820e9e5423394175f481d7003e196718554;hp=89c520fad0bc04e97cd1fbd8b1f406beb6ded06e;hpb=3bdeeb9b9d123e9e45159a6801b6e7fe74f08690;p=dygraphs.git diff --git a/auto_tests/tests/PixelSampler.js b/auto_tests/tests/PixelSampler.js index 89c520f..e1b3be3 100644 --- a/auto_tests/tests/PixelSampler.js +++ b/auto_tests/tests/PixelSampler.js @@ -17,6 +17,7 @@ var PixelSampler = function(dygraph) { var canvas = dygraph.hidden_; var ctx = canvas.getContext("2d"); this.imageData_ = ctx.getImageData(0, 0, canvas.width, canvas.height); + this.scale = canvas.width / dygraph.width_; }; /** @@ -26,7 +27,7 @@ var PixelSampler = function(dygraph) { * are in [0, 255]. A pixel which has never been touched will be [0,0,0,0]. */ PixelSampler.prototype.colorAtPixel = function(x, y) { - var i = 4 * (x + this.imageData_.width * y); + var i = 4 * (x * this.scale + this.imageData_.width * y * this.scale); var d = this.imageData_.data; return [d[i], d[i+1], d[i+2], d[i+3]]; };