javascript - 将 Canvas 分成几 block

标签 javascript jquery html canvas html2canvas

我正在使用 html2canvas 生成网址的屏幕截图。此屏幕截图显示在页面上,我希望能够在单击它时将其分成几部分。

我从 html2canvas 获得的输出文件是一个 canvas 元素。 我怎样才能将它“打破”成随机碎片?我应该为我想要的每件作品创建新的 Canvas 元素吗?

最佳答案

Html2Canvas 未单击 。它只是渲染提供给它的 DOM 元素。所以我认为你不能将渲染的 Canvas 分解成碎片。

How it works

The script traverses through the DOM of the page it is loaded on. It gathers information on all the elements there, which it then uses to build a representation of the page. In other words, it does not actually take a screenshot of the page, but builds a representation of it based on the properties it reads from the DOM.

但是您可以做的一件事是将 DOM 内容分成多个部分,然后您可以对每个 DOM 部分使用 Html2Canvas 并获得所需的结果。

关于javascript - 将 Canvas 分成几 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39654128/

相关文章:

javascript - JQuery 在事件开始时应用 css 函数,在结束时恢复

javascript - AngularJS - 在 html 模板中使用插值

.net - 如何检查用户是否在 javascript 中传递了有效日期?

javascript - 如何在 HTML 中修改所有选定类的子 div?

javascript - 'duplicate' jQuery 伪类选择器的用途是什么?

javascript - 如何使 jquery 滚动功能 ui-touch-punch 与来自 Bootstrap 的响应式 div 类一起工作?

javascript - 如何在我的 Rmarkdown html 输出中获取复制按钮,以将 R 代码中生成的表格复制到剪贴板?

用于将跨度更改为带有链接的图像的 Javascript 代码停止工作

Javascript:无法将 document.getElementById(fieldname).label 转换为对象

jquery - 如何使用 jQuery 滑动 div 关闭/打开页面