From 5be6dc80895e21402ab6d84e563a9b34c4a94f1c Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Sun, 16 Oct 2022 00:35:06 +0200 Subject: [PATCH] Improve pixel reading performance a bit --- src/util/Utils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/Utils.js b/src/util/Utils.js index be3c946..be69f01 100644 --- a/src/util/Utils.js +++ b/src/util/Utils.js @@ -384,7 +384,9 @@ export const vecArrToObj = (val, useZ = false) => { const pixel = document.createElement('canvas'); pixel.width = 1; pixel.height = 1; -const pixelContext = pixel.getContext('2d'); +const pixelContext = pixel.getContext('2d', { + willReadFrequently: true +}); export const getPixel = (img, x, y) => { pixelContext.drawImage(img, Math.floor(x), Math.floor(y), 1, 1, 0, 0, 1, 1);