background_image.py 857 B

12345678910111213141516171819202122232425262728293031
  1. """
  2. Set a jpeg background image
  3. on a separate rendering layer
  4. """
  5. from vedo import Plotter, dataurl, Cube, VedoLogo
  6. # Create a plotter object with 4 subrenderers
  7. # and individual camera for each one
  8. plt = Plotter(
  9. N=4,
  10. sharecam=False, # each subrenderer has its own camera
  11. bg=dataurl+"images/tropical.jpg", # set the background image
  12. )
  13. # Load a 3D model of a flamingo and rotate it so it is upright
  14. a1 = Cube().rotate_z(20)
  15. # Display a docstring on the second subrenderer
  16. plt.at(2).show(__doc__)
  17. # Zoom in on the background image to fill the window
  18. plt.background_renderer.GetActiveCamera().Zoom(1.8)
  19. # Display a logo on the first subrenderer
  20. plt.at(0).show(VedoLogo(distance=2))
  21. # Display the flamingo model on the fourth subrenderer
  22. plt.at(3).show(a1)
  23. # Allow the plot to be interacted with and then close it
  24. plt.interactive().close()