StickerSpoof: Fix not correctly cleaning previous frame

This commit is contained in:
Vendicated 2022-11-09 20:29:35 +01:00
parent 3c8084ec36
commit c1d2f0078f
No known key found for this signature in database
GPG Key ID: EC781ADFB93EFFA3

@ -181,9 +181,6 @@ export default definePlugin({
let lastImg: HTMLImageElement | null = null;
for (const { left, top, width, height, disposeOp, img, delay } of frames) {
if (disposeOp === ApngDisposeOp.BACKGROUND) {
ctx.clearRect(left, top, width, height);
}
ctx.drawImage(img, left, top, width, height);
const { data } = ctx.getImageData(0, 0, resolution, resolution);
@ -197,9 +194,12 @@ export default definePlugin({
delay,
});
if (disposeOp === ApngDisposeOp.PREVIOUS && lastImg) {
if (disposeOp === ApngDisposeOp.BACKGROUND) {
ctx.clearRect(left, top, width, height);
} else if (disposeOp === ApngDisposeOp.PREVIOUS && lastImg) {
ctx.drawImage(lastImg, left, top, width, height);
}
lastImg = img;
}