2d-context-api

the fillStyle of canvas is not working

一曲冷凌霜 提交于 2019-12-12 04:31:42
问题 i have a function that has a loop. in the loop it creates a canvas and sets the opacity. Then it sets the background color and converts the canvas to an image. Somehow the Opacity is being set on the canvas but the background color doesn't get set. if (remain <= 0) { var canvas = document.createElement('canvas'); context = canvas.getContext('2d'); for (var i = 0; i < img.length; ++i) { if (img[i]) { var opacity = item.opa; context.globalAlpha = opacity; context.drawImage(img[i],0,0); } } var