def test_ui_disk_2d(): window_size = (700, 700) show_manager = window.ShowManager(size=window_size) disk = ui.Disk2D(outer_radius=20, inner_radius=5) disk.position = (50, 80) npt.assert_equal(disk.position, (50, 80)) disk.color = (1, 0.5, 0) npt.assert_equal(disk.color, (1, 0.5, 0)) disk.opacity = 0.5 npt.assert_equal(disk.opacity, 0.5) # Check the rectangle is drawn at right place. show_manager.scene.add(disk) # Uncomment this to start the visualisation # show_manager.start() colors = [disk.color] arr = window.snapshot(show_manager.scene, size=window_size, offscreen=True) report = window.analyze_snapshot(arr, colors=colors) npt.assert_equal(report.objects, 1) # Should be False because of the offscreen npt.assert_equal(report.colors_found, [False]) # Test visibility off. disk.set_visibility(False) arr = window.snapshot(show_manager.scene, size=window_size, offscreen=True) report = window.analyze_snapshot(arr) npt.assert_equal(report.objects, 0)
from fury.data import fetch_viz_icons ############################################################################## # First we need to fetch some icons that are included in FURY. fetch_viz_icons() ############################################################################### # Let's draw some simple shapes. First, a rectangle. rect = ui.Rectangle2D(size=(100, 100), position=(400, 400), color=(1, 0, 1)) ############################################################################### # Then we can draw a solid circle, or disk. disk = ui.Disk2D(outer_radius=50, center=(400, 200), color=(1, 1, 0)) ############################################################################### # Add an inner radius to make a ring. ring = 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 = window.ShowManager(size=current_size, title="FURY Shapes Example")