Skip to content

Commit

Permalink
RF: Updated viz examples.
Browse files Browse the repository at this point in the history
- Updated the examples to work properly after actor addition.
- Updated the imports for the show manager, scene and io.
- Removed v2 refernce from import.
- Removed the old trial examples.
  • Loading branch information
maharshi-gor committed Dec 20, 2024
1 parent 94f6e2b commit 5608be3
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 347 deletions.
150 changes: 0 additions & 150 deletions docs/examples/example.ipynb

This file was deleted.

33 changes: 0 additions & 33 deletions docs/examples/example.py

This file was deleted.

23 changes: 0 additions & 23 deletions docs/examples/example_offscreen.py

This file was deleted.

79 changes: 0 additions & 79 deletions docs/examples/example_streamlines.py

This file was deleted.

37 changes: 0 additions & 37 deletions docs/examples/example_ui.py

This file was deleted.

25 changes: 16 additions & 9 deletions docs/examples/viz_display.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
from fury.v2.window import display, record
from fury.v2.actor import sphere
import numpy as np

sphere_actor0 = sphere(15, color=(1, 0, 0, 1), position=(15, 0, 0))
sphere_actor1 = sphere(15, color=(0, 1, 0, 1), position=(0, 15, 0))
sphere_actor2 = sphere(15, color=(0, 0, 1, 1), position=(0, 0, 15))
from fury.window import display, snapshot
from fury.actor import sphere

###############################################################################
# Let's create sphere actor to add three spheres to display.

sphere_actor = sphere(
np.asarray([(15, 0, 0), (0, 15, 0), (0, 0, 15)]).reshape((3, 3)),
radii=15,
colors=np.asarray([(1, 0, 0), (0, 1, 0), (0, 0, 1)]).reshape((3, 3)),
phi=48,
theta=48,
)

interactive = False

if __name__ == "__main__":
if interactive:
display(actors=(sphere_actor0, sphere_actor1, sphere_actor2))
display(actors=[sphere_actor])
else:
record(
actors=(sphere_actor0, sphere_actor1, sphere_actor2), fname="display.png"
)
snapshot(actors=[sphere_actor], fname="display.png")
41 changes: 33 additions & 8 deletions docs/examples/viz_multi_screen.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from fury.v2.window import ShowManager, Scene, record
from fury.v2.actor import sphere
import numpy as np

from fury.window import ShowManager, Scene, snapshot
from fury.actor import sphere
from fury.data import read_viz_cubemap, fetch_viz_cubemaps
from fury.v2.io import load_cube_map_texture
from fury.io import load_cube_map_texture


###############################################################################
Expand Down Expand Up @@ -29,11 +31,34 @@

scene0 = Scene(skybox=cube_map)
scene1 = Scene(background=(1, 1, 1, 1))
scene2 = Scene(background=(1, 0, 1, 1))
scene2 = Scene(background=(1, 0, 0, 1))

###############################################################################
# Let's create three different sphere actors to add to respective scenes.
# Note: Adding same actor to multiple scenes will not work and only add to the
# last scene that got the actor added to it.

sphere_actor0 = sphere(15, color=(1, 0, 0, 1), position=(0, 0, 0))
sphere_actor1 = sphere(15, color=(1, 0, 0, 1), position=(0, 0, 0))
sphere_actor2 = sphere(15, color=(1, 0, 0, 1), position=(0, 0, 0))
sphere_actor0 = sphere(
np.zeros((1, 3)),
colors=(1, 0, 1, 1),
radii=15.0,
phi=48,
theta=48,
)
sphere_actor1 = sphere(
np.zeros((1, 3)),
colors=(1, 0, 1, 1),
radii=15.0,
phi=48,
theta=48,
)
sphere_actor2 = sphere(
np.zeros((1, 3)),
colors=(1, 0, 1, 1),
radii=15.0,
phi=48,
theta=48,
)

scene0.add(sphere_actor0)
scene1.add(sphere_actor1)
Expand All @@ -51,7 +76,7 @@
)
show_m.start()
else:
record(
snapshot(
scene=[scene0, scene1, scene2],
fname="multi_screen.png",
screen_config=[2, 1],
Expand Down
21 changes: 13 additions & 8 deletions docs/examples/viz_skybox.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from fury.v2.window import ShowManager, Scene, record
from fury.v2.actor import sphere
import numpy as np

from fury.window import ShowManager, Scene, snapshot
from fury.actor import sphere
from fury.data import read_viz_cubemap, fetch_viz_cubemaps
from fury.v2.io import load_cube_map_texture
from fury.io import load_cube_map_texture


###############################################################################
Expand Down Expand Up @@ -29,11 +31,14 @@

scene = Scene(skybox=cube_map)

sphere_actor = sphere(15, color=(1, 0, 1, 1), position=(0, 0, 0))
sphere_actor1 = sphere(15, color=(1, 0, 1, 1), position=(10, 10, 10))
sphere_actor = sphere(
np.zeros((1, 3)),
colors=(1, 0, 1, 1),
radii=15.0,
phi=48,
theta=48,
)
scene.add(sphere_actor)
scene.add(sphere_actor1)


interactive = False

Expand All @@ -42,4 +47,4 @@
show_m = ShowManager(scene=scene, title="FURY 2.0: Skybox Example")
show_m.start()
else:
record(scene=scene, fname="skybox.png")
snapshot(scene=scene, fname="skybox.png")
1 change: 1 addition & 0 deletions fury/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
run = run
Canvas = WgpuCanvas
OffscreenCanvas = OffscreenWgpuCanvas
JupyterCanvas = None
if have_jupyter_rfb:
JupyterCanvas = JupyterWgpuCanvas

0 comments on commit 5608be3

Please sign in to comment.