var canvas = wx.createCanvas("fore") var scrw = 0 var scrh = 0 var minV = 0 wx.getSystemInfo ( { success: function (res) { scrh = res.windowHeight scrw = res.windowWidth minV = scrh if (scrh > scrw) minV = scrw } } ) canvas.width = minV canvas.height = minV // console.log(canvas.width, canvas.height) var context = canvas.getContext('2d') var a = 10 var b = minV - 20 context.fillStyle = 'rgb(200,100,100)' var i = 0 while (i < 20) { var c1 = (20 - i) * 10 var c2 = "'"+'rgb(' + c1 + ','+ c1 +','+ c1 + ")'" console.log(c2) context.setFillStyle = c2 context.fillRect(a + i, a + i, b - i * 2, b - i * 2) i = i + 1 } var offScreenCanvas1 = wx.createCanvas() var offContext1 = offScreenCanvas1.getContext('2d') offContext1.fillStyle = 'blue' offContext1.fillRect(0, 0, 100, 100) context.drawImage(offScreenCanvas1, 100, 100);
context.setFillStyle = c2,是不是有问题?var a = 10 var b = minV - 20 context.fillStyle = 'rgb(200,100,100)' var i = 0 while (i < 20) { var c1 = (20 - i) * 10 var c2 = "'"+'rgb(' + c1 + ','+ c1 +','+ c1 + ")'" console.log(c2) context.setFillStyle = c2 context.fillRect(a + i, a + i, b - i * 2, b - i * 2) i = i + 1 } 其中倒数第四行 context.setFillStyle = c2,没有起作用,求助。谢谢!
2019-09-04