小程序canvas 变换
var ctx = wx.createCanvasContext('base'); var centerX = 375/ 2; var centerY = 200; var rotate = 90; var scale = 2; ctx.save();//保存状态 ctx.translate(centerX, centerY) ctx.rotate(rotate * Math.PI / 180); ctx.scale(scale, scale); ctx.setFillStyle("#FF0000"); ctx.setFontSize(20); ctx.setTextAlign('center'); ctx.setTextBaseline('middle'); ctx.fillText('Hello World', 0, 0); ctx.restore();//恢复状态 ctx.draw();