问题描述
有没有办法在canvas中呈现一个任意的HTML元素(然后访问它的缓冲区......)。
目前,由于canvas上下文不具备呈现HTML元素的功能,因此您无法将真实的HTML呈现转换为< canvas>
本身。
有一些模拟:
html2canvas项目(基本上是一个基于Javascript + canvas的HTML渲染器尝试)
HTML to SVG to < canvas>
可能取决于您的用例: $ b
另外,如果您使用Firefox
Is there a way to have an arbitrary HTML element rendered in a canvas (and then access its buffer...).
You won't get real HTML rendering to <canvas>
per se currently, because canvas context does not have functions to render HTML elements.
There are some emulations:
html2canvas project http://html2canvas.hertzen.com/index.html (basically a HTML renderer attempt built on Javascript + canvas)
HTML to SVG to <canvas>
might be possible depending on your use case:
https://github.com/miohtama/Krusovice/blob/master/src/tools/html2svg2canvas.js
Also if you are using Firefox you can hack some extended permissions and then render a DOM window to <canvas>
这篇关于将HTML元素渲染到< canvas>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!