fix(ui): fix layer transparency calculation

This commit is contained in:
psychedelicious 2024-07-15 19:35:38 +10:00
parent 9bc57a6f59
commit 4a44e171fd

View File

@ -3,7 +3,7 @@ export const getImageDataTransparency = (imageData: ImageData) => {
let isPartiallyTransparent = false; let isPartiallyTransparent = false;
const len = imageData.data.length; const len = imageData.data.length;
for (let i = 3; i < len; i += 4) { for (let i = 3; i < len; i += 4) {
if (imageData.data[i] === 255) { if (imageData.data[i] !== 0) {
isFullyTransparent = false; isFullyTransparent = false;
} else { } else {
isPartiallyTransparent = true; isPartiallyTransparent = true;
@ -14,14 +14,3 @@ export const getImageDataTransparency = (imageData: ImageData) => {
} }
return { isFullyTransparent, isPartiallyTransparent }; return { isFullyTransparent, isPartiallyTransparent };
}; };
export const areAnyPixelsBlack = (pixels: Uint8ClampedArray) => {
const len = pixels.length;
const i = 0;
for (let i = 0; i < len; i) {
if (pixels[i++] === 0 && pixels[i++] === 0 && pixels[i++] === 0 && pixels[i++] === 255) {
return true;
}
}
return false;
};