cellects.display.param
cellects.display.param
This script contains color, font, and size parameters for displaying images, videos, and plots.
generate_color_gradient(colors, n_steps)
Generate a linear color gradient interpolating between a sequence of RGB colors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
colors
|
list
|
List of RGB tuples defining the colors to interpolate through. |
required |
n_steps
|
int
|
Total number of color tuples to generate to fill the gradient between the provided colors. |
required |
Returns:
| Type | Description |
|---|---|
list
|
A list of RGB tuples forming a gradient between the provided colors. |
Examples:
>>> colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255)]
>>> gradient = generate_color_gradient(colors, 5)
>>> print(gradient)
[(255.0, 0.0, 0.0), (127.5, 127.5, 0.0), (0.0, 255.0, 0.0),
(0.0, 127.5, 127.5), (0.0, 0.0, 255.0)]
Source code in src/cellects/display/param.py
get_mpl_colormap(cmap_name)
Returns a linear color range array for the given matplotlib colormap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmap_name
|
str
|
The name of the colormap to get. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
A 256x1x3 array of bytes representing the linear color range. |
Examples:
Source code in src/cellects/display/param.py
random_pastel_colors(color_nb, hexadecimal=False)
Generate random pastel colors.
This function generates a specified number of random pastel colors by manipulating the HSV color space to ensure a soft, pastel-like appearance. The generated colors can be returned either in hexadecimal format or as RGB tuples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
color_nb
|
int
|
Number of pastel colors to generate. |
required |
hexadecimal
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
List[Union[tuple, str]]
|
A list of generated pastel colors. Each color is represented as an RGB tuple or hexadecimal
string, depending on the value of |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the |
Examples:
>>> colors = random_pastel_colors(3, hexadecimal=True)
>>> print(colors)
['#d9d8ff', '#ffdabd', '#ffe5d3']
>>> colors = random_pastel_colors(3, hexadecimal=False)
>>> print(colors)
[(221, 187, 255), (255, 218, 187), (255, 227, 211)]