Skip to content

Commit

Permalink
DOC: updated Sphere&material docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
m-agour committed Dec 15, 2024
1 parent fdc1388 commit a05fe70
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
37 changes: 37 additions & 0 deletions fury/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions fury/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a05fe70

Please sign in to comment.