1
0
Fork 0

Try willReadFrequently

This commit is contained in:
Lim Chee Aun 2023-09-09 14:26:08 +08:00
parent fea1d77342
commit 696a46311d
2 changed files with 6 additions and 2 deletions

View file

@ -188,7 +188,9 @@ function AccountInfo({
try {
// Get color from four corners of image
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
const ctx = canvas.getContext('2d', {
willReadFrequently: true,
});
canvas.width = e.target.width;
canvas.height = e.target.height;
ctx.drawImage(e.target, 0, 0);

View file

@ -16,7 +16,9 @@ const alphaCache = {};
const canvas = window.OffscreenCanvas
? new OffscreenCanvas(1, 1)
: document.createElement('canvas');
const ctx = canvas.getContext('2d');
const ctx = canvas.getContext('2d', {
willReadFrequently: true,
});
function Avatar({ url, size, alt = '', squircle, ...props }) {
size = SIZES[size] || size || SIZES.m;