繁华开满天机
是的,当然,只要你有它的背景。如何获得画布上下文?var imgData = context.getImageData(0,0,canvas.width,canvas.height);// { data: [r,g,b,a,r,g,b,a,r,g,..], ... }function getPixel(imgData, index) {
var i = index*4, d = imgData.data;
return [d[i],d[i+1],d[i+2],d[i+3]] // returns array [R,G,B,A]}// AND/ORfunction getPixelXY(imgData, x, y) {
return getPixel(imgData, y*imgData.width+x);}