I'm creating a color picker and I have it pulling the color from the HTML5 canvas with the gradient. Most of the time it's displaying the proper color, but sometimes it will randomly display white or black. I have a demo below where it logs all blacks and whites (other than the top left and the bottom pixels).
DEMO: http://jsfiddle.net/ek2kD/
The code in question, at the very bottom, is this:
function getColor()
{
var pixelColor = contextTone.getImageData(mouseXGo, mouseYGo, 1, 1).data;
var hex = "#" + ("000000" + ((pixelColor[0] << 16) | (pixelColor[1] << 8) | pixelColor[2]).toString(16)).slice(-6);
document.getElementById("preview").style.backgroundColor = hex;
}
(I removed the logging code for the snippet above)
Why is this flickering white and black when dragging around the circle on the top gradient?