After the last chrome update a p5 program I’ve been working on has broken.
I’m using image() to draw an image on the canvas and on mouseup the canvas is stored using loadpixels(). This is so I have some undo data to go back to. Since the chrome update, every time it runs loadpixels() it clears the canvas and I lose the drawing.
Is this a bug that needs to be addressed?
Is there a better way I could be doing this?
Worth noting, it still works as intended on Firefox.
Here is a basic example of what I’m working with: p5.js Web Editor
And to compare, if you draw a rect instead of an image the canvas does not clear
let canvas
preload = function () {
img = loadImage('https://static.vecteezy.com/system/resources/thumbnails/008/505/460/small/watercolor-moon-and-star-clipart-png.png');
}
function setup() {
canvas = createCanvas(400, 400);
canvas.mousePressed(mouseDown);
canvas.mouseReleased(mouseUp);
noLoop();
}
function draw() {
image(img, mouseX, mouseY, 50, 50);
// rect(mouseX, mouseY, 50, 50);
}
function mouseUp() {
noLoop();
canvas.loadPixels(); // load the pixel array
}
function mouseDown() {
loop();
}