diff --git a/resources/assets/src/scripts/textureUtils.ts b/resources/assets/src/scripts/textureUtils.ts index 8a898c41..a34f46c1 100644 --- a/resources/assets/src/scripts/textureUtils.ts +++ b/resources/assets/src/scripts/textureUtils.ts @@ -1,14 +1,18 @@ import { loadSkinToCanvas } from 'skinview-utils' /* istanbul ignore next */ -function isTransparent( +function checkPixel( context: CanvasRenderingContext2D, x: number, y: number, ): boolean { const imageData = context.getImageData(x, y, 1, 1) - return imageData.data[3] !== 255 + return ( + imageData.data[0] === 0 && + imageData.data[1] === 0 && + imageData.data[2] === 0 + ) } /* istanbul ignore next */ @@ -32,7 +36,16 @@ export function isAlex(texture: string): Promise { return } - resolve(isTransparent(context, 46 * ratio, 63 * ratio)) + for (let x = 46 * ratio; x < 48 * ratio; x += 1) { + for (let y = 52 * ratio; y < 64 * ratio; y += 1) { + if (!checkPixel(context, x, y)) { + resolve(false) + return + } + } + } + + resolve(true) } }) }