drawCircle: function (step){
var context = wx.createCanvasContext( 'canvasProgress' );
// 设置渐变
var gradient = context.createLinearGradient(200, 100, 100, 200);
gradient.addColorStop( "0" , "#2661DD" );
gradient.addColorStop( "0.5" , "#40ED94" );
gradient.addColorStop( "1.0" , "#5956CC" );
context.setLineWidth(10);
context.setStrokeStyle(gradient);
context.setLineCap( 'round' )
context.beginPath();
// 参数step 为绘制的圆环周长,从0到2为一周 。 -Math.PI / 2 将起始角设在12点钟位置 ,结束角 通过改变 step 的值确定
context.arc(110, 110, 100, -Math.PI / 2, step * Math.PI - Math.PI / 2, false);
context.stroke();
context.draw()
},
onReady: function () {
this.drawProgressbg();
this.drawCircle(2)
},
|