带有垂直滚动条的HTML画布

时间:2020-09-09 01:06:40

标签: html5-canvas

我是Html 5 canvas的新手,有没有一种方法可以从模拟了滚动条的整个画布中保存图像?

带有滚动条的示例画布: https://konvajs.org/downloads/code/sandbox/Canvas_Scrolling_Transform.html

保存图像

var canvas = document.getElementsByTagName('canvas')[0];
var MIME_TYPE = "image/png";
var imgURL = canvas.toDataURL(MIME_TYPE);
var dlLink = document.createElement('a');
dlLink.download = 'dl';
dlLink.href = imgURL;
dlLink.dataset.downloadurl = [MIME_TYPE, dlLink.download, dlLink.href].join(':');
document.body.appendChild(dlLink);
dlLink.click();

0 个答案:

没有答案