mirror of
https://github.com/BlueMap-Minecraft/BlueMapWeb.git
synced 2024-06-29 07:44:42 +02:00
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');
|
const pixel = document.createElement('canvas');
|
||||||
pixel.width = 1;
|
pixel.width = 1;
|
||||||
pixel.height = 1;
|
pixel.height = 1;
|
||||||
const pixelContext = pixel.getContext('2d');
|
const pixelContext = pixel.getContext('2d', {
|
||||||
|
willReadFrequently: true
|
||||||
|
});
|
||||||
|
|
||||||
export const getPixel = (img, x, y) => {
|
export const getPixel = (img, x, y) => {
|
||||||
pixelContext.drawImage(img, Math.floor(x), Math.floor(y), 1, 1, 0, 0, 1, 1);
|
pixelContext.drawImage(img, Math.floor(x), Math.floor(y), 1, 1, 0, 0, 1, 1);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user