|
@@ -269,141 +269,4 @@ Page({
|
|
wx.setStorageSync('simulationFont' + that.data.isActive, that.data.simulation);
|
|
wx.setStorageSync('simulationFont' + that.data.isActive, that.data.simulation);
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- // getBuildImg(that) {
|
|
|
|
- // for (let i = 1; i <= 1; i++) {
|
|
|
|
- // if (wx.getStorageSync('madeCupImgData' + i) || wx.getStorageSync('madeCupFontData' + i)) {
|
|
|
|
- // if (wx.getStorageSync('madeCupImgData' + i)) {
|
|
|
|
- // this.setData({
|
|
|
|
- // imgTouch: wx.getStorageSync('madeCupImgData' + i)
|
|
|
|
- // })
|
|
|
|
- // }
|
|
|
|
- // if (wx.getStorageSync('madeCupFontData' + i)) {
|
|
|
|
- // this.setData({
|
|
|
|
- // fontTouch: wx.getStorageSync('madeCupFontData' + i)
|
|
|
|
- // })
|
|
|
|
- // }
|
|
|
|
- // that.getCombImg(that);
|
|
|
|
- // }
|
|
|
|
- // console.log(i)
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- // },
|
|
|
|
- // 合成canvas的js
|
|
|
|
- // getCombImg(that) {
|
|
|
|
- // let imgTouch = that.data.imgTouch;
|
|
|
|
- // let dataPositionObj = that.data.dataPositionObj;
|
|
|
|
- // wx.getSystemInfo({
|
|
|
|
- // success: function (res) {
|
|
|
|
- // let rpx = res.windowWidth / 750;
|
|
|
|
- // that.setData({
|
|
|
|
- // rpx: rpx
|
|
|
|
- // });
|
|
|
|
- // wx.downloadFile({
|
|
|
|
- // url: imgTouch.src, // 仅为示例,并非真实的资源
|
|
|
|
- // success(res) {
|
|
|
|
- // // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
|
|
|
|
- // console.log(res)
|
|
|
|
- // if (res.statusCode === 200) {
|
|
|
|
- // // canvas截图区域与图片的宽度比例
|
|
|
|
- // let dWidth = dataPositionObj.width / imgTouch.width;
|
|
|
|
- // // canvas截图区域与图片的高度比例
|
|
|
|
- // let dHeight = dataPositionObj.height / imgTouch.height;
|
|
|
|
- // const ctx = wx.createCanvasContext('comb-img');
|
|
|
|
- // //画布中点坐标转移到图片中心
|
|
|
|
- // let movex = imgTouch.x + imgTouch.width * rpx / 2;
|
|
|
|
- // let movey = imgTouch.y + imgTouch.height * rpx / 2;
|
|
|
|
- // ctx.translate(movex, movey);
|
|
|
|
- // ctx.rotate(imgTouch.angle * Math.PI / 180);
|
|
|
|
- // ctx.drawImage(res.tempFilePath, -imgTouch.width * rpx / 2, -imgTouch.height * rpx / 2, imgTouch.width * rpx, imgTouch.height * rpx)
|
|
|
|
- // ctx.draw(true, function () {
|
|
|
|
- // wx.canvasToTempFilePath({
|
|
|
|
- // canvasId: 'comb-img',
|
|
|
|
- // success: function (res) {
|
|
|
|
- // console.log(res)
|
|
|
|
- // let imgArray = that.data.imgSrcArray;
|
|
|
|
- // imgArray.push(res.tempFilePath)
|
|
|
|
- // that.setData({
|
|
|
|
- // imgSrcArray: imgArray
|
|
|
|
- // })
|
|
|
|
- // that.getCombFont(that);
|
|
|
|
- // }
|
|
|
|
- // }, that)
|
|
|
|
- // })
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
-
|
|
|
|
- // },
|
|
|
|
- // })
|
|
|
|
- // },
|
|
|
|
- // getCombFont(that) {
|
|
|
|
- // let fontTouch = that.data.fontTouch;
|
|
|
|
- // let dataPositionObj = that.data.dataPositionObj;
|
|
|
|
- // const ctx = wx.createCanvasContext('comb-font');
|
|
|
|
-
|
|
|
|
- // let movex = fontTouch.x + fontTouch.width / 2;
|
|
|
|
- // let movey = fontTouch.y + fontTouch.height / 2;
|
|
|
|
- // // ctx.translate(movex, movey);
|
|
|
|
- // // ctx.rotate(fontTouch.angle * Math.PI / 180);
|
|
|
|
-
|
|
|
|
- // ctx.setFontSize(fontTouch.fontSize);
|
|
|
|
- // ctx.setFillStyle(fontTouch.isColor);
|
|
|
|
- // ctx.fillText(fontTouch.fontContent, fontTouch.x, fontTouch.y + fontTouch.height / 5 * 4);
|
|
|
|
- // // ctx.fillText(fontTouch.fontContent, -fontTouch.width / 2, fontTouch.height / 10 * 3);
|
|
|
|
- // ctx.draw(true, function () {
|
|
|
|
- // wx.canvasToTempFilePath({
|
|
|
|
- // canvasId: 'comb-font',
|
|
|
|
- // success: function (res) {
|
|
|
|
- // console.log(res)
|
|
|
|
- // let imgArray = that.data.imgSrcArray;
|
|
|
|
- // imgArray.push(res.tempFilePath)
|
|
|
|
- // that.setData({
|
|
|
|
- // imgSrcArray: imgArray
|
|
|
|
- // })
|
|
|
|
- // console.log(that.data.imgSrcArray, "that.data.imgSrcArray")
|
|
|
|
- // that.getComb(that, that.data.imgSrcArray)
|
|
|
|
- // }
|
|
|
|
- // }, that)
|
|
|
|
- // })
|
|
|
|
- // },
|
|
|
|
- // getComb(that, imgSrcArray) {
|
|
|
|
- // console.log('开始最后的合成')
|
|
|
|
- // let imgTouch = that.data.imgTouch;
|
|
|
|
- // let dataPositionObj = that.data.dataPositionObj;
|
|
|
|
- // wx.getSystemInfo({
|
|
|
|
- // success: function (res) {
|
|
|
|
- // let rpx = res.windowWidth / 750;
|
|
|
|
- // that.setData({
|
|
|
|
- // rpx: rpx
|
|
|
|
- // });
|
|
|
|
- // let canvasBg = that.data.obverseImgObject[1];
|
|
|
|
- // const ctx = wx.createCanvasContext('comb-canvas');
|
|
|
|
- // ctx.drawImage(canvasBg, 0, 0, 750 * rpx, 588 * rpx);
|
|
|
|
- // ctx.draw(true);
|
|
|
|
- // // 设置背景
|
|
|
|
- // imgSrcArray.forEach((res) => {
|
|
|
|
- // ctx.drawImage(res, dataPositionObj.left * rpx, dataPositionObj.top * rpx, dataPositionObj.width * rpx, dataPositionObj.height * rpx);
|
|
|
|
- // })
|
|
|
|
- // console.log('渲染完成');
|
|
|
|
- // ctx.draw(true);
|
|
|
|
- // // ctx.draw(true, function () {
|
|
|
|
- // // wx.canvasToTempFilePath({
|
|
|
|
- // // canvasId: 'comb-canvas',
|
|
|
|
- // // success: function (res) {
|
|
|
|
- // // console.log(res, "最后的合成")
|
|
|
|
- // // let imgBuildArray = that.data.imgBuildArray;
|
|
|
|
- // // imgBuildArray.push(res.tempFilePath)
|
|
|
|
- // // that.setData({
|
|
|
|
- // // imgSrcArray: [], // 重置
|
|
|
|
- // // imgBuildArray: imgBuildArray
|
|
|
|
- // // })
|
|
|
|
- // // console.log(that.data.imgBuildArray, "that.data.imgBuildArray")
|
|
|
|
- // // }
|
|
|
|
- // // }, that)
|
|
|
|
- // // })
|
|
|
|
-
|
|
|
|
- // },
|
|
|
|
- // })
|
|
|
|
- // }
|
|
|
|
})
|
|
})
|