update detect method of texture type
This commit is contained in:
parent
f6d3b014ad
commit
48de60b43a
@ -1,14 +1,18 @@
|
|||||||
import { loadSkinToCanvas } from 'skinview-utils'
|
import { loadSkinToCanvas } from 'skinview-utils'
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
function isTransparent(
|
function checkPixel(
|
||||||
context: CanvasRenderingContext2D,
|
context: CanvasRenderingContext2D,
|
||||||
x: number,
|
x: number,
|
||||||
y: number,
|
y: number,
|
||||||
): boolean {
|
): boolean {
|
||||||
const imageData = context.getImageData(x, y, 1, 1)
|
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 */
|
/* istanbul ignore next */
|
||||||
@ -32,7 +36,16 @@ export function isAlex(texture: string): Promise<boolean> {
|
|||||||
return
|
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