update detect method of texture type
This commit is contained in:
parent
f6d3b014ad
commit
48de60b43a
@ -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<boolean> {
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user