X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2FPixelSampler.js;fp=auto_tests%2Ftests%2FPixelSampler.js;h=d45ab8a30e681fcb1a8d0a0626de8af2b29a08f4;hb=ce31caf22475e3e1fd6d9fea192d61ff4fcd7fac;hp=e1b3be36b651efa8ea59e23f7b7c34abb0543495;hpb=a4c3ece0a11e4e5c4f1f51a8bc8b7878d34ee052;p=dygraphs.git diff --git a/auto_tests/tests/PixelSampler.js b/auto_tests/tests/PixelSampler.js index e1b3be3..d45ab8a 100644 --- a/auto_tests/tests/PixelSampler.js +++ b/auto_tests/tests/PixelSampler.js @@ -33,6 +33,17 @@ PixelSampler.prototype.colorAtPixel = function(x, y) { }; /** + * Convenience wrapper around colorAtPixel if you only care about RGB (not A). + * @param {number} x The screen x-coordinate at which to sample. + * @param {number} y The screen y-coordinate at which to sample. + * @return {Array.} a 3D array: [R, G, B]. All three values + * are in [0, 255]. A pixel which has never been touched will be [0,0,0]. + */ +PixelSampler.prototype.rgbAtPixel = function(x, y) { + return this.colorAtPixel(x, y).slice(0, 3); +}; + +/** * The method samples a color using data coordinates (not screen coordinates). * This will round your data coordinates to the nearest screen pixel before * sampling. @@ -45,3 +56,5 @@ PixelSampler.prototype.colorAtCoordinate = function(x, y) { var dom_xy = this.dygraph_.toDomCoords(x, y); return this.colorAtPixel(Math.round(dom_xy[0]), Math.round(dom_xy[1])); }; + +export default PixelSampler;