简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM