-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split 'editor' to 'editor' and 'combine','next'button intelligentized…
… disable
- Loading branch information
Showing
10 changed files
with
144 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// pages/combine/combine.js | ||
const app=getApp(); | ||
Page({ | ||
|
||
data: { | ||
|
||
}, | ||
|
||
onLoad: function (options) { | ||
wx.getImageInfo({ | ||
src:app.globalData.bgPic, | ||
success: res => { | ||
this.bgPic=res.path | ||
this.draw(); | ||
} | ||
}) | ||
}, | ||
|
||
/** | ||
* 生命周期函数--监听页面初次渲染完成 | ||
*/ | ||
onReady: function () { | ||
|
||
}, | ||
|
||
|
||
draw() { | ||
let scale = app.globalData.scale; | ||
let rotate = app.globalData.rotate; | ||
let hat_center_x = app.globalData.hat_center_x; | ||
let hat_center_y = app.globalData.hat_center_y; | ||
let currentHatId = app.globalData.currentHatId; | ||
const pc = wx.createCanvasContext('myCanvas'); | ||
const windowWidth = wx.getSystemInfoSync().windowWidth; | ||
const hat_size = 100 * scale; | ||
|
||
|
||
pc.clearRect(0, 0, windowWidth, 300); | ||
pc.drawImage(this.bgPic, windowWidth / 2 - 150, 0, 300, 300); | ||
pc.translate(hat_center_x,hat_center_y); | ||
pc.rotate(rotate * Math.PI / 180); | ||
pc.drawImage("../../image/" + currentHatId + ".png", -hat_size / 2, -hat_size / 2, hat_size, hat_size); | ||
pc.draw(); | ||
}, | ||
savePic() { | ||
const windowWidth = wx.getSystemInfoSync().windowWidth; | ||
wx.canvasToTempFilePath({ | ||
x: windowWidth / 2 - 150, | ||
y: 0, | ||
height: 300, | ||
width: 300, | ||
canvasId: 'myCanvas', | ||
success: (res) => { | ||
wx.saveImageToPhotosAlbum({ | ||
filePath: res.tempFilePath, | ||
success: (res) => { | ||
wx.navigateTo({ | ||
url: '../index/index', | ||
success: function(res) {}, | ||
fail: function(res) {}, | ||
complete: function(res) {}, | ||
}) | ||
console.log("success:" + res); | ||
}, fail(e) { | ||
console.log("err:" + e); | ||
} | ||
}) | ||
} | ||
}); | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<view > | ||
<canvas class="myCanvas" canvas-id="myCanvas" style="height:300px;;width:100%;"/> | ||
<button bind:tap="savePic">保存至相册</button> | ||
</view> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* pages/combine/combine.wxss */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters