How to use fury - 10 common examples

To help you get started, we’ve selected a few fury examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fury-gl / fury / docs / experimental / viz_shader_sines_1.py View on Github external
from fury import window
from viz_shader_canvas import cube


import vtk


scene = window.Scene()
showm = window.ShowManager(scene, order_transparent=True)

canvas_actor = cube()
canvas_actor.GetProperty().BackfaceCullingOff()
scene.add(canvas_actor)
scene.background((1, 1, 1))
mapper = canvas_actor.GetMapper()

# Modify the vertex shader to pass the position of the vertex
mapper.AddShaderReplacement(
    vtk.vtkShader.Vertex,
    "//VTK::Normal::Dec",  # replace the normal block
    True,  # before the standard replacements
    """
    //VTK::Normal::Dec  // we still want the default
    out vec4 myVertexMC;
github fury-gl / fury / docs / experimental / viz_shader_texture.py View on Github external
)

mapper.SetFragmentShaderCode(
    """
    //VTK::System::Dec  // always start with this line
    //VTK::Output::Dec  // always have this line in your FS
    in vec3 TexCoords;
    uniform samplerCube texture_0;
    
    void main() {
        gl_FragData[0] = texture(texture_0, TexCoords);
    }
    """
)

window.show(scene)
github fury-gl / fury / docs / experimental / viz_shader_canvas_sk.py View on Github external
showm.render()
    # scene.azimuth(10)


@window.vtk.calldata_type(window.vtk.VTK_OBJECT)
def vtk_shader_callback(caller, event, calldata=None):
    program = calldata
    global timer
    if program is not None:
        try:
            program.SetUniformf("time", timer)
        except ValueError:
            pass


mapper.AddObserver(window.vtk.vtkCommand.UpdateShaderEvent,
                   vtk_shader_callback)

mapper.AddShaderReplacement(
    vtk.vtkShader.Vertex,
    "//VTK::Normal::Dec",
    True,
    """
    //VTK::Normal::Dec
    out vec4 myVertexMC;
    in vec3 my_centers[3]; // now declare our attribute
    out vec3 my_centers_out[3];
    """,
    False
)

mapper.AddShaderReplacement(
github fury-gl / fury / docs / experimental / viz_shader_sines_1.py View on Github external
showm.render()
    # scene.azimuth(10)


@window.vtk.calldata_type(window.vtk.VTK_OBJECT)
def vtk_shader_callback(caller, event, calldata=None):
    program = calldata
    global timer
    if program is not None:
        try:
            program.SetUniformf("time", timer)
        except ValueError:
            pass


mapper.AddObserver(window.vtk.vtkCommand.UpdateShaderEvent,
                   vtk_shader_callback)

mapper.AddShaderReplacement(
    vtk.vtkShader.Fragment,  # // in the fragment shader
    "//VTK::Light::Impl",  # // replace the light block
    False,  # // after the standard replacements
    """
    //VTK::Light::Impl  // we still want the default calc
    vec3 rColor = vec3(.9, .0, .3);
    vec3 gColor = vec3(.0, .9, .3);
    vec3 bColor = vec3(.0, .3, .9);
    vec3 yColor = vec3(.9, .9, .3);

    float yScale = .5;  // 1 / 2. Original
    float xScale = 2.5;  // 5. Original
    float shiftScale = .2;  // .2 Original
github fury-gl / fury / test_sdfbranchmulti.py View on Github external
from fury import actor, window
import numpy as np

scene = window.Scene()
scene.background((1.0, 0.8, 0.8))
centers = np.array([[0, 0, 0]])
sdfactor = actor.multi_sdf(centers=centers, scale=6)
scene.add(sdfactor)

scene.add(actor.axes())
window.show(scene, size=(1920, 1080))
github fury-gl / fury / docs / tutorials / 04_others / viz_timers.py View on Github external
tb.message = "Let's count up to 100 and exit :" + str(cnt)
    showm.scene.azimuth(0.05 * cnt)
    sphere_actor.GetProperty().SetOpacity(cnt/100.)
    showm.render()
    if cnt == 100:
        showm.exit()


scene.add(tb)

# Run every 200 milliseconds
showm.add_timer_callback(True, 200, timer_callback)

showm.start()

window.record(showm.scene, size=(900, 768), out_path="viz_timer.png")
github fury-gl / fury / docs / tutorials / 04_others / viz_timers.py View on Github external
scene = window.Scene()

sphere_actor = actor.sphere(centers=xyz,
                            colors=colors,
                            radii=radii)

scene.add(sphere_actor)

showm = window.ShowManager(scene,
                           size=(900, 768), reset_camera=False,
                           order_transparent=True)

showm.initialize()

tb = ui.TextBlock2D(bold=True)

# use itertools to avoid global variables
counter = itertools.count()


def timer_callback(_obj, _event):
    cnt = next(counter)
    tb.message = "Let's count up to 100 and exit :" + str(cnt)
    showm.scene.azimuth(0.05 * cnt)
    sphere_actor.GetProperty().SetOpacity(cnt/100.)
    showm.render()
    if cnt == 100:
        showm.exit()


scene.add(tb)
github scilus / scilpy / scripts / scil_visualize_seeds.py View on Github external
tractogram = load_tractogram(args.tractogram, 'same')
    # Streamlines are saved in RASMM but seeds are saved in VOX
    # This might produce weird behavior with non-iso
    tractogram.to_vox()

    streamlines = tractogram.streamlines
    if 'seeds' not in tractogram.data_per_streamline:
        parser.error('Tractogram does not contain seeds')
    seeds = tractogram.data_per_streamline['seeds']

    # Make display objects
    streamlines_actor = actor.line(streamlines)
    points = actor.dots(seeds, color=(1., 1., 1.))

    # Add display objects to canvas
    r = window.Renderer()
    r.add(streamlines_actor)
    r.add(points)

    # Show and record if needed
    if args.save is not None:
        window.record(r, out_path=args.save, size=(1000, 1000))
    window.show(r)
github fury-gl / fury / docs / tutorials / 04_others / viz_spiky.py View on Github external
vertices=vertices, triangles=triangles, colors=primitive_colors,
    normals=normals, backface_culling=True)

##############################################################################
# We add all actors (visual objects) defined above to the scene.

scene.add(point_actor)
scene.add(arrow_actor)
scene.add(primitive_actor)
scene.add(actor.axes())

##############################################################################
# The ShowManager class is the interface between the scene, the window and the
# interactor.

showm = window.ShowManager(scene,
                           size=(900, 768), reset_camera=False,
                           order_transparent=True)

##############################################################################
# We want to make a small animation for fun!
# We can determine the duration of animation with using the ``counter``.
# Use itertools to avoid global variables.

counter = itertools.count()

##############################################################################
# The timer will call this user defined callback every 200 milliseconds. The
# application will exit after the callback has been called 20 times.


def timer_callback(_obj, _event):
github fury-gl / fury / docs / experimental / viz_sdf.py View on Github external
}
    else{
    	fragOutput0 = vec4(0, 0, 0, 0.3);
    }



	""",
	False
)



scene.add(box_actor)
scene.add(actor.axes())
window.show(scene, size=(1920, 1200))