收藏
回答

悬赏一包辣条,通过canvas把一张图片等比例切割成九张。理想很美好现实很骨感?

切割核心代码:

var that = this

for (var i = 0; i < 3; i++) {

for (var j = 0; j < 3; j++) {

console.log(i, j)

wx.canvasToTempFilePath({

x: that.data.canvasWidth / 3 * j,

y: that.data.canvasHeight / 3 * i,

width: that.data.canvasWidth / 3,

height: that.data.canvasHeight / 3,

canvasId: 'myCanvas',

success(res) {

console.log(res.tempFilePath)

wx.saveFile({

tempFilePath: res.tempFilePath,

success(opt) {

console.log(opt.savedFilePath)

that.setData({

yulan: opt.savedFilePath

})

}

})

}

})

}

}



最后一次编辑于  08-01
回答关注问题邀请回答
收藏

2 个回答