public static createBitmap(imgUrl: string): Promise<any> {
return new Promise<object | number>((resolve, reject) => {
const image: any = new Image()
image.src = imgUrl || ''
image.onload = () => {
const Bitmap = new createjs.Bitmap(image)
const { width, height } = Bitmap.image
// Bitmap.setBounds(0, 0, width, height);
Bitmap.regX = width / 2
Bitmap.regY = height / 2
resolve(Bitmap)
}
image.onerror = (error: any) => {
console.warn(`"image load fail"${imgUrl}`, error)
}
})
}
createjs 创建图片位图并设置中心点为图片中心
- 本文作者: 王大伟
- 本文链接: https://weidadeda.github.io/post/createjs-chuang-jian-tu-pian-wei-tu-bing-she-zhi-zhong-xin-dian-wei-tu-pian-zhong-xin
- 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
0%
召唤看板娘