canvas
发布于 6 年前 作者 mingshen 13264 次浏览 来自 问答

下面一段代码是把ctx.drawImage()封装成一个方法:

statusImage: function (picPath, statusImgObj) {
var ctx = this.data.ctx;
   ctx.drawImage(picPath, (statusImgObj.x-50) / 2, (statusImgObj.y -16)/ 2,50, 50)
},

在需要的地方调用这个方法:

that.statusImage(item.imgUrl, {x: item.x, y: item.y});
that.data.ctx.draw();

真机上测试时,发现用ctx.drawImage()画的静态图片在安卓机上被拉伸变虚,ios系统没有被拉伸变虚

回到顶部