I'm not sure how to properly use getImageData for color recognition.
var imgd = ctx.getImageData(checkx - ln, checky - ln, ln * 2, ln * 2);
pix = imgd.data;
for (var i = 0, n = pix.length; i < n; i += 4){
    if (pix[i] != 255) {
        collision = 1;
    }
}
Right now, to be safe - if something isn't white on the canvas -> collision
But I want to identify red #ff0000 or green colors #00CC00
How can I do it?
 
     
    