Simple Shapes#

This example shows how to use the UI API. We will demonstrate how to draw some geometric shapes from FURY UI elements.

First, a bunch of imports.

import fury

First we need to fetch some icons that are included in FURY.

fury.data.fetch_viz_icons()
Data size is approximately 12KB
Dataset is already in place. If you want to fetch it again please first remove the folder /Users/skoudoro/.fury/icons

({'icomoon.tar.gz': ('https://digital.lib.washington.edu/researchworks/bitstream/handle/1773/38478/icomoon.tar.gz', 'BC1FEEA6F58BA3601D6A0B029EB8DFC5F352E21F2A16BA41099A96AA3F5A4735')}, '/Users/skoudoro/.fury/icons')

Let’s draw some simple shapes. First, a rectangle.

rect = fury.ui.Rectangle2D(size=(100, 100), position=(400, 400), color=(1, 0, 1))

Then we can draw a solid circle, or disk.

disk = fury.ui.Disk2D(outer_radius=50, center=(400, 200), color=(1, 1, 0))

Add an inner radius to make a ring.

ring = fury.ui.Disk2D(
    outer_radius=50, inner_radius=45, center=(500, 600), color=(0, 1, 1)
)

Now that all the elements have been initialised, we add them to the show manager.

current_size = (800, 800)
show_manager = fury.window.ShowManager(size=current_size, title="FURY Shapes Example")

show_manager.scene.add(rect)
show_manager.scene.add(disk)
show_manager.scene.add(ring)

interactive = False

if interactive:
    show_manager.start()

fury.window.record(show_manager.scene, size=current_size, out_path="viz_shapes.png")
viz shapes
/opt/homebrew/Caskroom/miniforge/base/envs/py39/lib/python3.9/site-packages/sphinx_gallery/gen_rst.py:722: UserWarning: We'll no longer accept the way you call the record function in future versions of FURY.

Here's how to call the Function record: record(scene='value', cam_pos='value', cam_focal='value', cam_view='value', out_path='value', path_numbering='value', n_frames='value', az_ang='value', magnification='value', size='value', reset_camera='value', screen_clip='value', stereo='value', verbose='value')

  exec(self.code, self.fake_main.__dict__)

Total running time of the script: (0 minutes 0.063 seconds)

Gallery generated by Sphinx-Gallery