To get the pixel color from the canvas, use the following code. This will return the color in rgba -
var index = (Math.floor(y) * canvasWidth + Math.floor(x)) * 4 // color in rgba var r = data[index] var g = data[index + 1] var b = data[index + 2] var a = data[index + 3]
The above is the detailed content of Get pixel color from HTML canvas. For more information, please follow other related articles on the PHP Chinese website!