Some images have small artifacts of alpha transparency

Change requirement to at least 50% transparency. Not perfect, good for now.
pull/79/head
Lim Chee Aun 2023-03-14 11:56:52 +08:00
rodzic b47c904729
commit 2a80c42c87
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -57,9 +57,10 @@ function Avatar({ url, size, alt = '', ...props }) {
canvas.height,
);
const hasAlpha = allPixels.data.some((pixel, i) => {
return i % 4 === 3 && pixel !== 255;
return i % 4 === 3 && pixel <= 128;
});
if (hasAlpha) {
console.log('hasAlpha', hasAlpha, allPixels.data);
avatarRef.current.classList.add('has-alpha');
alphaCache[url] = true;
}