'Extract Canvas or Jpeg Image out of Vpython Rendered Output using script
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.stack.imgur.com/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.
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user1114907 |
