diff --git a/fury/actor.py b/fury/actor.py index d35f765e3..0d3976ecf 100644 --- a/fury/actor.py +++ b/fury/actor.py @@ -15,6 +15,43 @@ def sphere( material='phong', enable_picking=True ): + """ + Visualize one or many spheres with different colors and radii. + + Parameters + ---------- + centers : ndarray, shape (N, 3) + Spheres positions. + colors : ndarray, shape (N, 3) or (N, 4) or tuple (3,) or tuple (4,) + RGB or RGBA (for opacity) R, G, B, and A should be in the range [0, 1]. + radii : float or ndarray, shape (N,) + Sphere radius. Can be a single value for all spheres or an array of radii for each sphere. + phi : int, optional + The number of segments in the longitude direction. Default is 16. + theta : int, optional + The number of segments in the latitude direction. Default is 16. + opacity : float, optional + Takes values from 0 (fully transparent) to 1 (opaque). Default is None (fully opaque). + material : str, optional + The material type for the spheres. Options are 'phong' (default) and 'basic'. + enable_picking : bool, optional + Whether the spheres should be pickable in a 3D scene. Defaults to True. + + Returns + ------- + mesh_actor : Actor + A mesh actor containing the generated spheres, with the specified material and properties. + + Examples + -------- + >>> from fury import window, actor + >>> scene = window.Scene() + >>> centers = np.random.rand(5, 3) + >>> colors = np.random.rand(5, 3) + >>> sphere_actor = actor.sphere(centers, colors, radii=0.5) + >>> scene.add(sphere_actor) + >>> # window.show(scene) + """ scales = radii directions = (1, 0, 0) diff --git a/fury/material.py b/fury/material.py index 07bef9913..34f8261b0 100644 --- a/fury/material.py +++ b/fury/material.py @@ -2,11 +2,30 @@ def _create_mesh_material( + material='phong', enable_picking=True, color=None, opacity=1.0): + """ + Create a mesh material. + + Parameters + ---------- + material : str + The type of material to create. Options are 'phong' (default) and 'basic'. + enable_picking : bool + Whether the material should be pickable in a scene. Defaults to True. + color : tuple or None + The color of the material, represented as an RGBA tuple. If None, the default color is used. Defaults to None. + opacity : float + The opacity of the material, from 0 (transparent) to 1 (opaque). Defaults to 1.0. + Returns + ------- + gfx.MeshMaterial + A mesh material object of the specified type with the given properties. + """ if material == 'phong': return gfx.MeshPhongMaterial( pick_write=enable_picking,