javascript - How to compare (contents of) color objects retrieved from HTML5 canvas via ctx.getImageData() -
i'd compare (a limited number of) color values retrieved html5 canvas. retrieve , store i'm interested in ctx.getimagedata(x, y, 1, 1).data; i tried use array.prototype.compare from: how compare arrays in javascript? by: // add same compare method uint8clampedarray uint8clampedarray.prototype.compare=array.prototype.compare; that works fine on recent firefox , chrome found not browsers return object of type uint8clampedarray. ie seems use object of canvaspixelarray , safari seems use simple 4-value array do have deal differences myself or there reliable generelized method (plain js or jquery) compare 2 such values retieved ctx.getimagedata() works on browsers? you can (probably?) use array compare method this: var comparisonresult = [].compare.call(yourpixels, colors); that code finds "compare" method array instance , invokes pixel array this value , other array (your colors) first parameter. this same thing: var comparisonresult =