|
@@ -206,8 +206,7 @@ Page({
|
|
|
wx.canvasToTempFilePath({
|
|
|
canvasId: 'comb-font',
|
|
|
success: function (res) {
|
|
|
- console.log(res)
|
|
|
- that.getComb(that, that.data.imgSrcArray, i)
|
|
|
+ that.getCombFontImg(that, res.tempFilePath, fontTouch, i)
|
|
|
}
|
|
|
}, that)
|
|
|
})
|
|
@@ -216,6 +215,40 @@ Page({
|
|
|
}
|
|
|
|
|
|
},
|
|
|
+ getCombFontImg(that, img, fontTouch, i) { // 生产字体图片后在进行处理一次
|
|
|
+ wx.getSystemInfo({
|
|
|
+ success: function (res) {
|
|
|
+ let rpx = res.windowWidth / 750;
|
|
|
+ that.setData({
|
|
|
+ rpx: rpx
|
|
|
+ });
|
|
|
+ // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
|
|
|
+ console.log(res)
|
|
|
+ // canvas截图区域与图片的宽度比例
|
|
|
+ const ctx = wx.createCanvasContext('comb-font-1');
|
|
|
+ //画布中点坐标转移到图片中心
|
|
|
+ let movex = fontTouch.x + that.data.dataPositionObj.width * rpx / 2;
|
|
|
+ let movey = fontTouch.y + that.data.dataPositionObj.height * rpx / 2;
|
|
|
+ ctx.translate(movex, movey);
|
|
|
+ ctx.rotate(fontTouch.angle * Math.PI / 180);
|
|
|
+ ctx.drawImage(img, -that.data.dataPositionObj.width * rpx / 2, -that.data.dataPositionObj.height * rpx / 2, that.data.dataPositionObj.width * rpx, that.data.dataPositionObj.height * rpx)
|
|
|
+ ctx.draw(false, function () {
|
|
|
+ wx.canvasToTempFilePath({
|
|
|
+ canvasId: 'comb-font-1',
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res)
|
|
|
+ let imgArray = that.data.imgSrcArray;
|
|
|
+ imgArray.push(res.tempFilePath)
|
|
|
+ that.setData({
|
|
|
+ imgSrcArray: imgArray
|
|
|
+ })
|
|
|
+ that.getComb(that, that.data.imgSrcArray, i, true)
|
|
|
+ }
|
|
|
+ }, that)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ })
|
|
|
+ },
|
|
|
getComb(that, imgSrcArray, i) {
|
|
|
console.log(imgSrcArray, "imgSrcArray")
|
|
|
|