如何将 webkit 转换后的画布绘制成一张?
我有一个 div,其中包含 6 个画布,并应用了不同的 webkit 变换,我想将此 div 的内容“绘制”到一个画布中(“截取此 div 的屏幕截图”)。但似乎这会有点棘手,因为无法将 div 直接绘制到画布中,并且当我尝试将转换后的画布绘制到另一画布中时,不会应用 webkit 转换。
是否可以使用画布变换(缩放、平移等)正确绘制这些画布?有没有什么好的库可以帮助您将 3d 转换为 2d? 提前致谢。
I have a div which contains 6 canvases with different webkit transromations applied and I want to "draw" the content of this div into one canvas ("take a screenshot" of this div). But seems like it's going to be a little tricky, because there is no way to draw div directly into canvas and webkit transformations are not applied when I'm trying to draw transformed canvas into another one.
Is it possible to properly draw these canvases using canvas transformations (scale, translate, etc)? Is there any good lib which helps you to convert 3d transformations into 2d?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法将
div
的内容捕获为图像,但您可以使用父画布并将其他内容绘制到其中。您可以通过使用父画布上下文的drawImage
方法并将源画布作为图像参数传递来完成此操作。通过设置目标上下文的转换使用此处定义的方法,您可以定义任何仿射你想要的变换(缩放、平移、旋转 - 但不是透视)。
It's not possible to capture the contents of a
div
as an image, but you could use a parent canvas and draw the others into it. You can do that by using thedrawImage
method of the parent canvas's context and pass the source canvas as the image argument.By setting the transformation of the destination context with the methods defined here you can define whatever affine transformation you want (scaling, translation, rotation - but not perspective).