Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_scene_creation_notebook():
settings.notebookBackend = "k3d"
Scene()
settings.notebookBackend = None
def test_scene_creation_notebook():
settings.notebookBackend = "k3d"
Scene()
settings.notebookBackend = None
- 'folder' -> str, path to folder where to save screenshots
- 'name' -> str, filename to prepend to screenshots files
- 'format' -> str, 'png', 'svg' or 'jpg'
- scale -> float, values > 1 yield higher resultion screenshots
:param use_default_key_bindings: if True the defualt keybindings from vedo are used, otherwise
a custom function that can be used to take screenshots with the parameter above.
"""
# Setup a few rendering options
self.verbose = verbose
self.display_inset = (
display_inset
if display_inset is not None
else brainrender.DISPLAY_INSET
)
if vedosettings.notebookBackend == "k3d":
self.jupyter = True
else:
self.jupyter = False
if self.display_inset and self.jupyter:
print(
"Setting 'display_inset' to False as this feature is not \
available in juputer notebooks"
)
self.display_inset = False
# Camera parameters
self.camera = get_scene_camera(camera, self.atlas)
# Create vedo plotter
self.plotter = Plotter(**get_scene_plotter_settings(self.jupyter))
def export_for_web(self, filepath="brexport.html"):
"""
This function is used to export a brainrender scene
for hosting it online. It saves an html file that can
be opened in a web browser to show an interactive brainrender scene
"""
if not filepath.endswith(".html"):
raise ValueError("Filepath should point to a .html file")
# prepare settings
vedosettings.notebookBackend = "k3d"
# Create new plotter and save to file
plt = Plotter()
plt.add(self.actors)
plt = plt.show(interactive=False)
plt.camera[-2] = -1
print(
"Ready for exporting. Exporting scenes with many actors might require a few minutes"
)
with open(filepath, "w") as fp:
fp.write(plt.get_snapshot())
print(
f"The brainrender scene has been exported for web. The results are saved at {filepath}"
)
plt.add(self.actors)
plt = plt.show(interactive=False)
plt.camera[-2] = -1
print(
"Ready for exporting. Exporting scenes with many actors might require a few minutes"
)
with open(filepath, "w") as fp:
fp.write(plt.get_snapshot())
print(
f"The brainrender scene has been exported for web. The results are saved at {filepath}"
)
# Reset settings
vedosettings.notebookBackend = None
self.jupyter = False