Skip to content

Commit

Permalink
Merge branch 'main' of github.com:brentyi/viser into adam/camera_cont…
Browse files Browse the repository at this point in the history
…rols
  • Loading branch information
brentyi committed Sep 21, 2023
2 parents b10f39d + bf2f369 commit e633fbe
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions docs/source/examples/19_get_renders.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.. Comment: this file is automatically generated by `update_example_docs.py`.
It should not be modified manually.
Get Renders
==========================================


Example for getting renders from a client's viewport to the Python API.



.. code-block:: python
:linenos:
import time
import imageio.v3 as iio
import numpy as onp
import viser
def main():
server = viser.ViserServer()
button = server.add_gui_button("Render a GIF")
@button.on_click
def _(event: viser.GuiEvent) -> None:
client = event.client
assert client is not None
client.reset_scene()
images = []
for i in range(20):
positions = onp.random.normal(size=(30, 3)) * 3.0
client.add_spline_catmull_rom(
f"/catmull_{i}",
positions,
tension=0.5,
line_width=3.0,
color=onp.random.uniform(size=3),
)
images.append(client.get_render(height=1080, width=1920))
print("Writing GIF...")
iio.imwrite("saved.gif", images)
print("Wrote GIF!")
while True:
time.sleep(10.0)
if __name__ == "__main__":
main()

0 comments on commit e633fbe

Please sign in to comment.