Exemplo n.º 1
0
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.ren.add(disk)
    # Uncomment this to start the visualisation
    # show_manager.start()

    colors = [disk.color]
    arr = window.snapshot(show_manager.ren, size=window_size, offscreen=True)
    report = window.analyze_snapshot(arr, colors=colors)
    assert report.objects == 1
    assert report.colors_found

    # Test visibility off.
    disk.set_visibility(False)
    arr = window.snapshot(show_manager.ren, size=window_size, offscreen=True)
    report = window.analyze_snapshot(arr)
    assert report.objects == 0
Exemplo n.º 2
0
from dipy.viz import read_viz_icons, fetch_viz_icons

from dipy.viz import ui, window
"""
Shapes
======

Let's start by drawing some simple shapes. First, a rectangle.
"""

rect = ui.Rectangle2D(size=(200, 200), position=(400, 300), color=(1, 0, 1))
"""
Then we can draw a solid circle, or disk.
"""

disk = ui.Disk2D(outer_radius=50, center=(500, 500), color=(1, 1, 0))
"""
Add an inner radius to make a ring.
"""

ring = ui.Disk2D(outer_radius=50,
                 inner_radius=45,
                 center=(500, 300),
                 color=(0, 1, 1))
"""
Image
=====

Now let's display an image. First we need to fetch some icons that are included
in DIPY.
"""