角:生成图像时如何设置画布的背景色?

时间:2018-08-10 20:47:08

标签: html5-canvas

我尝试将画布下载为图像,但是下载的背景透明。如何为图片设置背景颜色?

这是我尝试过的代码:

 this.canvas = document.getElementById('barchart') as HTMLCanvasElement;
        var download = document.getElementById("download");
        let url = this.canvas.toDataURL("image/png").replace("image/png","image/octet-stream");
        download.setAttribute("href", url);

0 个答案:

没有答案