ios
wx.drawCanvasios
ios
here is the code section:
app.awardsConfig = {
chance: true,
awards: [
{ "index": 0, "name": "1" },
{ "index": 1, "name": "5" },
{ "index": 2, "name": "6" },
{ "index": 3, "name": "8" },
{ "index": 4, "name": "10" },
{ "index": 5, "name": "10" }
]
}
//
var awardsConfig = app.awardsConfig.awards,
len = awardsConfig.length,
rotateDeg = 360 / len / 2 + 90,
html = [],
turnNum = 1 / len // turn
that.setData({
btnDisabled: app.awardsConfig.chance ? "" : "disabled"
})
var ctx = wx.createContext()
for (var i = 0; i < len; iPP) {
//
ctx.save();
//
ctx.beginPath();
//
ctx.translate(150, 150);
// (0, 0)
ctx.moveTo(0, 0);
// ,, degrees * Math.PI/180
ctx.rotate((360 / len * i - rotateDeg) * Math.PI / 180);
//
ctx.arc(0, 0, 150, 0, 2 * Math.PI / len, false);
//
if (i % 2 == 0) {
ctx.setFillStyle("-sharpffb820");
} else {
ctx.setFillStyle("-sharpffcb3f");
}
//
ctx.fill();
//
ctx.setLineWidth(0.5);
ctx.setStrokeStyle("-sharpe4370e");
ctx.stroke();
//
ctx.restore();
//
html.push({ turn: i * turnNum + "turn", award: awardsConfig[i].name });
}
that.setData({
awardsList: html
});
// setTimeout(function(){
wx.drawCanvas({
canvasId: "lotteryCanvas",
actions: ctx.getActions()
})
// },3000)