i want a function which checks the color of stroke and pixel in canvas. If the color of pixel in canvas and stroke is same, then do not change the color of the stroke. I have tried the function below but it doesn't work. Any idea how to achieve this? thanks
//this line gets pixel data
pixels = context.getImageData(0, 0, canvas.width, canvas.height);
var linecolor = context.strokeStyle;
if ((linecolor) === (colour.r && colour.g && colour.b)){
context.strokeStyle = "rgb(255,255,0)"
}
function getpixelcolour(x, y) {
var index = ((y * (pixels.width * 4)) + (x * 4));
return {
r: pixels.data[index],
g: pixels.data[index + 1],
b: pixels.data[index + 2],
a: pixels.data[index + 3]
};
}