Open dsicom opened 9 years ago
Check out: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData
This will return an array of all the pixels in rgba value, you could potentially loop over every integer in that array and if they all are 0 then it would be reasonable to assume the canvas is blank.
I store the empty canvas on init and later compare the current sta with the empty one:
// on init
emptyImage = wPaintCanvas.toDataURL();
// later
if(wPaintCanvas.toDataURL() === emptyImage) {
I need to force at the user to paint something in wPaint. Are there any manner to check if the canvas is empty or not? Thanks