Answer the question
In order to leave comments, you need to log in
How to get the pixel color of an image in canvas?
Tell me, I'm uploading an image to canvas and I want to know the color of a certain pixel in the image.
For example, this image:
My code for calculating the color for a canvas without an image (purely using pixel drawing):
ctx.clearRect(0, 0, canvas.width, canvas.height);
frame4x4.forEach((row, i) => {
row.forEach((column, j) => {
ctx.fillStyle = `${currColor.style.backgroundColor}`;
frame4x4[i][j] = `${currColor.style.backgroundColor}`;
ctx.fillRect(j * 4, i * 4, 4, 4);
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question