使用脚本从 Vpython 渲染输出中提取 Canvas 或 Jpeg 图像
希望你们一切都好。
我正在尝试绘制一个 3D 文本,并将其嵌入到 HTML 文档中。 为此,我找到了 vpython,它可以使用 CANVAS 在浏览器窗口中绘制 3D 文本并渲染结果。
有没有简单的方法可以直接从 vpython 脚本导出渲染的画布或光栅图像(jpeg/png)?
[这是jupyter笔记本的结果] [1]: https://i.sstatic.net/Z2YUH.png
执行相同的代码从 python 文件启动浏览器并呈现 HTML 页面。
一旦我获得渲染的画布甚至光栅图像,我就可以使用它。
Hope you are all doing well.
I am trying to draw a 3D-text which I want to embed into an HTML document.
So for this I found vpython which can draw 3D text and render result in browser window using CANVAS.
Is there any easy way to get that rendered canvas or raster image (jpeg/png) exported right from the the vpython script?.
[Here is jupyter notebook result]
[1]: https://i.sstatic.net/Z2YUH.png
Same code executed from python file launches the browser having rendered HTML page.
Once I get rendered canvas or even raster image I will be able to use it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确,以下方法应该有效:访问 webvpython.org 并使用 Google 帐户登录。创建一个新文件,其中包含标题“GlowScript 3.2 VPython”。添加 3D 文本语句,例如 text(text='Hello')。单击“运行此程序”以检查其外观是否符合您的要求,然后单击“编辑此程序”,然后单击“共享或导出此程序”。复制从(非常短的)VPython 程序转译的 JavaScript 代码并将其存储在 .html 文件中。双击该 .html 文件,这将调用浏览器并显示 3D 文本。您可以在自己的 html 中安装 JavaScript 代码和/或使用 iframe 嵌入它。或者,如果您只想创建图像,请使用 scene.capture(某个文件名)将 .png 文件存储到您的下载文件夹中。
If I understand correctly, the following approach should work: Go to webvpython.org and log in with a Google account. Create a new file, which will have a header "GlowScript 3.2 VPython". Add your 3D text statement such as text(text='Hello'). Click "Run this program" to check that it looks the way you want, then click "Edit this program" followed by clicking "Share or export this program". Copy the JavaScript code that has been transpiled from your (very short) VPython program and store it in an .html file. Double-click that .html file, which will invoke a browser and display the 3D text. You can install the JavaScript code in your own html and/or use iframe to embed it. Alternatively, if you simply want to create an image, use scene.capture(some file name) to store a .png file into your Download folder.