I want to get color of a x y pixel with javascript/jquery, so googled and found that it could be done with canvas.
var canvas = $("<canvas>"); //Create the canvas element
//Create a layer which overlaps the whole window
canvas.css({ position: "fixed", top: "0", left: "0",
width: "100%", height: "100%", "z-index": 9001
});
//Add an event listener to the canvas element
canvas.click(function (ev) {
var x = ev.pageX, y = ev.pageY;
var canvas = this.getContext("2d");
canvas.drawWindow(window, x, y, 1, 1, "transparent");
var data = canvas.getImageData(0, 0, 1, 1).data;
var hex = rgb2hex(data[0], data[1], data[2]);
alert(hex);
$(this).remove();
});
but its not working (drawWindow
in firefox not working, not working in chrome too).
any ideas ?