Improve pixel reading performance a bit
This commit is contained in:
parent
7e9f0e0bd8
commit
5be6dc8089
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue